gcs

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudStorageClient

type CloudStorageClient interface {
	IsInitialized(ctxIn context.Context) bool
	DoesBucketExist(ctxIn context.Context, project string, bucket string) (bool, error)
	BucketUsageInBytes(ctxIn context.Context, project string, bucket string) (float64, error)
	CreateBucket(ctxIn context.Context, project, bucket, location, dualLocation, storageClass string, lifetimeInDays uint, archiveTTM uint) error
	GetProject(ctxIn context.Context, projectID string) (*resourcemanagerpb.Project, error)
	SetBucketIAMPolicy(ctxIn context.Context, bucket string, policy *iam.Policy) error
	CreateObject(ctxIn context.Context, bucketName, objectName, content string) error
	DeleteBucket(ctxIn context.Context, bucket string) error
	DeleteObject(ctxIn context.Context, bucketName string, objectName string) error
	DeleteObjectsWithObjectMatch(ctxIn context.Context, bucketName string, prefix string, objectPattern *regexp.Regexp) (deleted int, err error)
	MoveObject(ctxIn context.Context, bucketName, oldObjectName, newObjectName string) error
	ReadObject(ctxIn context.Context, bucketName, objectName string) ([]byte, error)
	GetBuckets(ctxIn context.Context, project string) ([]string, error)
	Close(ctxIn context.Context)
	UpdateBucket(ctxIn context.Context, bucket string, lifetimeInDays uint, archiveTTM uint) error
	GetBucketDetails(ctxIn context.Context, bucket string) (*storage.BucketAttrs, error)
	DeleteObjectWithPrefix(ctxIn context.Context, bucket string, objectPrefixName string) error
}

CloudStorageClient define operations with the GCS

func NewCloudStorageClient

func NewCloudStorageClient(ctxIn context.Context, tokenSourceProvider impersonate.TargetPrincipalForProjectProvider, targetProjectID string) (CloudStorageClient, error)

NewCloudStorageClient create a new CloudStorageClient

func NewMockGcsClient

func NewMockGcsClient(initialized bool, shouldFail bool) CloudStorageClient

type CloudStorageClientFactory

type CloudStorageClientFactory interface {
	NewCloudStorageClient(targetProjectID string) (CloudStorageClient, error)
}

CloudStorageClientFactory creates a CloudStorageClient with the credentails for a specified project

type MockGcsClient

type MockGcsClient struct {
	ClientInitialized bool
	ShouldFail        bool
	ObjectContent     []byte
}

func (*MockGcsClient) BucketUsageInBytes

func (c *MockGcsClient) BucketUsageInBytes(ctxIn context.Context, project string, bucket string) (float64, error)

func (*MockGcsClient) Close

func (c *MockGcsClient) Close(ctxIn context.Context)

func (*MockGcsClient) CreateBucket

func (c *MockGcsClient) CreateBucket(ctxIn context.Context, project, bucket, location, dualLocation, storageClass string, lifetimeInDays uint, archiveTTM uint) error

func (*MockGcsClient) CreateObject

func (c *MockGcsClient) CreateObject(ctxIn context.Context, bucketName, objectName, content string) error

func (*MockGcsClient) DeleteBucket

func (c *MockGcsClient) DeleteBucket(ctxIn context.Context, bucket string) error

func (*MockGcsClient) DeleteObject

func (c *MockGcsClient) DeleteObject(ctxIn context.Context, bucketName string, objectName string) error

func (*MockGcsClient) DeleteObjectWithPrefix added in v1.5.1

func (c *MockGcsClient) DeleteObjectWithPrefix(ctxIn context.Context, bucket string, objectPrefixName string) error

func (*MockGcsClient) DeleteObjectsWithObjectMatch

func (c *MockGcsClient) DeleteObjectsWithObjectMatch(ctxIn context.Context, bucketName string, prefix string, objectPattern *regexp.Regexp) (deleted int, err error)

func (*MockGcsClient) DoesBucketExist

func (c *MockGcsClient) DoesBucketExist(ctxIn context.Context, project string, bucket string) (bool, error)

func (*MockGcsClient) GetBucketDetails added in v1.4.0

func (c *MockGcsClient) GetBucketDetails(ctxIn context.Context, bucket string) (*storage.BucketAttrs, error)

func (*MockGcsClient) GetBuckets

func (c *MockGcsClient) GetBuckets(ctxIn context.Context, project string) ([]string, error)

func (*MockGcsClient) GetProject added in v1.4.4

func (c *MockGcsClient) GetProject(ctxIn context.Context, projectID string) (*resourcemanagerpb.Project, error)

func (*MockGcsClient) IsInitialized

func (c *MockGcsClient) IsInitialized(ctxIn context.Context) bool

func (*MockGcsClient) MoveObject

func (c *MockGcsClient) MoveObject(ctxIn context.Context, bucketName, oldObjectName, newObjectName string) error

func (*MockGcsClient) ReadObject

func (c *MockGcsClient) ReadObject(ctxIn context.Context, bucketName, objectName string) ([]byte, error)

func (*MockGcsClient) SetBucketIAMPolicy added in v1.4.4

func (c *MockGcsClient) SetBucketIAMPolicy(ctxIn context.Context, bucket string, policy *iam.Policy) error

func (*MockGcsClient) UpdateBucket

func (c *MockGcsClient) UpdateBucket(ctxIn context.Context, bucket string, lifetimeInDays uint, archiveTTM uint) error

type TransferJobHandler

type TransferJobHandler struct {
	// contains filtered or unexported fields
}

TransferJobHandler represent api to deal with transfer jobs

func NewTransferJobHandler

func NewTransferJobHandler(ctxIn context.Context, tokenSourceProvider impersonate.TargetPrincipalForProjectProvider, targetProjectID string) (*TransferJobHandler, error)

NewTransferJobHandler create new TransferJobHandler

func (*TransferJobHandler) Close

func (t *TransferJobHandler) Close(ctxIn context.Context)

Close terminates terminates all resources in use

func (*TransferJobHandler) CreateTransferJob

func (t *TransferJobHandler) CreateTransferJob(ctxIn context.Context, srcProjectID, targetProjectID, srcBucket, targetBucket string, includePath, excludePath []string) (string, error)

CreateTransferJob create new transfer job

func (*TransferJobHandler) DeleteTransferJob

func (t *TransferJobHandler) DeleteTransferJob(ctxIn context.Context, targetProjectID, transferJobID string) error

DeleteTransferJob delete transfer job If job does not exist, it returns nil

func (*TransferJobHandler) GetStatusOfJob

func (t *TransferJobHandler) GetStatusOfJob(ctxIn context.Context, targetProjectID, name string) (TransferJobState, error)

GetStatusOfJob return actual status of transfer job

func (*TransferJobHandler) ReuseTransferJob added in v1.3.0

func (t *TransferJobHandler) ReuseTransferJob(ctxIn context.Context, srcProjectID, targetProjectID, srcBucket, targetBucket string, includePath, excludePath []string, transferJobID repository.TransferJobID) (string, error)

ReuseTransferJob takes a StorageTransferJob with the id transferJobID, patches (changes) the configuration so it meets the given backup specification and then starts a run.

type TransferJobState

type TransferJobState string

TransferJobState State is one of a sequence of states that a Job progresses through as it is processed.

const (
	// StateUnspecified is the default JobIterator state.
	StateUnspecified TransferJobState = "Unspecified"
	// Pending is a state that describes that the job is pending.
	Pending TransferJobState = "Pending"
	// Running is a state that describes that the job is running.
	Running TransferJobState = "Running"
	// Done is a state that describes that the job is done.
	Done TransferJobState = "Done"
	// Failed is a state that describes that the job complete unsuccessfully.
	Failed TransferJobState = "Failed"
)

Jump to

Keyboard shortcuts

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