handler

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPolicy is a default policy of placing containers in NeoFS if it's not set at the request.
	DefaultPolicy = "REP 3"
	// DefaultCopiesNumber is a default number of object copies that is enough to consider put successful if it's not set in config.
	DefaultCopiesNumber uint32 = 0
)
View Source
const (
	EventObjectCreated                                = "s3:ObjectCreated:*"
	EventObjectCreatedPut                             = "s3:ObjectCreated:Put"
	EventObjectCreatedPost                            = "s3:ObjectCreated:Post"
	EventObjectCreatedCopy                            = "s3:ObjectCreated:Copy"
	EventReducedRedundancyLostObject                  = "s3:ReducedRedundancyLostObject"
	EventObjectCreatedCompleteMultipartUpload         = "s3:ObjectCreated:CompleteMultipartUpload"
	EventObjectRemoved                                = "s3:ObjectRemoved:*"
	EventObjectRemovedDelete                          = "s3:ObjectRemoved:Delete"
	EventObjectRemovedDeleteMarkerCreated             = "s3:ObjectRemoved:DeleteMarkerCreated"
	EventObjectRestore                                = "s3:ObjectRestore:*"
	EventObjectRestorePost                            = "s3:ObjectRestore:Post"
	EventObjectRestoreCompleted                       = "s3:ObjectRestore:Completed"
	EventReplication                                  = "s3:Replication:*"
	EventReplicationOperationFailedReplication        = "s3:Replication:OperationFailedReplication"
	EventReplicationOperationNotTracked               = "s3:Replication:OperationNotTracked"
	EventReplicationOperationMissedThreshold          = "s3:Replication:OperationMissedThreshold"
	EventReplicationOperationReplicatedAfterThreshold = "s3:Replication:OperationReplicatedAfterThreshold"
	EventObjectRestoreDelete                          = "s3:ObjectRestore:Delete"
	EventLifecycleTransition                          = "s3:LifecycleTransition"
	EventIntelligentTiering                           = "s3:IntelligentTiering"
	EventObjectACLPut                                 = "s3:ObjectAcl:Put"
	EventLifecycleExpiration                          = "s3:LifecycleExpiration:*"
	EventLifecycleExpirationDelete                    = "s3:LifecycleExpiration:Delete"
	EventLifecycleExpirationDeleteMarkerCreated       = "s3:LifecycleExpiration:DeleteMarkerCreated"
	EventObjectTagging                                = "s3:ObjectTagging:*"
	EventObjectTaggingPut                             = "s3:ObjectTagging:Put"
	EventObjectTaggingDelete                          = "s3:ObjectTagging:Delete"
)
View Source
const (
	// DefaultMaxAge is a default value of Access-Control-Max-Age if this value is not set in a rule.
	DefaultMaxAge = 600
)

Variables

This section is empty.

Functions

func New

func New(log *zap.Logger, obj layer.Client, notificator Notificator, cfg *Config) (api.Handler, error)

New creates new api.Handler using given logger and client.

Types

type AccessControlPolicy added in v0.17.0

type AccessControlPolicy struct {
	XMLName           xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ AccessControlPolicy" json:"-"`
	Owner             Owner
	AccessControlList []*Grant `xml:"AccessControlList>Grant"`
}

AccessControlPolicy contains ACL.

type Bucket

type Bucket struct {
	Name         string
	CreationDate string // time string of format "2006-01-02T15:04:05.000Z"
}

Bucket container for bucket metadata.

type Checksum added in v0.22.0

type Checksum struct {
	ChecksumSHA256 string `xml:"ChecksumSHA256,omitempty"`
}

type CommonPrefix

type CommonPrefix struct {
	Prefix string
}

CommonPrefix container for prefix response in ListObjects's response.

type CompleteMultipartUpload added in v0.18.0

type CompleteMultipartUpload struct {
	XMLName xml.Name               `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUpload"`
	Parts   []*layer.CompletedPart `xml:"Part"`
}

type CompleteMultipartUploadResponse added in v0.18.0

type CompleteMultipartUploadResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUploadResult" json:"-"`
	Bucket  string   `xml:"Bucket"`
	Key     string   `xml:"Key"`
	ETag    string   `xml:"ETag"`
}

type Config added in v0.17.0

type Config struct {
	Policy                  PlacementPolicy
	PlacementPolicyProvider PlacementPolicyProvider
	DefaultMaxAge           int
	NotificatorEnabled      bool
	CopiesNumber            uint32
	MaxDeletePerRequest     int
}

Config contains data which handler needs to keep.

type CopyObjectResponse

type CopyObjectResponse struct {
	XMLName      xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult" json:"-"`
	LastModified string   // time string of format "2006-01-02T15:04:05.000Z"
	ETag         string   // md5sum of the copied object.
}

CopyObjectResponse container returns ETag and LastModified of the successfully copied object.

type DeleteError

type DeleteError struct {
	Code      string
	Message   string
	Key       string
	VersionID string `xml:"versionId,omitempty"`
}

DeleteError structure.

type DeleteMarkerEntry added in v0.16.0

type DeleteMarkerEntry struct {
	IsLatest     bool   `xml:"IsLatest"`
	Key          string `xml:"Key"`
	LastModified string `xml:"LastModified"`
	Owner        Owner  `xml:"Owner"`
	VersionID    string `xml:"VersionId"`
}

DeleteMarkerEntry container for deleted object's version in the response of ListBucketObjectVersionsHandler.

type DeleteObjectsRequest

type DeleteObjectsRequest struct {
	// Element to enable quiet mode for the request
	Quiet bool
	// List of objects to be deleted
	Objects []ObjectIdentifier `xml:"Object"`
}

DeleteObjectsRequest -- xml carrying the object key names which should be deleted.

type DeleteObjectsResponse

type DeleteObjectsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ DeleteResult" json:"-"`

	// Collection of all deleted objects
	DeletedObjects []DeletedObject `xml:"Deleted,omitempty"`

	// Collection of errors deleting certain objects.
	Errors []DeleteError `xml:"Error,omitempty"`
}

DeleteObjectsResponse container for multiple object deletes.

type DeletedObject added in v0.17.0

type DeletedObject struct {
	ObjectIdentifier
	DeleteMarker          bool   `xml:"DeleteMarker,omitempty"`
	DeleteMarkerVersionID string `xml:"DeleteMarkerVersionId,omitempty"`
}

DeletedObject carries the key name for the object to delete.

type GetObjectAttributesArgs added in v0.21.0

type GetObjectAttributesArgs struct {
	MaxParts         int
	PartNumberMarker int
	Attributes       []string
	VersionID        string
	Conditional      *conditionalArgs
}

type GetObjectAttributesResponse added in v0.21.0

type GetObjectAttributesResponse struct {
	ETag         string       `xml:"ETag,omitempty"`
	Checksum     *Checksum    `xml:"Checksum,omitempty"`
	ObjectSize   int64        `xml:"ObjectSize,omitempty"`
	StorageClass string       `xml:"StorageClass,omitempty"`
	ObjectParts  *ObjectParts `xml:"ObjectParts,omitempty"`
}

type Grant added in v0.17.0

type Grant struct {
	Grantee    *Grantee
	Permission amazonS3Permission
}

Grant is container for Grantee data.

type Grantee added in v0.17.0

type Grantee struct {
	// Screen name of the grantee.
	// Optional.
	DisplayName string
	// Email address of the grantee.
	// Optional.
	EmailAddress string
	// The canonical user ID of the grantee.
	// Optional.
	ID string
	// Type of grantee.
	// Required.
	Type granteeType
	// URI of the grantee group.
	// Optional.
	URI string
}

Grantee represents container (not NeoFS) for the person being granted permissions specified in https://docs.aws.amazon.com/AmazonS3/latest/API/API_Grantee.html.

func NewGrantee added in v0.17.0

func NewGrantee(t granteeType) *Grantee

NewGrantee initializes new Grantee with specified granteeType.

func (Grantee) MarshalXML added in v0.27.0

func (x Grantee) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML provides xml.Marshaler for Grantee.

XML scheme of Grantee is described in Amazon S3 docs https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html.

MarshalXML overrides default encoding of Grantee layout because currently xml.Marshal doesn't provide convenient approach to work with prefixes in XML namespaces. According to docs, Grantee.Type is an attribute from the namespace with 'xsi' prefix.

Here we use workaround proposed in corresponding Go issue https://github.com/golang/go/issues/9519#issuecomment-252196382.

func (*Grantee) UnmarshalXML added in v0.27.0

func (x *Grantee) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML MarshalXML provides xml.Unmarshaler for Grantee.

See MarshalXML for details.

type InitiateMultipartUploadResponse added in v0.18.0

type InitiateMultipartUploadResponse struct {
	XMLName  xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ InitiateMultipartUploadResult" json:"-"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadID string   `xml:"UploadId"`
}

type Initiator added in v0.18.0

type Initiator struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

type ListBucketsResponse

type ListBucketsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"`

	Owner Owner

	// Container for one or more buckets.
	Buckets struct {
		Buckets []Bucket `xml:"Bucket"`
	} // Buckets are nested
}

ListBucketsResponse -- format for list buckets response.

type ListMultipartUploadsResponse added in v0.18.0

type ListMultipartUploadsResponse struct {
	XMLName            xml.Name          `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListMultipartUploadsResult" json:"-"`
	Bucket             string            `xml:"Bucket"`
	CommonPrefixes     []CommonPrefix    `xml:"CommonPrefixes"`
	Delimiter          string            `xml:"Delimiter,omitempty"`
	EncodingType       string            `xml:"EncodingType,omitempty"`
	IsTruncated        bool              `xml:"IsTruncated"`
	KeyMarker          string            `xml:"KeyMarker"`
	MaxUploads         int               `xml:"MaxUploads"`
	NextKeyMarker      string            `xml:"NextKeyMarker,omitempty"`
	NextUploadIDMarker string            `xml:"NextUploadIdMarker,omitempty"`
	Prefix             string            `xml:"Prefix"`
	Uploads            []MultipartUpload `xml:"Upload"`
	UploadIDMarker     string            `xml:"UploadIdMarker,omitempty"`
}

type ListObjectsV1Response added in v0.17.0

type ListObjectsV1Response struct {
	XMLName        xml.Name       `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
	CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
	Contents       []Object       `xml:"Contents"`
	Delimiter      string         `xml:"Delimiter,omitempty"`
	EncodingType   string         `xml:"EncodingType,omitempty"`
	IsTruncated    bool           `xml:"IsTruncated"`
	Marker         string         `xml:"Marker"`
	MaxKeys        int            `xml:"MaxKeys"`
	Name           string         `xml:"Name"`
	NextMarker     string         `xml:"NextMarker,omitempty"`
	Prefix         string         `xml:"Prefix"`
}

ListObjectsV1Response -- format for ListObjectsV1 response.

type ListObjectsV2Response

type ListObjectsV2Response struct {
	XMLName               xml.Name       `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
	CommonPrefixes        []CommonPrefix `xml:"CommonPrefixes"`
	Contents              []Object       `xml:"Contents"`
	ContinuationToken     string         `xml:"ContinuationToken,omitempty"`
	Delimiter             string         `xml:"Delimiter,omitempty"`
	EncodingType          string         `xml:"EncodingType,omitempty"`
	IsTruncated           bool           `xml:"IsTruncated"`
	KeyCount              int            `xml:"KeyCount"`
	MaxKeys               int            `xml:"MaxKeys"`
	Name                  string         `xml:"Name"`
	NextContinuationToken string         `xml:"NextContinuationToken,omitempty"`
	Prefix                string         `xml:"Prefix"`
	StartAfter            string         `xml:"StartAfter,omitempty"`
}

ListObjectsV2Response -- format for ListObjectsV2 response.

type ListObjectsVersionsResponse added in v0.16.0

type ListObjectsVersionsResponse struct {
	XMLName             xml.Name                `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListVersionsResult" json:"-"`
	EncodingType        string                  `xml:"EncodingType,omitempty"`
	Name                string                  `xml:"Name"`
	IsTruncated         bool                    `xml:"IsTruncated"`
	KeyMarker           string                  `xml:"KeyMarker"`
	NextKeyMarker       string                  `xml:"NextKeyMarker,omitempty"`
	NextVersionIDMarker string                  `xml:"NextVersionIdMarker,omitempty"`
	VersionIDMarker     string                  `xml:"VersionIdMarker"`
	DeleteMarker        []DeleteMarkerEntry     `xml:"DeleteMarker"`
	Version             []ObjectVersionResponse `xml:"Version"`
	CommonPrefixes      []CommonPrefix          `xml:"CommonPrefixes"`
}

ListObjectsVersionsResponse is a response of ListBucketObjectVersionsHandler.

type ListPartsResponse added in v0.18.0

type ListPartsResponse struct {
	XMLName              xml.Name      `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListPartsResult" json:"-"`
	Bucket               string        `xml:"Bucket"`
	Initiator            Initiator     `xml:"Initiator"`
	IsTruncated          bool          `xml:"IsTruncated"`
	Key                  string        `xml:"Key"`
	MaxParts             int           `xml:"MaxParts,omitempty"`
	NextPartNumberMarker int           `xml:"NextPartNumberMarker,omitempty"`
	Owner                Owner         `xml:"Owner"`
	Parts                []*layer.Part `xml:"Part"`
	PartNumberMarker     int           `xml:"PartNumberMarker,omitempty"`
	StorageClass         string        `xml:"StorageClass,omitempty"`
	UploadID             string        `xml:"UploadId"`
}

type LocationResponse

type LocationResponse struct {
	XMLName  xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LocationConstraint" json:"-"`
	Location string   `xml:",chardata"`
}

LocationResponse -- format for location response.

type MultipartUpload added in v0.18.0

type MultipartUpload struct {
	Initiated    string    `xml:"Initiated"`
	Initiator    Initiator `xml:"Initiator"`
	Key          string    `xml:"Key"`
	Owner        Owner     `xml:"Owner"`
	StorageClass string    `xml:"StorageClass,omitempty"`
	UploadID     string    `xml:"UploadId"`
}

type NotificationConfiguration added in v0.19.0

type NotificationConfiguration struct {
	XMLName                   xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ NotificationConfiguation"`
	NotificationConfiguration data.NotificationConfiguration
}

type Notificator added in v0.21.0

type Notificator interface {
	SendNotifications(topics map[string]string, p *SendNotificationParams) error
	SendTestNotification(topic, bucketName, requestID, HostID string, now time.Time) error
}

type Object

type Object struct {
	Key          string
	LastModified string // time string of format "2006-01-02T15:04:05.000Z"
	ETag         string `xml:"ETag,omitempty"`
	Size         int64

	// Owner of the object.
	Owner *Owner `xml:"Owner,omitempty"`

	// Class of storage used to store the object.
	StorageClass string `xml:"StorageClass,omitempty"`
}

Object container for object metadata.

type ObjectIdentifier

type ObjectIdentifier struct {
	ObjectName string `xml:"Key"`
	VersionID  string `xml:"VersionId,omitempty"`
}

ObjectIdentifier carries the key name for the object to delete.

type ObjectParts added in v0.21.0

type ObjectParts struct {
	IsTruncated          bool   `xml:"IsTruncated,omitempty"`
	MaxParts             int    `xml:"MaxParts,omitempty"`
	NextPartNumberMarker int    `xml:"NextPartNumberMarker,omitempty"`
	PartNumberMarker     int    `xml:"PartNumberMarker,omitempty"`
	Parts                []Part `xml:"Part,omitempty"`
	PartsCount           int    `xml:"PartsCount,omitempty"`
}

type ObjectVersionResponse added in v0.16.0

type ObjectVersionResponse struct {
	ETag         string `xml:"ETag"`
	IsLatest     bool   `xml:"IsLatest"`
	Key          string `xml:"Key"`
	LastModified string `xml:"LastModified"`
	Owner        Owner  `xml:"Owner"`
	Size         int64  `xml:"Size"`
	StorageClass string `xml:"StorageClass,omitempty"` // is empty!!
	VersionID    string `xml:"VersionId"`
}

ObjectVersionResponse container for object version in the response of ListBucketObjectVersionsHandler.

type Owner

type Owner struct {
	ID          string
	DisplayName string
}

Owner -- bucket owner/principal.

type Part added in v0.21.0

type Part struct {
	ChecksumSHA256 string `xml:"ChecksumSHA256,omitempty"`
	PartNumber     int    `xml:"PartNumber,omitempty"`
	Size           int    `xml:"Size,omitempty"`
}

type PlacementPolicy added in v0.26.0

type PlacementPolicy interface {
	Default() netmap.PlacementPolicy
	Get(string) (netmap.PlacementPolicy, bool)
}

type PlacementPolicyProvider added in v0.32.0

type PlacementPolicyProvider interface {
	// GetPlacementPolicy get policy by name.
	// Returns [models.ErrNotFound] if policy not found.
	GetPlacementPolicy(userAddr util.Uint160, policyName string) (*netmap.PlacementPolicy, error)
}

PlacementPolicyProvider takes placement policy from contract.

type PostResponse added in v0.17.0

type PostResponse struct {
	Bucket string `xml:"Bucket"`
	Key    string `xml:"Key"`
	ETag   string `xml:"Etag"`
}

PostResponse contains result of posting object.

type SendNotificationParams added in v0.21.0

type SendNotificationParams struct {
	Event            string
	NotificationInfo *data.NotificationInfo
	BktInfo          *data.BucketInfo
	ReqInfo          *api.ReqInfo
	User             string
	Time             time.Time
}

type ServiceRecord added in v0.22.0

type ServiceRecord struct {
	Resource           string
	GroupRecordsLength int
}

type StringMap

type StringMap map[string]string

StringMap is a map[string]string.

func (StringMap) MarshalXML

func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML -- StringMap marshals into XML.

type Tag added in v0.17.0

type Tag struct {
	Key   string
	Value string
}

Tag is an AWS key-value tag.

type Tagging added in v0.17.0

type Tagging struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Tagging"`
	TagSet  []Tag    `xml:"TagSet>Tag"`
}

Tagging contains tag set.

type UploadPartCopyResponse added in v0.18.0

type UploadPartCopyResponse struct {
	ETag         string `xml:"ETag"`
	LastModified string `xml:"LastModified"`
}

type VersioningConfiguration

type VersioningConfiguration struct {
	XMLName   xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ VersioningConfiguration"`
	Status    string   `xml:"Status,omitempty"`
	MfaDelete string   `xml:"MfaDelete,omitempty"`
}

VersioningConfiguration contains VersioningConfiguration XML representation.

Jump to

Keyboard shortcuts

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