s3

package
v0.135.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageClassStandard = s3.StorageClassStandardIa
	StorageClassCold     = "COLD"
	StorageClassIce      = "ICE"
)
View Source
const (
	TypeCanonicalUser = s3.TypeCanonicalUser
	TypeGroup         = s3.TypeGroup
)
View Source
const (
	PermissionFullControl = s3.PermissionFullControl
	PermissionRead        = s3.PermissionRead
	PermissionWrite       = s3.PermissionWrite
)
View Source
const (
	ObjectLockEnabled = s3.ObjectLockEnabledEnabled
)
View Source
const (
	ServerSideEncryptionAwsKms = s3.ServerSideEncryptionAwsKms
)

Variables

View Source
var (
	ObjectLockEnabledValues         = s3.ObjectLockEnabled_Values()
	ObjectLockRetentionModeValues   = s3.ObjectLockRetentionMode_Values()
	ObjectLockLegalHoldStatusValues = s3.ObjectLockLegalHoldStatus_Values()
)
View Source
var ErrBucketNotFound = errors.New("bucket not found")
View Source
var ErrObjectNotFound = errors.New("object not found")

Functions

func IsErr

func IsErr(err error, code ErrCode) bool

IsErr returns true if the error matches all these conditions:

  • err is of type awserr.Error
  • Error.Code() matches code

func RetryLongTermOperations

func RetryLongTermOperations[T any](ctx context.Context, f func() (T, error)) (T, error)

RetryLongTermOperations retries on some AWS codes because some previous operations are asynchronous and need to wait for the result.

func RetryOnCodes

func RetryOnCodes[T any](ctx context.Context, codes []ErrCode, f func() (T, error)) (T, error)

func S3TagsToRaw

func S3TagsToRaw(tags []*s3.Tag) map[string]string

func TagsToRaw

func TagsToRaw(tags []Tag) map[string]string

func TagsToS3

func TagsToS3(tags []Tag) []*s3.Tag

func TransitionHash

func TransitionHash(v interface{}) int

Types

type Bucket

type Bucket struct {
	DomainName string
	Policy     string
	CORSRules  []map[string]interface{}
	Website    *WebsiteInfo
	Grants     []interface{}
	Versioning []map[string]interface{}
	ObjectLock []map[string]interface{}
	Logging    []map[string]interface{}
	Lifecycle  []map[string]interface{}
	Encryption []map[string]interface{}
	Tags       []Tag
}

type BucketACL

type BucketACL string
const (
	BucketACLOwnerFullControl BucketACL = "bucket-owner-full-control"
	BucketACLPublicRead       BucketACL = s3.BucketCannedACLPublicRead
	BucketACLPublicReadWrite  BucketACL = s3.BucketCannedACLPublicReadWrite
	BucketACLAuthRead         BucketACL = s3.BucketCannedACLAuthenticatedRead
	BucketACLPrivate          BucketACL = s3.BucketCannedACLPrivate
)

type CORSRule

type CORSRule struct {
	MaxAgeSeconds  int
	AllowedHeaders []*string
	AllowedMethods []*string
	AllowedOrigins []*string
	ExposeHeaders  []*string
}

func NewCORSRules

func NewCORSRules(raw []interface{}) []CORSRule

type Client

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

func NewClient

func NewClient(ctx context.Context, accessKey, secretKey, iamToken, url string) (*Client, error)

func (*Client) CreateBucket

func (c *Client) CreateBucket(ctx context.Context, bucket string, acl BucketACL) error

func (*Client) CreateObject

func (c *Client) CreateObject(ctx context.Context, data CreationData) (bool, error)

CreateObject creates a new object in the bucket with the given key and source. It returns true if the object was created, false if it was not created (but no error occurred),

func (*Client) DeleteBucket

func (c *Client) DeleteBucket(ctx context.Context, bucket string, force bool) error

func (*Client) DeleteObject

func (c *Client) DeleteObject(ctx context.Context, bucket, key string) error

func (*Client) GetBucket

func (c *Client) GetBucket(ctx context.Context, bucket, endpoint, acl string) (*Bucket, error)

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, bucket, key string) (*Object, error)

func (*Client) S3

func (c *Client) S3() *s3.S3

S3 use only for test for backward compatibility with old code do not use it in new code

func (*Client) UpdateBucketACL

func (c *Client) UpdateBucketACL(ctx context.Context, bucket string, acl BucketACL) error

func (*Client) UpdateBucketCORS

func (c *Client) UpdateBucketCORS(ctx context.Context, bucket string, rules []CORSRule) error

func (*Client) UpdateBucketGrants

func (c *Client) UpdateBucketGrants(ctx context.Context, bucket string, grants []Grant) error

func (*Client) UpdateBucketLifecycle

func (c *Client) UpdateBucketLifecycle(ctx context.Context, bucket string, rules []LifecycleRule) error

func (*Client) UpdateBucketLogging

func (c *Client) UpdateBucketLogging(ctx context.Context, bucket string, loggingStatus LoggingStatus) error

func (*Client) UpdateBucketObjectLock

func (c *Client) UpdateBucketObjectLock(ctx context.Context, bucket string, lock ObjectLock) error

func (*Client) UpdateBucketPolicy

func (c *Client) UpdateBucketPolicy(ctx context.Context, bucket, policy string) error

func (*Client) UpdateBucketServerSideEncryption

func (c *Client) UpdateBucketServerSideEncryption(
	ctx context.Context,
	bucket string,
	rules []ServerSideEncryptionRule,
) error

func (*Client) UpdateBucketTags

func (c *Client) UpdateBucketTags(ctx context.Context, bucket string, tags []Tag) error

func (*Client) UpdateBucketVersioning

func (c *Client) UpdateBucketVersioning(ctx context.Context, bucket string, status VersioningStatus) error

func (*Client) UpdateBucketWebsite

func (c *Client) UpdateBucketWebsite(ctx context.Context, bucket string, website *Website) error

func (*Client) UpdateObjectACL

func (c *Client) UpdateObjectACL(ctx context.Context, bucket, key, acl string) error

func (*Client) UpdateObjectLegalHold

func (c *Client) UpdateObjectLegalHold(ctx context.Context, bucket, key, status string) error

func (*Client) UpdateObjectRetention

func (c *Client) UpdateObjectRetention(
	ctx context.Context,
	bucket, key string,
	retention *ObjectRetention,
) error

func (*Client) UpdateObjectTags

func (c *Client) UpdateObjectTags(ctx context.Context, bucket, key string, tags []Tag) error

type CreationData

type CreationData struct {
	Source                    *Source
	Bucket                    string
	Key                       string
	ACL                       string
	ContentType               string
	ObjectLockLegalHoldStatus string
	ObjectRetention           *ObjectRetention
	Tags                      []Tag
}

type ErrCode

type ErrCode string
const (
	NoSuchBucket                                   ErrCode = s3.ErrCodeNoSuchBucket
	AccessDenied                                   ErrCode = "AccessDenied"
	BadRequest                                     ErrCode = "BadRequest"
	Forbidden                                      ErrCode = "Forbidden"
	MalformedPolicy                                ErrCode = "MalformedPolicy"
	BucketNotEmpty                                 ErrCode = "BucketNotEmpty"
	NoSuchBucketPolicy                             ErrCode = "NoSuchBucketPolicy"
	NoSuchCORSConfiguration                        ErrCode = "NoSuchCORSConfiguration"
	NotImplemented                                 ErrCode = "NotImplemented"
	NoSuchWebsiteConfiguration                     ErrCode = "NoSuchWebsiteConfiguration"
	ObjectLockConfigurationNotFoundError           ErrCode = "ObjectLockConfigurationNotFoundError"
	NoSuchLifecycleConfiguration                   ErrCode = "NoSuchLifecycleConfiguration"
	ServerSideEncryptionConfigurationNotFoundError ErrCode = "ServerSideEncryptionConfigurationNotFoundError"
	NoSuchEncryptionConfiguration                  ErrCode = "NoSuchEncryptionConfiguration"
)

type Grant

type Grant struct {
	Grantee    *Grantee
	Permission string
}

func NewGrants

func NewGrants(raw []interface{}) ([]Grant, error)

type Grantee

type Grantee struct {
	ID   *string
	Type *string
	URI  *string
}

type LifecycleAbortIncompleteMultipartUpload

type LifecycleAbortIncompleteMultipartUpload struct {
	DaysAfterInitiation *int64
}

type LifecycleExpiration

type LifecycleExpiration struct {
	Date                      *time.Time
	Days                      *int64
	ExpiredObjectDeleteMarker *bool
}

type LifecycleNoncurrentVersionExpiration

type LifecycleNoncurrentVersionExpiration struct {
	NoncurrentDays *int64
}

type LifecycleNoncurrentVersionTransition

type LifecycleNoncurrentVersionTransition struct {
	NoncurrentDays *int64
	StorageClass   *string
}

type LifecycleRule

type LifecycleRule struct {
	ID                             *string
	Status                         *string
	Filter                         *LifecycleRuleFilter
	Expiration                     *LifecycleExpiration
	AbortIncompleteMultipartUpload *LifecycleAbortIncompleteMultipartUpload
	NoncurrentVersionExpiration    *LifecycleNoncurrentVersionExpiration
	Transitions                    []LifecycleTransition
	NoncurrentVersionTransitions   []LifecycleNoncurrentVersionTransition
}

func NewLifecycleRules

func NewLifecycleRules(raw []interface{}, d *schema.ResourceData) ([]LifecycleRule, error)

type LifecycleRuleAndOperator

type LifecycleRuleAndOperator struct {
	ObjectSizeGreaterThan *int64
	ObjectSizeLessThan    *int64
	Prefix                *string
	Tags                  []Tag
}

type LifecycleRuleFilter

type LifecycleRuleFilter struct {
	Prefix                *string
	ObjectSizeGreaterThan *int64
	ObjectSizeLessThan    *int64
	Tag                   *Tag
	And                   *LifecycleRuleAndOperator
}

type LifecycleTransition

type LifecycleTransition struct {
	Date         *time.Time
	Days         *int64
	StorageClass *string
}

type LoggingStatus

type LoggingStatus struct {
	Enabled      bool
	TargetBucket *string
	TargetPrefix *string
}

func NewLoggingStatus

func NewLoggingStatus(raw []interface{}) LoggingStatus

type Object

type Object struct {
	Bucket                    string
	Key                       string
	ContentType               *string
	ObjectLockLegalHoldStatus *string
	ObjectRetention           *ObjectRetention
	Tags                      []Tag
}

type ObjectLock

type ObjectLock struct {
	Enabled bool
	Rule    *ObjectLockRule
}

func NewObjectLock

func NewObjectLock(raw []interface{}) ObjectLock

type ObjectLockRule

type ObjectLockRule struct {
	Mode  string
	Days  *int64
	Years *int64
}

type ObjectRetention

type ObjectRetention struct {
	Mode            string
	RetainUntilDate time.Time
}

type RedirectAllRequestsTo

type RedirectAllRequestsTo struct {
	HostName string
	Protocol string
}

type ServerSideEncryptionRule

type ServerSideEncryptionRule struct {
	SSEAlgorithm   string
	KMSMasterKeyID *string
}

func NewServerSideEncryptionRules

func NewServerSideEncryptionRules(raw []interface{}) []ServerSideEncryptionRule

type Source

type Source struct {
	Type  SourceType
	Value string
}

func (*Source) Parse

func (s *Source) Parse() (io.ReadSeeker, error)

type SourceType

type SourceType string
const (
	SourceTypeFile          SourceType = "file"
	SourceTypeContent       SourceType = "content"
	SourceTypeContentBase64 SourceType = "content_base64"
)

type Tag

type Tag struct {
	Key   string
	Value string
}

func NewTags

func NewTags(raw interface{}) []Tag

type VersioningStatus

type VersioningStatus string
const (
	VersioningEnabled  VersioningStatus = "Enabled"
	VersioningDisabled VersioningStatus = "Suspended"
)

func NewVersioningStatus

func NewVersioningStatus(raw []interface{}) VersioningStatus

type Website

type Website struct {
	IndexDocument         string
	ErrorDocument         string
	RedirectAllRequestsTo *RedirectAllRequestsTo
	RoutingRules          []*s3.RoutingRule
}

func NewWebsite

func NewWebsite(raw []interface{}) (*Website, error)

type WebsiteInfo

type WebsiteInfo struct {
	RawData  []map[string]interface{}
	Domain   string
	Endpoint string
}

Jump to

Keyboard shortcuts

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