store

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketNotEmpty = errors.New("bucket not empty")
View Source
var ErrInvalidDirectoryObject = errors.New("invalid directory object")
View Source
var ErrObjectNotFound = errors.New("object not found")

Functions

func GetSelfPolicy added in v0.4.0

func GetSelfPolicy(accessKey, bucket string) (policy.Statement, error)

GetSelfPolicy get default policy

func NewBucketMetadataSys

func NewBucketMetadataSys(db objmetadb.ObjStoreMetaDBAPI) *bucketMetadataSys

NewBucketMetadataSys - creates new policy system.

Types

type BucketInfo added in v0.4.0

type BucketInfo struct {
	Name    string `json:"name"`
	Size    uint64 `json:"size"`
	Objects uint64 `json:"objects"`
}

BucketInfo represents bucket usage of a bucket, and its relevant access type for an account

type BucketMetadata

type BucketMetadata struct {
	Name    string
	Region  string
	Owner   string
	Created time.Time

	PolicyConfig  *policy.Policy
	TaggingConfig *Tags
}

BucketMetadata contains bucket metadata.

func NewBucketMetadata

func NewBucketMetadata(name, region, accessKey string) *BucketMetadata

NewBucketMetadata creates BucketMetadata with the supplied name and Created to Now.

type BucketMetadataSysAPI added in v0.4.0

type BucketMetadataSysAPI interface {
	NewNSLock(bucket string) lock.RWLocker
	SetEmptyBucket(emptyBucket func(ctx context.Context, bucket string) (bool, error))
	CreateBucket(ctx context.Context, bucket string, region string, accessKey string) error
	GetBucketMeta(ctx context.Context, bucket string) (meta BucketMetadata, err error)
	HasBucket(ctx context.Context, bucket string) bool
	DeleteBucket(ctx context.Context, bucket string, accessKey string) error
	GetAllBucketsOfUser(ctx context.Context, username string) ([]BucketMetadata, error)
	GetAllBucketInfo(ctx context.Context) (allBucketInfo, error)
	UpdateBucketPolicy(ctx context.Context, bucket string, p *policy.Policy) error
	DeleteBucketPolicy(ctx context.Context, bucket string) error
	GetPolicyConfig(ctx context.Context, bucket string) (*policy.Policy, error)
	UpdateBucketTagging(ctx context.Context, bucket string, tags *Tags) error
	DeleteBucketTagging(ctx context.Context, bucket string) error
	GetTaggingConfig(ctx context.Context, bucket string) (*Tags, error)
}

BucketMetadataSysAPI BucketMetadata Sys

type BucketNotFound

type BucketNotFound struct {
	Bucket string
	Err    error
}

BucketNotFound - no bucket found.

func (BucketNotFound) Error

func (e BucketNotFound) Error() string

type BucketPolicy added in v0.4.0

type BucketPolicy string

BucketPolicy - Bucket level policy.

func GetPolicyName added in v0.4.0

func GetPolicyName(statements []policy.Statement, bucketName string, prefix string) BucketPolicy

GetPolicyName - Returns policy of given bucket name, prefix in given statements.

type BucketPolicyNotFound

type BucketPolicyNotFound struct {
	Bucket string
	Err    error
}

BucketPolicyNotFound - no bucket policy found.

func (BucketPolicyNotFound) Error

func (e BucketPolicyNotFound) Error() string

type BucketPolicySys added in v0.4.0

type BucketPolicySys struct {
	BmSys *bucketMetadataSys
}

BucketPolicySys - policy subsystem.

func NewIPolicySys added in v0.4.0

func NewIPolicySys(db objmetadb.ObjStoreMetaDBAPI) *BucketPolicySys

NewIPolicySys - creates new policy system.

func (*BucketPolicySys) IsAllowed added in v0.4.0

func (sys *BucketPolicySys) IsAllowed(ctx context.Context, args auth.Args) bool

IsAllowed - checks given policy args is allowed to continue the Rest API.

type BucketTaggingNotFound

type BucketTaggingNotFound struct {
	Bucket string
	Err    error
}

func (BucketTaggingNotFound) Error

func (e BucketTaggingNotFound) Error() string

type DataUsageInfo added in v0.4.0

type DataUsageInfo struct {
	TotalCaptivity uint64 `json:"totalCaptivity"`

	// Objects total count across all buckets
	ObjectsTotalCount uint64 `json:"objectsCount"`

	// Objects total size across all buckets
	ObjectsTotalSize uint64 `json:"objectsTotalSize"`
	// Total number of buckets in this cluster
	BucketsCount uint64 `json:"bucketsCount"`

	// Buckets usage info provides following information across all buckets
	// - total size of the bucket
	// - total objects in a bucket
	// - object size histogram per bucket
	BucketsUsage []BucketInfo `json:"bucketsUsageInfo"`
}

type ListMultipartsInfo

type ListMultipartsInfo struct {
	// Together with upload-id-marker, this parameter specifies the multipart upload
	// after which listing should begin.
	KeyMarker string

	// Together with key-marker, specifies the multipart upload after which listing
	// should begin. If key-marker is not specified, the upload-id-marker parameter
	// is ignored.
	UploadIDMarker string

	// When a list is truncated, this element specifies the value that should be
	// used for the key-marker request parameter in a subsequent request.
	NextKeyMarker string

	// When a list is truncated, this element specifies the value that should be
	// used for the upload-id-marker request parameter in a subsequent request.
	NextUploadIDMarker string

	// Maximum number of multipart uploads that could have been included in the
	// response.
	MaxUploads int

	// Indicates whether the returned list of multipart uploads is truncated. A
	// value of true indicates that the list was truncated. The list can be truncated
	// if the number of multipart uploads exceeds the limit allowed or specified
	// by max uploads.
	IsTruncated bool

	// List of all pending uploads.
	Uploads []MultipartInfo

	// When a prefix is provided in the request, The result contains only keys
	// starting with the specified prefix.
	Prefix string

	// A character used to truncate the object prefixes.
	// NOTE: only supported delimiter is '/'.
	Delimiter string

	// CommonPrefixes contains all (if there are any) keys between Prefix and the
	// next occurrence of the string specified by delimiter.
	CommonPrefixes []string

	EncodingType string // Not supported yet.
}

ListMultipartsInfo - represnets bucket resources for incomplete multipart uploads.

func (ListMultipartsInfo) Lookup

func (lm ListMultipartsInfo) Lookup(uploadID string) bool

Lookup - returns if uploadID is valid

type ListObjectsInfo

type ListObjectsInfo struct {
	// Indicates whether the returned list objects response is truncated. A
	// value of true indicates that the list was truncated. The list can be truncated
	// if the number of objects exceeds the limit allowed or specified
	// by max keys.
	IsTruncated bool

	// When response is truncated (the IsTruncated element value in the response is true),
	// you can use the key name in this field as marker in the subsequent
	// request to get next set of objects.
	//
	// NOTE: AWS S3 returns NextMarker only if you have delimiter request parameter specified,
	NextMarker string

	// List of objects info for this request.
	Objects []ObjectInfo

	// List of prefixes for this request.
	Prefixes []string
}

ListObjectsInfo - container for list objects.

type ListObjectsV2Info

type ListObjectsV2Info struct {
	// Indicates whether the returned list objects response is truncated. A
	// value of true indicates that the list was truncated. The list can be truncated
	// if the number of objects exceeds the limit allowed or specified
	// by max keys.
	IsTruncated bool

	// When response is truncated (the IsTruncated element value in the response
	// is true), you can use the key name in this field as marker in the subsequent
	// request to get next set of objects.
	//
	// NOTE: This element is returned only if you have delimiter request parameter
	// specified.
	ContinuationToken     string
	NextContinuationToken string

	// List of objects info for this request.
	Objects []ObjectInfo

	// List of prefixes for this request.
	Prefixes []string
}

ListObjectsV2Info - container for list objects version 2.

type ListPartsInfo

type ListPartsInfo struct {
	// Name of the bucket.
	Bucket string

	// Name of the object.
	Object string

	// Upload ID identifying the multipart upload whose parts are being listed.
	UploadID string

	// Part number after which listing begins.
	PartNumberMarker int

	// When a list is truncated, this element specifies the last part in the list,
	// as well as the value to use for the part-number-marker request parameter
	// in a subsequent request.
	NextPartNumberMarker int

	// Maximum number of parts that were allowed in the response.
	MaxParts int

	// Indicates whether the returned list of parts is truncated.
	IsTruncated bool

	// List of all parts.
	Parts []objectPartInfo

	// Any metadata set during InitMultipartUpload, including encryption headers.
	Metadata map[string]string

	// ChecksumAlgorithm if set
	ChecksumAlgorithm string
}

ListPartsInfo - represents list of all parts.

type MultipartInfo

type MultipartInfo struct {
	Bucket    string
	Object    string
	UploadID  string
	Initiated time.Time
	MetaData  map[string]string
	// List of individual parts, maximum size of upto 10,000
	Parts []objectPartInfo
}

type ObjectInfo

type ObjectInfo struct {
	// Name of the bucket.
	Bucket string

	// Name of the object.
	Name string

	// Date and time when the object was last modified.
	ModTime time.Time

	// Total object size.
	Size int64

	// IsDir indicates if the object is prefix.
	IsDir bool

	// Hex encoded unique entity tag of the object.
	ETag string

	// Version ID of this object.
	VersionID string

	// IsLatest indicates if this is the latest current version
	// latest can be true for delete marker or a version.
	IsLatest bool

	// DeleteMarker indicates if the versionId corresponds
	// to a delete marker on an object.
	DeleteMarker bool

	// A standard MIME type describing the format of the object.
	ContentType string

	// Specifies what content encodings have been applied to the object and thus
	// what decoding mechanisms must be applied to obtain the object referenced
	// by the Content-Type header field.
	ContentEncoding string

	// Date and time at which the object is no longer able to be cached
	Expires time.Time

	// Date and time when the object was last accessed.
	AccTime time.Time

	//  The mod time of the successor object version if any
	SuccessorModTime time.Time
}

ObjectInfo - represents object metadata.

{
	Bucket = {string} "test"
	Name = {string} "default.exe"
	ModTime = {time.Time} 2022-03-18 10:54:43.308685163 +0800
	Size = {int64} 11604147
	IsDir = {bool} false
	ETag = {string} "a6b0b7ddb4630832ed47821af59aa125"
	VersionID = {string} ""
	IsLatest = {bool} false
	DeleteMarker = {bool} false
	ContentType = {string} "application/x-msdownload"
	ContentEncoding = {string} ""
	Expires = {time.Time} 0001-01-01 00:00:00 +0000
	Parts = {[]ObjectPartInfo} nil
	AccTime = {time.Time} 0001-01-01 00:00:00 +0000
	SuccessorModTime = {time.Time} 0001-01-01 00:00:00 +0000
}

type ObjectStoreSystemAPI added in v0.4.0

type ObjectStoreSystemAPI interface {
	StoreStats(ctx context.Context, bucketMetadataMap map[string]BucketMetadata) (DataUsageInfo, error)
	SetNewBucketNSLock(newBucketNSLock func(bucket string) lock.RWLocker)
	SetHasBucket(hasBucket func(ctx context.Context, bucket string) bool)
	StoreObject(ctx context.Context, bucket string, object string, reader io.ReadCloser, size int64, meta map[string]string, fileFolder bool) (ObjectInfo, error)
	GetObject(ctx context.Context, bucket string, object string) (ObjectInfo, io.ReadCloser, error)
	GetObjectInfo(ctx context.Context, bucket string, object string) (meta ObjectInfo, err error)
	DeleteObject(ctx context.Context, bucket string, object string) error
	CleanObjectsInBucket(ctx context.Context, bucket string) error
	GetAllObjectsInBucketInfo(ctx context.Context, bucket string) (bi BucketInfo, err error)
	ListObjects(ctx context.Context, bucket string, prefix string, marker string, delimiter string, maxKeys int) (loi ListObjectsInfo, err error)
	EmptyBucket(ctx context.Context, bucket string) (bool, error)
	ListObjectsV2(ctx context.Context, bucket string, prefix string, continuationToken string, delimiter string, maxKeys int, owner bool, startAfter string) (ListObjectsV2Info, error)
	NewMultipartUpload(ctx context.Context, bucket string, object string, meta map[string]string) (MultipartInfo, error)
	GetMultipartInfo(ctx context.Context, bucket string, object string, uploadID string) (MultipartInfo, error)
	PutObjectPart(ctx context.Context, bucket string, object string, uploadID string, partID int, reader io.ReadCloser, size int64, meta map[string]string) (pi objectPartInfo, err error)
	CompleteMultiPartUpload(ctx context.Context, bucket string, object string, uploadID string, parts []datatypes.CompletePart) (oi ObjectInfo, err error)
	AbortMultipartUpload(ctx context.Context, bucket string, object string, uploadID string) error
	ListObjectParts(ctx context.Context, bucket string, object string, uploadID string, partNumberMarker int, maxParts int) (result ListPartsInfo, err error)
	ListMultipartUploads(ctx context.Context, bucket string, prefix string, keyMarker string, uploadIDMarker string, delimiter string, maxUploads int) (result ListMultipartsInfo, err error)
}

ObjectStoreSystemAPI object store system API

func NewStorageSys

NewStorageSys new a storage sys

type TagSet

type TagSet struct {
	TagMap   map[string]string
	IsObject bool
}

TagSet represents list of unique tags.

type Tags

type Tags tagging

Tags is list of tags of XML request/response as per https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html#API_GetBucketTagging_RequestBody

Jump to

Keyboard shortcuts

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