2022-04-22 07:18:21 +00:00
|
|
|
package layer
|
|
|
|
|
|
|
|
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
|
|
|
// GetNotificationConfigurationNode gets an object id that corresponds to object with bucket CORS.
|
|
|
|
//
|
|
|
|
// If tree node is not found returns ErrNodeNotFound error.
|
2022-09-13 09:44:18 +00:00
|
|
|
GetNotificationConfigurationNode(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, error)
|
2022-06-27 09:33:36 +00:00
|
|
|
|
2022-05-17 13:52:51 +00:00
|
|
|
// PutNotificationConfigurationNode puts a node to a system tree
|
2022-12-20 08:38:58 +00:00
|
|
|
// and returns objectID of a previous notif config which must be deleted in FrostFS.
|
2022-06-27 09:33:36 +00:00
|
|
|
//
|
|
|
|
// If object id to remove is not found returns ErrNoNodeToRemove error.
|
2022-09-13 09:44:18 +00:00
|
|
|
PutNotificationConfigurationNode(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) (oid.ID, error)
|
2022-05-12 02:33:03 +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.
|
2022-09-13 09:44:18 +00:00
|
|
|
GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, 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
|
|
|
//
|
|
|
|
// If object id to remove is not found returns ErrNoNodeToRemove error.
|
2022-09-13 09:44:18 +00:00
|
|
|
PutBucketCORS(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) (oid.ID, 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
|
|
|
//
|
|
|
|
// If object id to remove is not found returns ErrNoNodeToRemove error.
|
2022-09-13 09:44:18 +00:00
|
|
|
DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, 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)
|
|
|
|
GetLatestVersionsByPrefix(ctx context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.NodeVersion, error)
|
2023-10-16 06:27:21 +00:00
|
|
|
GetLatestVersionsByPrefixStream(ctx context.Context, bktInfo *data.BucketInfo, prefix string) (data.VersionsStream, error)
|
2022-09-13 09:44:18 +00:00
|
|
|
GetAllVersionsByPrefix(ctx context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.NodeVersion, error)
|
|
|
|
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
|
2022-12-20 08:38:58 +00:00
|
|
|
// and returns objectID of a previous part which must be deleted in FrostFS.
|
2022-06-27 09:33:36 +00:00
|
|
|
//
|
|
|
|
// If object id to remove is not found returns ErrNoNodeToRemove error.
|
2022-09-13 09:44:18 +00:00
|
|
|
AddPart(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete oid.ID, err error)
|
|
|
|
GetParts(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64) ([]*data.PartInfo, 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")
|
|
|
|
)
|