layer

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadIDAttributeName         = "S3-Upload-Id"
	UploadPartNumberAttributeName = "S3-Upload-Part-Number"
	UploadKeyAttributeName        = "S3-Upload-Key"
	UploadPartKeyPrefix           = ".upload-"

	MaxSizeUploadsList  = 1000
	MaxSizePartsList    = 1000
	UploadMinPartNumber = 1
	UploadMaxPartNumber = 10000
)
View Source
const (
	VersionsDeleteMarkAttr = "S3-Versions-delete-mark"
	DelMarkFullObject      = "*"
)
View Source
const PathSeparator = string(os.PathSeparator)

PathSeparator is a path components separator string.

Variables

View Source
var ErrAccessDenied = stderrors.New("access denied")

ErrAccessDenied is returned from NeoFS in case of access violation.

Functions

func GetBoxData added in v0.17.0

func GetBoxData(ctx context.Context) (*accessbox.Box, error)

GetBoxData extracts accessbox.Box from context.

func IsAuthenticatedRequest added in v0.19.0

func IsAuthenticatedRequest(ctx context.Context) bool

IsAuthenticatedRequest check if access box exists in current request.

func IsSystemHeader added in v0.19.0

func IsSystemHeader(key string) bool

func NameFromString

func NameFromString(name string) (string, string)

NameFromString splits name into base file name and directory path.

Types

type AnonymousKey added in v0.18.0

type AnonymousKey struct {
	Key *keys.PrivateKey
}

AnonymousKey contains data for anonymous requests.

type BucketACL added in v0.17.0

type BucketACL struct {
	Info *data.BucketInfo
	EACL *eacl.Table
}

BucketACL extends BucketInfo by eacl.Table.

type BucketSettings added in v0.17.0

type BucketSettings struct {
	VersioningEnabled bool
}

BucketSettings stores settings such as versioning.

type CachesConfig added in v0.17.0

type CachesConfig struct {
	Objects     *cache.Config
	ObjectsList *cache.Config
	Names       *cache.Config
	Buckets     *cache.Config
	System      *cache.Config
}

CachesConfig contains params for caches.

func DefaultCachesConfigs added in v0.17.0

func DefaultCachesConfigs() *CachesConfig

DefaultCachesConfigs returns filled configs.

type Client

type Client interface {
	EphemeralKey() *keys.PublicKey

	PutBucketVersioning(ctx context.Context, p *PutVersioningParams) (*data.ObjectInfo, error)
	GetBucketVersioning(ctx context.Context, name string) (*BucketSettings, error)

	PutBucketCORS(ctx context.Context, p *PutCORSParams) error
	GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (*data.CORSConfiguration, error)
	DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) error

	ListBuckets(ctx context.Context) ([]*data.BucketInfo, error)
	GetBucketInfo(ctx context.Context, name string) (*data.BucketInfo, error)
	GetBucketACL(ctx context.Context, name string) (*BucketACL, error)
	PutBucketACL(ctx context.Context, p *PutBucketACLParams) error
	CreateBucket(ctx context.Context, p *CreateBucketParams) (*cid.ID, error)
	DeleteBucket(ctx context.Context, p *DeleteBucketParams) error

	GetObject(ctx context.Context, p *GetObjectParams) error
	GetObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.ObjectInfo, error)
	GetObjectTagging(ctx context.Context, p *data.ObjectInfo) (map[string]string, error)
	GetBucketTagging(ctx context.Context, bucket string) (map[string]string, error)

	PutObject(ctx context.Context, p *PutObjectParams) (*data.ObjectInfo, error)
	PutObjectTagging(ctx context.Context, p *PutTaggingParams) error
	PutBucketTagging(ctx context.Context, bucket string, tagSet map[string]string) error

	CopyObject(ctx context.Context, p *CopyObjectParams) (*data.ObjectInfo, error)

	ListObjectsV1(ctx context.Context, p *ListObjectsParamsV1) (*ListObjectsInfoV1, error)
	ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*ListObjectsInfoV2, error)
	ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error)

	DeleteObjects(ctx context.Context, bucket string, objects []*VersionedObject) ([]*VersionedObject, error)
	DeleteObjectTagging(ctx context.Context, p *data.ObjectInfo) error
	DeleteBucketTagging(ctx context.Context, bucket string) error

	CompleteMultipartUpload(ctx context.Context, p *CompleteMultipartParams) (*data.ObjectInfo, error)
	UploadPart(ctx context.Context, p *UploadPartParams) (*data.ObjectInfo, error)
	UploadPartCopy(ctx context.Context, p *UploadCopyParams) (*data.ObjectInfo, error)
	ListMultipartUploads(ctx context.Context, p *ListMultipartUploadsParams) (*ListMultipartUploadsInfo, error)
	AbortMultipartUpload(ctx context.Context, p *UploadInfoParams) error
	ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsInfo, error)
	GetUploadInitInfo(ctx context.Context, p *UploadInfoParams) (*data.ObjectInfo, error)

	PutBucketNotificationConfiguration(ctx context.Context, p *PutBucketNotificationConfigurationParams) error
	GetBucketNotificationConfiguration(ctx context.Context, bktInfo *data.BucketInfo) (*data.NotificationConfiguration, error)
}

Client provides S3 API client interface.

func NewLayer

func NewLayer(log *zap.Logger, neoFS NeoFS, config *Config) Client

NewLayer creates instance of layer. It checks credentials and establishes gRPC connection with node.

type CompleteMultipartParams added in v0.18.0

type CompleteMultipartParams struct {
	Info  *UploadInfoParams
	Parts []*CompletedPart
}

type CompletedPart added in v0.18.0

type CompletedPart struct {
	ETag       string
	PartNumber int
}

type Config added in v0.18.0

type Config struct {
	ChainAddress           string
	Caches                 *CachesConfig
	AnonKey                AnonymousKey
	Resolver               *resolver.BucketResolver
	NotificationController *notifications.Controller
}

type CopyObjectParams

type CopyObjectParams struct {
	SrcObject *data.ObjectInfo
	DstBucket string
	DstObject string
	SrcSize   int64
	Header    map[string]string
	Range     *RangeParams
}

CopyObjectParams stores object copy request parameters.

type CreateBucketParams added in v0.16.0

type CreateBucketParams struct {
	Name               string
	ACL                uint32
	Policy             *netmap.PlacementPolicy
	EACL               *eacl.Table
	SessionToken       *session.Token
	LocationConstraint string
}

CreateBucketParams stores bucket create request parameters.

type DeleteBucketParams added in v0.16.0

type DeleteBucketParams struct {
	Name string
}

DeleteBucketParams stores delete bucket request parameters.

type GetObjectParams

type GetObjectParams struct {
	Range      *RangeParams
	ObjectInfo *data.ObjectInfo
	Writer     io.Writer
	VersionID  string
}

GetObjectParams stores object get request parameters.

type HeadObjectParams added in v0.17.0

type HeadObjectParams struct {
	Bucket    string
	Object    string
	VersionID string
}

HeadObjectParams stores object head request parameters.

type ListMultipartUploadsInfo added in v0.18.0

type ListMultipartUploadsInfo struct {
	Prefixes           []string
	Uploads            []*UploadInfo
	IsTruncated        bool
	NextKeyMarker      string
	NextUploadIDMarker string
}

type ListMultipartUploadsParams added in v0.18.0

type ListMultipartUploadsParams struct {
	Bkt            *data.BucketInfo
	Delimiter      string
	EncodingType   string
	KeyMarker      string
	MaxUploads     int
	Prefix         string
	UploadIDMarker string
}

type ListObjectVersionsInfo added in v0.16.0

type ListObjectVersionsInfo struct {
	CommonPrefixes      []string
	IsTruncated         bool
	KeyMarker           string
	NextKeyMarker       string
	NextVersionIDMarker string
	Version             []*ObjectVersionInfo
	DeleteMarker        []*ObjectVersionInfo
	VersionIDMarker     string
}

ListObjectVersionsInfo stores info and list of objects' versions.

type ListObjectVersionsParams added in v0.16.0

type ListObjectVersionsParams struct {
	Bucket          string
	Delimiter       string
	KeyMarker       string
	MaxKeys         int
	Prefix          string
	VersionIDMarker string
	Encode          string
}

ListObjectVersionsParams stores list objects versions parameters.

type ListObjectsInfo

type ListObjectsInfo struct {
	Prefixes    []string
	Objects     []*data.ObjectInfo
	IsTruncated bool
}

ListObjectsInfo contains common fields of data for ListObjectsV1 and ListObjectsV2.

type ListObjectsInfoV1 added in v0.17.0

type ListObjectsInfoV1 struct {
	ListObjectsInfo
	NextMarker string
}

ListObjectsInfoV1 holds data which ListObjectsV1 returns.

type ListObjectsInfoV2 added in v0.17.0

type ListObjectsInfoV2 struct {
	ListObjectsInfo
	NextContinuationToken string
}

ListObjectsInfoV2 holds data which ListObjectsV2 returns.

type ListObjectsParamsCommon added in v0.17.0

type ListObjectsParamsCommon struct {
	Bucket    string
	Delimiter string
	Encode    string
	MaxKeys   int
	Prefix    string
}

ListObjectsParamsCommon contains common parameters for ListObjectsV1 and ListObjectsV2.

type ListObjectsParamsV1 added in v0.17.0

type ListObjectsParamsV1 struct {
	ListObjectsParamsCommon
	Marker string
}

ListObjectsParamsV1 contains params for ListObjectsV1.

type ListObjectsParamsV2 added in v0.17.0

type ListObjectsParamsV2 struct {
	ListObjectsParamsCommon
	ContinuationToken string
	StartAfter        string
	FetchOwner        bool
}

ListObjectsParamsV2 contains params for ListObjectsV2.

type ListPartsInfo added in v0.18.0

type ListPartsInfo struct {
	Parts                []*Part
	Owner                *owner.ID
	NextPartNumberMarker int
	IsTruncated          bool
}

type ListPartsParams added in v0.18.0

type ListPartsParams struct {
	Info             *UploadInfoParams
	MaxParts         int
	PartNumberMarker int
}

type NeoFS

type NeoFS interface {
	// CreateContainer creates and saves parameterized container in NeoFS.
	// Returns ID of the saved container.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the container to be created.
	CreateContainer(context.Context, PrmContainerCreate) (*cid.ID, error)

	// Container reads container from NeoFS by ID.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the container to be read.
	Container(context.Context, cid.ID) (*container.Container, error)

	// UserContainers reads list of the containers owned by specified user.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the containers to be listed.
	UserContainers(context.Context, owner.ID) ([]cid.ID, error)

	// SetContainerEACL saves eACL table of the container in NeoFS.
	//
	// Returns any error encountered which prevented the eACL to be saved.
	SetContainerEACL(context.Context, eacl.Table) error

	// ContainerEACL reads container eACL from NeoFS by container ID.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the eACL to be read.
	ContainerEACL(context.Context, cid.ID) (*eacl.Table, error)

	// DeleteContainer marks the container to be removed from NeoFS by ID.
	// Request is sent within session if the session token is specified.
	// Successful return does not guarantee the actual removal.
	//
	// Returns any error encountered which prevented the removal request to be sent.
	DeleteContainer(context.Context, cid.ID, *session.Token) error

	// SelectObjects perform object selection from the NeoFS container according
	// to specified parameters. Selects user objects only.
	//
	// Returns ErrAccessDenied on selection access violation.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the objects to be selected.
	SelectObjects(context.Context, PrmObjectSelect) ([]oid.ID, error)

	// ReadObject reads part of the object from the NeoFS container by identifier.
	// Exact part is returned according to the parameters:
	//   * with header only: empty payload (both in-mem and reader parts are nil);
	//   * with payload only: header is nil (zero range means full payload);
	//   * with header and payload: full in-mem object, payload reader is nil.
	//
	// WithHeader or WithPayload is true. Range length is positive if offset is positive.
	//
	// Payload reader should be closed if it is no longer needed.
	//
	// Returns ErrAccessDenied on read access violation.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the object header to be read.
	ReadObject(context.Context, PrmObjectRead) (*ObjectPart, error)

	// CreateObject creates and saves parameterized object in the NeoFS container.
	// Returns ID of the saved object.
	//
	// Creation time should be written into object (UTC).
	//
	// Returns ErrAccessDenied on write access violation.
	//
	// Returns exactly one non-nil value. Returns any error encountered which
	// prevented the container to be created.
	CreateObject(context.Context, PrmObjectCreate) (*oid.ID, error)

	// DeleteObject marks the object to be removed from the NeoFS container by identifier.
	// Successful return does not guarantee the actual removal.
	//
	// Returns ErrAccessDenied on remove access violation.
	//
	// Returns any error encountered which prevented the removal request to be sent.
	DeleteObject(context.Context, PrmObjectDelete) error
}

NeoFS represents virtual connection to NeoFS network.

type ObjectPart added in v0.19.0

type ObjectPart struct {
	// Object header with optional in-memory payload part.
	Head *object.Object

	// Object payload part encapsulated in io.Reader primitive.
	// Returns ErrAccessDenied on read access violation.
	Payload io.ReadCloser
}

ObjectPart represents partially read NeoFS object.

type ObjectVersionInfo added in v0.16.0

type ObjectVersionInfo struct {
	Object   *data.ObjectInfo
	IsLatest bool
}

ObjectVersionInfo stores info about objects versions.

type Part added in v0.18.0

type Part struct {
	ETag         string
	LastModified string
	PartNumber   int
	Size         int64
}

type PrmAuth added in v0.19.0

type PrmAuth struct {
	// Bearer token to be used for the operation. Overlaps PrivateKey. Optional.
	BearerToken *token.BearerToken

	// Private key used for the operation if BearerToken is missing (in this case non-nil).
	PrivateKey *ecdsa.PrivateKey
}

PrmAuth groups authentication parameters for the NeoFS operation.

type PrmContainerCreate added in v0.19.0

type PrmContainerCreate struct {
	// NeoFS identifier of the container creator.
	Creator owner.ID

	// Container placement policy.
	Policy netmap.PlacementPolicy

	// Name for the container.
	Name string

	// Token of the container's creation session. Nil means session absence.
	SessionToken *session.Token

	// Time when container is created.
	Time time.Time

	// Basic ACL of the container.
	BasicACL acl.BasicACL

	// Attribute for LocationConstraint parameter (optional).
	LocationConstraintAttribute *container.Attribute
}

PrmContainerCreate groups parameters of NeoFS.CreateContainer operation.

type PrmObjectCreate added in v0.19.0

type PrmObjectCreate struct {
	// Authentication parameters.
	PrmAuth

	// Container to store the object.
	Container cid.ID

	// NeoFS identifier of the object creator.
	Creator owner.ID

	// Key-value object attributes.
	Attributes [][2]string

	// Full payload size (optional).
	PayloadSize uint64

	// Associated filename (optional).
	Filename string

	// Object payload encapsulated in io.Reader primitive.
	Payload io.Reader
}

PrmObjectCreate groups parameters of NeoFS.CreateObject operation.

type PrmObjectDelete added in v0.19.0

type PrmObjectDelete struct {
	// Authentication parameters.
	PrmAuth

	// Container to delete the object from.
	Container cid.ID

	// Identifier of the removed object.
	Object oid.ID
}

PrmObjectDelete groups parameters of NeoFS.DeleteObject operation.

type PrmObjectRead added in v0.19.0

type PrmObjectRead struct {
	// Authentication parameters.
	PrmAuth

	// Container to read the object header from.
	Container cid.ID

	// ID of the object for which to read the header.
	Object oid.ID

	// Flag to read object header.
	WithHeader bool

	// Flag to read object payload. False overlaps payload range.
	WithPayload bool

	// Offset-length range of the object payload to be read.
	PayloadRange [2]uint64
}

PrmObjectRead groups parameters of NeoFS.ReadObject operation.

type PrmObjectSelect added in v0.19.0

type PrmObjectSelect struct {
	// Authentication parameters.
	PrmAuth

	// Container to select the objects from.
	Container cid.ID

	// Key-value object attribute which should exactly be
	// presented in selected objects. Optional, empty key means any.
	ExactAttribute [2]string

	// File prefix of the selected objects. Optional, empty value means any.
	FilePrefix string
}

PrmObjectSelect groups parameters of NeoFS.SelectObjects operation.

type PutBucketACLParams added in v0.17.0

type PutBucketACLParams struct {
	Name string
	EACL *eacl.Table
}

PutBucketACLParams stores put bucket acl request parameters.

type PutBucketNotificationConfigurationParams added in v0.19.0

type PutBucketNotificationConfigurationParams struct {
	BktInfo *data.BucketInfo
	Reader  io.Reader
}

type PutCORSParams added in v0.18.0

type PutCORSParams struct {
	BktInfo *data.BucketInfo
	Reader  io.Reader
}

PutCORSParams stores PutCORS request parameters.

type PutObjectParams

type PutObjectParams struct {
	Bucket string
	Object string
	Size   int64
	Reader io.Reader
	Header map[string]string
}

PutObjectParams stores object put request parameters.

type PutSystemObjectParams added in v0.18.0

type PutSystemObjectParams struct {
	BktInfo  *data.BucketInfo
	ObjName  string
	Metadata map[string]string
	Prefix   string
	Reader   io.Reader
}

PutSystemObjectParams stores putSystemObject parameters.

type PutTaggingParams added in v0.17.0

type PutTaggingParams struct {
	ObjectInfo *data.ObjectInfo
	TagSet     map[string]string
}

PutTaggingParams stores tag set params.

type PutVersioningParams added in v0.17.0

type PutVersioningParams struct {
	Bucket   string
	Settings *BucketSettings
}

PutVersioningParams stores object copy request parameters.

type RangeParams added in v0.16.0

type RangeParams struct {
	Start uint64
	End   uint64
}

RangeParams stores range header request parameters.

type UploadCopyParams added in v0.18.0

type UploadCopyParams struct {
	Info       *UploadInfoParams
	SrcObjInfo *data.ObjectInfo
	PartNumber int
	Range      *RangeParams
}

type UploadInfo added in v0.18.0

type UploadInfo struct {
	IsDir    bool
	Key      string
	UploadID string
	Owner    *owner.ID
	Created  time.Time
}

type UploadInfoParams added in v0.18.0

type UploadInfoParams struct {
	UploadID string
	Bkt      *data.BucketInfo
	Key      string
}

type UploadPartParams added in v0.18.0

type UploadPartParams struct {
	Info       *UploadInfoParams
	PartNumber int
	Size       int64
	Reader     io.Reader
	Header     map[string]string
}

type VersionOption added in v0.19.0

type VersionOption func(*versionOptions)

func FromUnversioned added in v0.19.0

func FromUnversioned() VersionOption

type VersionedObject added in v0.17.0

type VersionedObject struct {
	Name              string
	VersionID         string
	DeleteMarkVersion string
	Error             error
}

VersionedObject stores info about objects to delete.

func (*VersionedObject) String added in v0.17.0

func (t *VersionedObject) String() string

Jump to

Keyboard shortcuts

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