Documentation
¶
Index ¶
- Constants
- Variables
- func NewGoogleStorageClient(ctx context.Context, retryOpts helper.RetryOptions, opts StorageClientOptions) (*storage.Client, error)
- type Blackbox
- type BucketName
- type Client
- type ClientOption
- type ClientOptions
- type DefaultTool
- func (d *DefaultTool) BuildObjectPath(ctx context.Context, parts ...string) (string, error)
- func (d *DefaultTool) Close(ctx context.Context) error
- func (d *DefaultTool) DefaultBucketAttrs(ctx context.Context, lc *storage.Lifecycle) (*storage.BucketAttrs, error)
- func (d *DefaultTool) DeleteObjectByName(ctx context.Context, bucketName, objectName string) error
- func (d *DefaultTool) DeleteObjectsByQuery(ctx context.Context, bucketName string, query *storage.Query) error
- func (d *DefaultTool) EnsureBucket(ctx context.Context, opts contract.EnsureBucketOptions) (*storage.BucketAttrs, error)
- func (d *DefaultTool) FindObjects(ctx context.Context, opts contract.FindObjectsOptions) ([]*storage.ObjectAttrs, error)
- func (d *DefaultTool) GenerateBucketName(ctx context.Context, e contract.EnvironmentOperator, suffix string) (string, error)
- func (d *DefaultTool) GenerateSignedObjectURLs(ctx context.Context, opts contract.GenerateSignedObjectURLsOptions) ([]string, error)
- func (d *DefaultTool) NewObjectQuery(ctx context.Context, parts ...string) (*storage.Query, error)
- func (d *DefaultTool) NewSignedURLOptions(ctx context.Context, expire bool) (*storage.SignedURLOptions, error)
- func (d *DefaultTool) UploadObject(ctx context.Context, opts contract.UploadObjectOptions) error
- func (d *DefaultTool) UploadObjects(ctx context.Context, opts contract.UploadObjectsOptions) error
- type Dependencies
- type LifeCycleBase
- type Loaded
- type StorageClientOptions
- type ToRegister
- type Tool
Constants ¶
const ( BucketWorksites = "worksites" BucketJobs = "jobs" BucketCalls = "calls" BucketReports = "reports" BucketTickets = "tickets" BucketContacts = "contacts" BucketUsers = "users" BucketChat = "chat" BucketQR = "qr" BucketMemos = "memos" )
Variables ¶
var ( LifeCycleTwoYears = helper.Point(int64(720)) LifeCycleYear = helper.Point(int64(360)) LifeCycleHalfYear = helper.Point(int64(180)) ObjectPathKey = contract.ToPubSubKey("object_path") BucketNameKey = contract.ToPubSubKey("bucket_name") ObjectModalityKey = contract.ToPubSubKey("object_modality") ObjectIDKey = contract.ToPubSubKey("object_id") ObjectMIMEKey = contract.ToPubSubKey("object_mime") )
Functions ¶
func NewGoogleStorageClient ¶
func NewGoogleStorageClient(ctx context.Context, retryOpts helper.RetryOptions, opts StorageClientOptions) (*storage.Client, error)
Types ¶
type BucketName ¶ added in v0.1.485
type BucketName = string
type Client ¶
type Client interface {
Blackbox
contract.BucketOperator
}
func NewClient ¶
func NewClient(ctx context.Context, d Dependencies, opts ClientOptions) (Client, error)
func NewNoopClient ¶ added in v0.1.494
func NewNoopClient() Client
type ClientOption ¶
type ClientOption func(*ClientOptions)
func WithBucketLocation ¶
func WithBucketLocation(x string) ClientOption
func WithCredentialsJSON ¶
func WithCredentialsJSON(x []byte) ClientOption
func WithExpirationURL ¶
func WithExpirationURL(x time.Duration) ClientOption
func WithLoaded ¶
func WithLoaded(x Loaded) ClientOption
func WithToRegister ¶ added in v0.1.485
func WithToRegister(x ToRegister) ClientOption
type ClientOptions ¶
type ClientOptions struct {
Loaded
T ToRegister
ExpirationURL time.Duration
}
func ApplyClientOptions ¶
func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions
type DefaultTool ¶
func NewTool ¶
func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool
func (*DefaultTool) BuildObjectPath ¶
BuildObjectPath concatenates object path segments.
func (*DefaultTool) Close ¶
func (d *DefaultTool) Close(ctx context.Context) error
Close closes the underlying client.
func (*DefaultTool) DefaultBucketAttrs ¶
func (d *DefaultTool) DefaultBucketAttrs(ctx context.Context, lc *storage.Lifecycle) (*storage.BucketAttrs, error)
DefaultBucketAttrs builds default attributes for a new bucket.
func (*DefaultTool) DeleteObjectByName ¶
func (d *DefaultTool) DeleteObjectByName(ctx context.Context, bucketName, objectName string) error
DeleteObjectByName deletes a single object from the specified bucket.
func (*DefaultTool) DeleteObjectsByQuery ¶
func (d *DefaultTool) DeleteObjectsByQuery(ctx context.Context, bucketName string, query *storage.Query) error
DeleteObjectsByQuery deletes all objects in a bucket that match the given query.
func (*DefaultTool) EnsureBucket ¶
func (d *DefaultTool) EnsureBucket(ctx context.Context, opts contract.EnsureBucketOptions) (*storage.BucketAttrs, error)
EnsureBucket creates the bucket if it does not exist.
func (*DefaultTool) FindObjects ¶
func (d *DefaultTool) FindObjects(ctx context.Context, opts contract.FindObjectsOptions) ([]*storage.ObjectAttrs, error)
FindObjects retrieves and sorts all objects in a bucket that match the given query.
func (*DefaultTool) GenerateBucketName ¶ added in v0.1.510
func (d *DefaultTool) GenerateBucketName(ctx context.Context, e contract.EnvironmentOperator, suffix string) (string, error)
GenerateBucketName returns a new bucket name.
func (*DefaultTool) GenerateSignedObjectURLs ¶
func (d *DefaultTool) GenerateSignedObjectURLs(ctx context.Context, opts contract.GenerateSignedObjectURLsOptions) ([]string, error)
GenerateSignedObjectURLs returns signed URLs for a list of object attributes in a bucket.
func (*DefaultTool) NewObjectQuery ¶
NewObjectQuery builds a new storage.Query.
func (*DefaultTool) NewSignedURLOptions ¶
func (d *DefaultTool) NewSignedURLOptions(ctx context.Context, expire bool) (*storage.SignedURLOptions, error)
NewSignedURLOptions builds signed URL options using credentials.
func (*DefaultTool) UploadObject ¶
func (d *DefaultTool) UploadObject(ctx context.Context, opts contract.UploadObjectOptions) error
UploadObject uploads a single object to a Google Cloud Storage bucket.
func (*DefaultTool) UploadObjects ¶
func (d *DefaultTool) UploadObjects(ctx context.Context, opts contract.UploadObjectsOptions) error
UploadObjects uploads multiple objects to a Google Cloud Storage bucket.
type Dependencies ¶
type Dependencies struct {
C contract.GoogleStorage
U contract.Unmarshaler
ENV contract.EnvironmentOperator
CP contract.Copier
P contract.PoolOperator
}
type LifeCycleBase ¶ added in v0.1.488
type LifeCycleBase = *int64
type StorageClientOptions ¶
type StorageClientOptions struct {
Loaded
}
type ToRegister ¶ added in v0.1.485
type ToRegister map[BucketName]LifeCycleBase
type Tool ¶
type Tool interface {
contract.BucketOperator
}