Documentation
¶
Overview ¶
Package gcp provides a high level interface to the GCP part of the RSC platform.
Index ¶
- type API
- func (a API) AddProject(ctx context.Context, project ProjectFunc, feature core.Feature, ...) (uuid.UUID, error)
- func (a API) Permissions(ctx context.Context, features []core.Feature) (Permissions, error)
- func (a API) PermissionsUpdated(ctx context.Context, id IdentityFunc, features []core.Feature) error
- func (a API) PermissionsUpdatedForDefault(ctx context.Context, features []core.Feature) error
- func (a API) Project(ctx context.Context, id IdentityFunc, feature core.Feature) (CloudAccount, error)
- func (a API) Projects(ctx context.Context, feature core.Feature, filter string) ([]CloudAccount, error)
- func (a API) RemoveProject(ctx context.Context, id IdentityFunc, feature core.Feature, ...) error
- func (a API) ServiceAccount(ctx context.Context) (string, error)
- func (a API) SetServiceAccount(ctx context.Context, project ProjectFunc, opts ...OptionFunc) error
- type CloudAccount
- type Feature
- type IdentityFunc
- type OptionFunc
- type Permissions
- type ProjectFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API for GCP project management.
func (API) AddProject ¶
func (a API) AddProject(ctx context.Context, project ProjectFunc, feature core.Feature, opts ...OptionFunc) (uuid.UUID, error)
AddProject adds the specified project to RSC for the given feature. If name or organization aren't given as an options they are derived from information in the cloud. The result can vary slightly depending on permissions. Returns the RSC cloud account id of the added project.
func (API) Permissions ¶ added in v0.3.0
Permissions returns all GCP permissions required to use the specified RSC features.
func (API) PermissionsUpdated ¶ added in v0.3.0
func (a API) PermissionsUpdated(ctx context.Context, id IdentityFunc, features []core.Feature) error
PermissionsUpdated notifies RSC that the permissions for the GCP service account for the RSC cloud account with the specified id has been updated. The permissions should be updated when a feature has the status StatusMissingPermissions. Updating the permissions is done outside this SDK. The features parameter is allowed to be nil. When features is nil all features are updated. Note that RSC is only notified about features with status StatusMissingPermissions.
func (API) PermissionsUpdatedForDefault ¶ added in v0.3.0
PermissionsUpdatedForDefault notifies RSC that the permissions for the default GCP service account has been updated. The permissions should be updated when a feature has the status StatusMissingPermissions. Updating the permissions is done outside the SDK. The features parameter is allowed to be nil. When features is nil all features are updated. Note that RSC is only notified about features with status StatusMissingPermissions.
func (API) Project ¶
func (a API) Project(ctx context.Context, id IdentityFunc, feature core.Feature) (CloudAccount, error)
Project returns the project with specified id.
func (API) Projects ¶
func (a API) Projects(ctx context.Context, feature core.Feature, filter string) ([]CloudAccount, error)
Projects return all projects with the specified feature matching the filter. The filter can be used to search for project id, project name and project number.
func (API) RemoveProject ¶
func (a API) RemoveProject(ctx context.Context, id IdentityFunc, feature core.Feature, deleteSnapshots bool) error
RemoveProject removes the project with the specified id from RSC for the given feature. If deleteSnapshots is true the snapshots are deleted otherwise they are kept. Note that snapshots are only considered to be deleted when removing the cloud native protection feature.
func (API) ServiceAccount ¶
ServiceAccount returns the default service account name. If no default service account has been set an empty string is returned.
func (API) SetServiceAccount ¶
func (a API) SetServiceAccount(ctx context.Context, project ProjectFunc, opts ...OptionFunc) error
SetServiceAccount sets the default service account. The service account set will be used for projects added without a service account key file. If name isn't given as an option it will be derived from information in the cloud. The result can vary slightly depending on permissions. The organization option does nothing. Note that it's not possible to remove a service account once it has been set.
type CloudAccount ¶
type CloudAccount struct { ID uuid.UUID NativeID string Name string ProjectNumber int64 OrganizationName string DefaultServiceAccount bool Features []Feature }
CloudAccount for Google Cloud Platform projects. If DefaultServiceAccount is true the cloud account depends on the default service account.
type IdentityFunc ¶
IdentityFunc returns a project identity initialized from the values passed to the function creating the IdentityFunc.
func CloudAccountID ¶
func CloudAccountID(cloudAccountID uuid.UUID) IdentityFunc
CloudAccountID returns an IdentityFunc that initializes the identity with the specified RSC cloud account id.
func ID ¶
func ID(project ProjectFunc) IdentityFunc
ID returns an IdentityFunc that initializes the identity with the id of the specified project.
func ProjectID ¶
func ProjectID(projectID string) IdentityFunc
ProjectID returns an IdentityFunc that initializes the identity with the specified project id.
func ProjectNumber ¶
func ProjectNumber(number int64) IdentityFunc
ProjectNumber returns an IdentityFunc that initializes the identity with the specified project number.
type OptionFunc ¶
OptionFunc gives the value passed to the function creating the OptionFunc to the specified options instance.
func Name ¶
func Name(name string) OptionFunc
Name returns an OptionFunc that gives the specified name to the options instance.
func Organization ¶
func Organization(name string) OptionFunc
Organization returns an OptionFunc that gives the specified organization name to the options instance.
type ProjectFunc ¶
ProjectFunc returns a project initialized from the values passed to the function creating the ProjectFunc.
func Credentials ¶
func Credentials(credentials *google.Credentials) ProjectFunc
Credentials returns a ProjectFunc that initializes the project with values from the specified credentials and the cloud using the credentials project id.
func Default ¶
func Default() ProjectFunc
Default returns a ProjectFunc that initializes the project with values from the default credentials and the cloud using the default credentials project id.
func KeyFile ¶
func KeyFile(keyFile string) ProjectFunc
KeyFile returns a ProjectFunc that initializes the project with values from the specified key file and the cloud using the key file project id.
func KeyFileWithProject ¶ added in v0.5.0
func KeyFileWithProject(keyFile, projectID string) ProjectFunc
KeyFileWithProject returns a ProjectFunc that initializes the project with values from the specified key file and the cloud using the given project id.
func Project ¶
func Project(projectID string, projectNumber int64) ProjectFunc
Project returns a ProjectFunc that initializes the project with the specified values.