2022-04-22 07:18:21 +00:00
|
|
|
package layer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
2022-05-12 01:50:52 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-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-05-17 13:52:51 +00:00
|
|
|
PutSettingsNode(context.Context, *cid.ID, *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-05-12 01:48:17 +00:00
|
|
|
// If node is not found returns ErrNodeNotFound error.
|
2022-05-17 13:52:51 +00:00
|
|
|
GetSettingsNode(context.Context, *cid.ID) (*data.BucketSettings, error)
|
2022-05-12 01:50:52 +00:00
|
|
|
|
2022-05-17 13:52:51 +00:00
|
|
|
GetNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID) (*oid.ID, error)
|
|
|
|
// PutNotificationConfigurationNode puts a node to a system tree
|
|
|
|
// and returns objectID of a previous notif config which must be deleted in NeoFS
|
|
|
|
PutNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error)
|
2022-05-12 02:33:03 +00:00
|
|
|
|
2022-05-17 13:52:51 +00:00
|
|
|
GetBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error)
|
|
|
|
// PutBucketCORS puts a node to a system tree and returns objectID of a previous cors config which must be deleted in NeoFS
|
|
|
|
PutBucketCORS(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error)
|
|
|
|
// DeleteBucketCORS removes a node from a system tree and returns objID which must be deleted in NeoFS
|
|
|
|
DeleteBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error)
|
2022-05-17 14:56:05 +00:00
|
|
|
|
|
|
|
GetVersions(ctx context.Context, cnrID *cid.ID, objectName string) ([]*NodeVersion, error)
|
|
|
|
|
2022-05-17 14:56:05 +00:00
|
|
|
GetLatestVersion(ctx context.Context, cnrID *cid.ID, objectName string) (*NodeVersion, error)
|
|
|
|
|
|
|
|
GetUnversioned(ctx context.Context, cnrID *cid.ID, objectName string) (*NodeVersion, error)
|
2022-05-17 14:56:05 +00:00
|
|
|
|
|
|
|
AddVersion(ctx context.Context, cnrID *cid.ID, objectName string, newVersion *NodeVersion) error
|
|
|
|
|
|
|
|
RemoveVersion(ctx context.Context, cnrID *cid.ID, nodeID uint64) error
|
|
|
|
|
|
|
|
AddSystemVersion(ctx context.Context, cnrID *cid.ID, objectName string, newVersion *BaseNodeVersion) error
|
|
|
|
|
2022-05-17 14:56:05 +00:00
|
|
|
GetSystemVersion(ctx context.Context, cnrID *cid.ID, objectName string) (*BaseNodeVersion, error)
|
|
|
|
|
2022-05-17 14:56:05 +00:00
|
|
|
RemoveSystemVersion(ctx context.Context, cnrID *cid.ID, nodeID uint64) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type NodeVersion struct {
|
|
|
|
BaseNodeVersion
|
|
|
|
IsDeleteMarker bool
|
|
|
|
IsUnversioned bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type BaseNodeVersion struct {
|
|
|
|
ID uint64
|
|
|
|
OID *oid.ID
|
2022-04-22 07:18:21 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 01:48:17 +00:00
|
|
|
// ErrNodeNotFound is returned from Tree service in case of not found error.
|
|
|
|
var ErrNodeNotFound = errors.New("not found")
|