2024-09-27 08:13:13 +00:00
|
|
|
package tree
|
2022-04-22 07:18:21 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
2023-03-07 14:38:08 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
2022-04-22 07:18:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TreeService provide interface to interact with tree service using s3 data models.
|
|
|
|
type TreeService interface {
|
|
|
|
// PutSettingsNode update or create new settings node in tree service.
|
2022-09-13 09:44:18 +00:00
|
|
|
PutSettingsNode(ctx context.Context, bktInfo *data.BucketInfo, settings *data.BucketSettings) error
|
2022-04-22 07:18:21 +00:00
|
|
|
|
|
|
|
// GetSettingsNode retrieves the settings node from the tree service and form data.BucketSettings.
|
|
|
|
//
|
2022-06-27 09:33:36 +00:00
|
|
|
// If tree node is not found returns ErrNodeNotFound error.
|
2022-09-13 09:44:18 +00:00
|
|
|
GetSettingsNode(ctx context.Context, bktInfo *data.BucketInfo) (*data.BucketSettings, error)
|
2022-05-12 01:50:52 +00:00
|
|
|
|
2022-06-27 09:33:36 +00:00
|
|
|
// GetBucketCORS gets an object id that corresponds to object with bucket CORS.
|
|
|
|
//
|
|
|
|
// If object id is not found returns ErrNodeNotFound error.
|
2024-07-15 15:35:54 +00:00
|
|
|
GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.Address, error)
|
2022-06-27 09:33:36 +00:00
|
|
|
|
2022-12-20 08:38:58 +00:00
|
|
|
// PutBucketCORS puts a node to a system tree and returns objectID of a previous cors config which must be deleted in FrostFS.
|
2022-06-27 09:33:36 +00:00
|
|
|
//
|
2024-07-17 09:44:38 +00:00
|
|
|
// If object ids to remove is not found returns ErrNoNodeToRemove error.
|
|
|
|
PutBucketCORS(ctx context.Context, bktInfo *data.BucketInfo, addr oid.Address) ([]oid.Address, error)
|
2022-06-27 09:33:36 +00:00
|
|
|
|
2022-12-20 08:38:58 +00:00
|
|
|
// DeleteBucketCORS removes a node from a system tree and returns objID which must be deleted in FrostFS.
|
2022-06-27 09:33:36 +00:00
|
|
|
//
|
2024-07-17 09:44:38 +00:00
|
|
|
// If object ids to remove is not found returns ErrNoNodeToRemove error.
|
|
|
|
DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) ([]oid.Address, error)
|
2022-05-17 14:56:05 +00:00
|
|
|
|
2022-09-13 09:44:18 +00:00
|
|
|
GetObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) (map[string]string, error)
|
|
|
|
PutObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion, tagSet map[string]string) error
|
|
|
|
DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error
|
2022-05-24 06:58:33 +00:00
|
|
|
|
2022-09-13 09:44:18 +00:00
|
|
|
GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error)
|
|
|
|
PutBucketTagging(ctx context.Context, bktInfo *data.BucketInfo, tagSet map[string]string) error
|
|
|
|
DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error
|
2022-05-25 01:58:25 +00:00
|
|
|
|
2022-09-13 09:44:18 +00:00
|
|
|
GetVersions(ctx context.Context, bktInfo *data.BucketInfo, objectName string) ([]*data.NodeVersion, error)
|
|
|
|
GetLatestVersion(ctx context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)
|
2024-01-20 22:13:35 +00:00
|
|
|
InitVersionsByPrefixStream(ctx context.Context, bktInfo *data.BucketInfo, prefix string, latestOnly bool) (data.VersionsStream, error)
|
2022-09-13 09:44:18 +00:00
|
|
|
GetUnversioned(ctx context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)
|
|
|
|
AddVersion(ctx context.Context, bktInfo *data.BucketInfo, newVersion *data.NodeVersion) (uint64, error)
|
|
|
|
RemoveVersion(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64) error
|
2022-05-17 14:56:05 +00:00
|
|
|
|
2022-09-13 09:44:18 +00:00
|
|
|
PutLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64, lock *data.LockInfo) error
|
|
|
|
GetLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64) (*data.LockInfo, error)
|
2022-05-23 14:34:13 +00:00
|
|
|
|
2022-09-13 09:44:18 +00:00
|
|
|
CreateMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, info *data.MultipartInfo) error
|
2023-12-04 06:42:25 +00:00
|
|
|
DeleteMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, info *data.MultipartInfo) error
|
2022-09-13 09:44:18 +00:00
|
|
|
GetMultipartUploadsByPrefix(ctx context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.MultipartInfo, error)
|
|
|
|
GetMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, objectName, uploadID string) (*data.MultipartInfo, error)
|
2022-05-24 11:30:37 +00:00
|
|
|
|
|
|
|
// AddPart puts a node to a system tree as a child of appropriate multipart upload
|
2024-07-18 13:40:55 +00:00
|
|
|
// and returns objectIDs of a previous part/s which must be deleted in FrostFS.
|
2022-06-27 09:33:36 +00:00
|
|
|
//
|
2024-07-18 13:40:55 +00:00
|
|
|
// If object ids to remove is not found returns ErrNoNodeToRemove error.
|
|
|
|
AddPart(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64, info *data.PartInfo) (oldObjIDsToDelete []oid.ID, err error)
|
|
|
|
GetParts(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64) ([]*data.PartInfoExtended, error)
|
2022-05-31 14:25:47 +00:00
|
|
|
|
2024-08-12 11:22:56 +00:00
|
|
|
PutBucketLifecycleConfiguration(ctx context.Context, bktInfo *data.BucketInfo, addr oid.Address) ([]oid.Address, error)
|
|
|
|
GetBucketLifecycleConfiguration(ctx context.Context, bktInfo *data.BucketInfo) (oid.Address, error)
|
|
|
|
DeleteBucketLifecycleConfiguration(ctx context.Context, bktInfo *data.BucketInfo) ([]oid.Address, error)
|
|
|
|
|
2022-05-31 14:25:47 +00:00
|
|
|
// Compound methods for optimizations
|
|
|
|
|
|
|
|
// GetObjectTaggingAndLock unifies GetObjectTagging and GetLock methods in single tree service invocation.
|
2022-09-13 09:44:18 +00:00
|
|
|
GetObjectTaggingAndLock(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error)
|
2022-05-17 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 09:33:36 +00:00
|
|
|
var (
|
|
|
|
// ErrNodeNotFound is returned from Tree service in case of not found error.
|
|
|
|
ErrNodeNotFound = errors.New("not found")
|
|
|
|
|
2022-09-13 10:35:30 +00:00
|
|
|
// ErrNodeAccessDenied is returned from Tree service in case of access denied error.
|
|
|
|
ErrNodeAccessDenied = errors.New("access denied")
|
|
|
|
|
2022-06-27 09:33:36 +00:00
|
|
|
// ErrNoNodeToRemove is returned from Tree service in case of the lack of node with OID to remove.
|
|
|
|
ErrNoNodeToRemove = errors.New("no node to remove")
|
|
|
|
)
|