gcp

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package gcp provides a high level interface to the GCP part of the RSC platform.

Index

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 NewAPI deprecated

func NewAPI(gql *graphql.Client) API

Deprecated: use Wrap instead.

func Wrap added in v0.7.0

func Wrap(client *polaris.Client) API

Wrap the RSC client in the azure API.

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

func (a API) Permissions(ctx context.Context, features []core.Feature) (Permissions, error)

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

func (a API) PermissionsUpdatedForDefault(ctx context.Context, features []core.Feature) error

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

func (a API) ServiceAccount(ctx context.Context) (string, error)

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.

func (CloudAccount) Feature added in v0.3.0

func (c CloudAccount) Feature(feature core.Feature) (Feature, bool)

Feature returns the specified feature from the CloudAccount's features.

type Feature

type Feature struct {
	core.Feature
	Status core.Status
}

Feature for Google Cloud Platform projects.

type IdentityFunc

type IdentityFunc func(ctx context.Context) (identity, error)

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

type OptionFunc func(ctx context.Context, opts *options) error

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 Permissions added in v0.3.0

type Permissions []string

Permissions for GCP.

type ProjectFunc

type ProjectFunc func(ctx context.Context) (project, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL