datatype

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	CANNEDACL_PRIVATE                    = 0
	CANNEDACL_PUBLIC_READ                = 1
	CANNEDACL_PUBLIC_READ_WRITE          = 2
	CANNEDACL_AWS_EXEC_READ              = 3
	CANNEDACL_AUTHENTICATED_READ         = 4
	CANNEDACL_BUCKET_OWNER_READ          = 5
	CANNEDACL_BUCKET_OWNER_FULL_CONTROLL = 6
)
View Source
const (
	XMLNSXSI = "http://www.w3.org/2001/XMLSchema-instance"
	XMLNS    = "http://s3.amazonaws.com/doc/2006-03-01/"
)
View Source
const (
	ACL_TYPE_CANONICAL_USER = "CanonicalUser"
	ACL_TYPE_GROUP          = "Group"
)
View Source
const (
	ACL_GROUP_TYPE_ALL_USERS           = "http://acs.amazonaws.com/groups/global/AllUsers"
	ACL_GROUP_TYPE_AUTHENTICATED_USERS = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
)
View Source
const (
	ACL_PERM_READ         = "READ"
	ACL_PERM_WRITE        = "WRITE"
	ACL_PERM_READ_ACP     = "READ_ACP"
	ACL_PERM_WRITE_ACP    = "WRITE_ACP"
	ACL_PERM_FULL_CONTROL = "FULL_CONTROL"
)
View Source
const (
	MaxObjectList  = 1000 // Limit number of objects in a listObjectsResponse.
	MaxUploadsList = 1000 // Limit number of uploads in a listUploadsResponse.
	MaxPartsList   = 1000 // Limit number of parts in a listPartsResponse.
)
View Source
const (
	Iso8601Format           = "20060102T150405Z"
	YYYYMMDD                = "20060102"
	PresignedUrlExpireLimit = 7 * 24 * time.Hour
)
View Source
const (
	MaxBucketEncryptionRulesCount        = 100
	MaxBucketEncryptionConfigurationSize = 20 * humanize.KiByte
)
View Source
const (
	MaxObjectMetaConfigurationSize = 2 * humanize.KiByte
	CustomizeMetadataHeader        = "X-Amz-Meta-"
)
View Source
const (
	MaxBucketWebsiteRulesCount        = 100
	MaxBucketWebsiteConfigurationSize = 20 * humanize.KiByte
)
View Source
const (
	MAX_CORS_SIZE = 64 << 10 // 64 KB
)

Variables

View Source
var ErrorInvalidRange = errors.New("Invalid range")

ErrorInvalidRange - returned when given range value is not valid.

View Source
var ValidCannedAcl = []string{
	"private",
	"public-read",
	"public-read-write",
	"aws-exec-read",
	"authenticated-read",
	"bucket-owner-read",
	"bucket-owner-full-controll",
}

Functions

func IsValidCannedAcl

func IsValidCannedAcl(acl Acl) (err error)

func ParseAmzDate

func ParseAmzDate(amzDateStr string) (amzDate time.Time, apiErr error)

parseAmzDate - parses date string into supported amz date formats.

Types

type AccessControlPolicy

type AccessControlPolicy struct {
	XMLName           xml.Name `xml:"AccessControlPolicy"`
	Xmlns             string   `xml:"xmlns,attr,omitempty"`
	ID                string   `xml:"Owner>ID"`
	DisplayName       string   `xml:"Owner>DisplayName"`
	AccessControlList []Grant  `xml:"AccessControlList>Grant"`
}

type AccessControlPolicyResponse

type AccessControlPolicyResponse struct {
	XMLName           xml.Name        `xml:"AccessControlPolicy"`
	Xmlns             string          `xml:"xmlns,attr,omitempty"`
	ID                string          `xml:"Owner>ID"`
	DisplayName       string          `xml:"Owner>DisplayName"`
	AccessControlList []GrantResponse `xml:"AccessControlList>Grant"`
}

func CreatePolicyFromCanned

func CreatePolicyFromCanned(owner Owner, bucketOwner Owner, acl Acl) (
	policy AccessControlPolicyResponse, err error)

type Acl

type Acl struct {
	CannedAcl string
}

func GetCannedAclFromPolicy

func GetCannedAclFromPolicy(policy AccessControlPolicy) (acl Acl, err error)

the function will be deleted, because we will use AccessControlPolicy instead canned acl stored in hbase

type AppendObjectResult

type AppendObjectResult struct {
	PutObjectResult
	NextPosition int64
}

type ApplyServerSideEncryptionByDefault

type ApplyServerSideEncryptionByDefault struct {
	XMLName        xml.Name `xml:"ApplyServerSideEncryptionByDefault"`
	KMSMasterKeyID string   `xml:"KMSMasterKeyID"`
	SSEAlgorithm   string   `xml:"SSEAlgorithm"`
}

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 BucketLoggingRule

type BucketLoggingRule struct {
	TargetBucket string `xml:"TargetBucket"`
	TargetPrefix string `xml:"TargetPrefix"`
}

type BucketLoggingStatus

type BucketLoggingStatus struct {
	LoggingEnabled BucketLoggingRule `xml:"LoggingEnabled"`
	SetTime        string
	SetLog         bool
	DeleteTime     string
}

type BucketVersioningType

type BucketVersioningType string
const (
	BucketVersioningEnabled   BucketVersioningType = "Enabled"
	BucketVersioningDisabled  BucketVersioningType = "Disabled"
	BucketVersioningSuspended BucketVersioningType = "Suspended"
)

func (BucketVersioningType) String

func (b BucketVersioningType) String() string

type CommonPrefix

type CommonPrefix struct {
	XMLName xml.Name `xml:"CommonPrefixes"`
	Prefix  string
}

CommonPrefix container for prefix response in ListObjectsResponse

type CompleteMultipartResult

type CompleteMultipartResult struct {
	ETag                    string
	VersionId               string
	SseType                 string
	SseAwsKmsKeyIdBase64    string
	SseCustomerAlgorithm    string
	SseCustomerKeyMd5Base64 string
}

type CompleteMultipartUploadResponse

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

	Location string
	Bucket   string
	Key      string
	ETag     string
}

CompleteMultipartUploadResponse container for completed multipart upload response

type Condition

type Condition struct {
	XMLName                     xml.Name `xml:"Condition"`
	KeyPrefixEquals             string   `xml:"KeyPrefixEquals,omitempty"`
	HttpErrorCodeReturnedEquals string   `xml:"HttpErrorCodeReturnedEquals,omitempty"`
}

type CopyObjectPartResponse

type CopyObjectPartResponse struct {
	XMLName      xml.Name `xml:"CopyPartResult"`
	LastModified string
	ETag         string
}

type CopyObjectResponse

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

CopyObjectResponse container returns ETag and LastModified of the successfully copied object

type Cors

type Cors struct {
	XMLName   xml.Name   `xml:"CORSConfiguration" json:"-"`
	CorsRules []CorsRule `xml:"CORSRule"`
}

func CorsFromXml

func CorsFromXml(corsBuffer []byte) (cors Cors, err error)

type CorsRule

type CorsRule struct {
	Id             string   `xml:"ID"`
	AllowedMethods []string `xml:"AllowedMethod"`
	AllowedOrigins []string `xml:"AllowedOrigin"`
	AllowedHeaders []string `xml:"AllowedHeader"`
	MaxAgeSeconds  int
	ExposedHeaders []string `xml:"ExposeHeader"`
}

func (CorsRule) OriginMatched

func (rule CorsRule) OriginMatched(origin string) bool

func (CorsRule) SetResponseHeaders

func (rule CorsRule) SetResponseHeaders(w http.ResponseWriter, r *http.Request)

type CreateBucketLocationConfiguration

type CreateBucketLocationConfiguration struct {
	XMLName  xml.Name `xml:"CreateBucketConfiguration" json:"-"`
	Location string   `xml:"LocationConstraint"`
}

createBucketConfiguration container for bucket configuration request from client. Used for parsing the location from the request body for MakeBucket.

type DeleteError

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

DeleteError structure.

type DeleteObjectResult

type DeleteObjectResult struct {
	DeleteMarker bool
	VersionId    string
}

type DeleteObjectsRequest

type DeleteObjectsRequest struct {
	XMLName xml.Name `xml:"Delete"`
	// 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 needs to be deleted.

type EncryptionConfiguration

type EncryptionConfiguration struct {
	XMLName xml.Name `xml:"ServerSideEncryptionConfiguration"`
	Rules   []*Rule  `xml:"Rule,omitempty"`
}

func ParseEncryptionConfig

func ParseEncryptionConfig(reader io.Reader) (*EncryptionConfiguration, error)

func (*EncryptionConfiguration) Validate

func (e *EncryptionConfiguration) Validate() (error error)

Reference:https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html

type ErrorDocument

type ErrorDocument struct {
	XMLName xml.Name `xml:"ErrorDocument"`
	Key     string   `xml:"Key"`
}

type GlacierJobParameters

type GlacierJobParameters struct {
	XMLName xml.Name `xml:"GlacierJobParameters"`
	Tier    string   `xml:"Tier"`
}

type Grant

type Grant struct {
	XMLName    xml.Name `xml:"Grant"`
	Grantee    Grantee  `xml:"Grantee"`
	Permission string   `xml:"Permission"`
}

type GrantResponse

type GrantResponse struct {
	XMLName    xml.Name        `xml:"Grant"`
	Grantee    GranteeResponse `xml:"Grantee"`
	Permission string          `xml:"Permission"`
}

type Grantee

type Grantee struct {
	XMLName      xml.Name `xml:"Grantee"`
	XmlnsXsi     string   `xml:"xmlns:xsi,attr"`
	XsiType      string   `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
	URI          string   `xml:"URI,omitempty"`
	ID           string   `xml:"ID,omitempty"`
	DisplayName  string   `xml:"DisplayName,omitempty"`
	EmailAddress string   `xml:"EmailAddress,omitempty"`
}

type GranteeResponse

type GranteeResponse struct {
	XMLName      xml.Name `xml:"Grantee"`
	XmlnsXsi     string   `xml:"xmlns:xsi,attr"`
	XsiType      string   `xml:"xsi:type,attr"`
	URI          string   `xml:"URI,omitempty"`
	ID           string   `xml:"ID,omitempty"`
	DisplayName  string   `xml:"DisplayName,omitempty"`
	EmailAddress string   `xml:"EmailAddress,omitempty"`
}

type Headers

type Headers struct {
	XMLName  xml.Name   `xml:"Headers"`
	MetaData []MetaData `xml:"MetaData,omitempty"`
}

type HttpRange

type HttpRange struct {
	OffsetBegin  int64
	OffsetEnd    int64
	ResourceSize int64
}

HttpRange specifies the byte range to be sent to the client.

func ParseRequestRange

func ParseRequestRange(rangeString string, resourceSize int64) (hrange *HttpRange, err error)

func (HttpRange) GetLength

func (hrange HttpRange) GetLength() int64

getlength - get length from the range.

func (HttpRange) String

func (hrange HttpRange) String() string

String populate range stringer interface

type IndexDocument

type IndexDocument struct {
	XMLName xml.Name `xml:"IndexDocument"`
	Suffix  string   `xml:"Suffix"`
}

type InitiateMultipartUploadResponse

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

	Bucket   string
	Key      string
	UploadID string `xml:"UploadId"`
}

InitiateMultipartUploadResponse container for InitiateMultiPartUpload response, provides uploadID to start MultiPart upload

type Initiator

type Initiator Owner

Initiator inherit from Owner struct, fields are same

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

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

	Bucket             string
	KeyMarker          string
	UploadIdMarker     string
	NextKeyMarker      string
	NextUploadIdMarker string
	EncodingType       string `xml:"Encoding-Type,omitempty"`
	MaxUploads         int
	IsTruncated        bool
	Uploads            []Upload `xml:"Upload"`
	Prefix             string
	Delimiter          string
	CommonPrefixes     []CommonPrefix
}

ListMultipartUploadsResponse - format for list multipart uploads response.

type ListObjectsRequest

type ListObjectsRequest struct {
	Versioned    bool // should return versioned objects?
	Version      int  // Currently 1 or 2
	Delimiter    string
	EncodingType string
	MaxKeys      int
	Prefix       string

	// v1 specific
	Marker string

	// v2 specific
	ContinuationToken string
	StartAfter        string
	FetchOwner        bool

	// versioned specific
	KeyMarker       string
	VersionIdMarker string
}

type ListObjectsResponse

type ListObjectsResponse struct {
	XMLName xml.Name `xml:"ListBucketResult"`

	CommonPrefixes []CommonPrefix
	Delimiter      string
	EncodingType   string `xml:"Encoding-Type,omitempty"`
	IsTruncated    bool
	MaxKeys        int
	KeyCount       int `xml:",omitempty"`
	Prefix         string
	BucketName     string `xml:"Name"`

	// v1 specific
	Marker     string
	NextMarker string `xml:",omitempty"`

	// v2 specific
	ContinuationToken     string `xml:",omitempty"`
	NextContinuationToken string `xml:",omitempty"`
	StartAfter            string `xml:",omitempty"`

	Contents []Object
}

type ListPartsRequest

type ListPartsRequest struct {
	EncodingType     string
	UploadId         string
	MaxParts         int
	PartNumberMarker int
}

type ListPartsResponse

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

	Bucket       string
	Key          string
	UploadId     string
	EncodingType string `xml:"Encoding-Type,omitempty"`

	Initiator Initiator
	Owner     Owner

	// The class of storage used to store the object.
	StorageClass string

	PartNumberMarker     int
	NextPartNumberMarker int
	MaxParts             int
	IsTruncated          bool

	// List of parts.
	Parts []Part `xml:"Part"`
}

ListPartsResponse - format for list parts response.

type ListUploadsRequest

type ListUploadsRequest struct {
	Delimiter      string
	EncodingType   string
	MaxUploads     int
	KeyMarker      string
	Prefix         string
	UploadIdMarker string
}

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 MetaConfiguration

type MetaConfiguration struct {
	XMLName   xml.Name `xml:"MetaConfiguration"`
	Xmlns     string   `xml:"xmlns,attr,omitempty"`
	VersionID string   `xml:"VersionID,omitempty"`
	Headers   *Headers `xml:"Headers,omitempty"`
}

type MetaData

type MetaData struct {
	Key   string `xml:"key"`
	Value string `xml:"value"`
}

type MetaDataReq

type MetaDataReq struct {
	VersionId string
	Data      map[string]string
}

func ParseMetaConfig

func ParseMetaConfig(reader io.Reader) (metaDataReq MetaDataReq, err error)

type Object

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

	Owner Owner

	// The class of storage used to store the object.
	StorageClass string
}

Object container for object metadata

type ObjectIdentifier

type ObjectIdentifier struct {
	ObjectName            string `xml:"Key"`
	VersionId             string `xml:",omitempty"`
	DeleteMarker          bool   `xml:",omitempty"`
	DeleteMarkerVersionId string `xml:",omitempty"`
}

ObjectIdentifier carries key name for the object to delete.

type Owner

type Owner struct {
	ID          string
	DisplayName string
}

Owner - bucket owner/principal

type Part

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

Part container for part metadata.

type PostResponse

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

	Location string
	Bucket   string
	Key      string
	ETag     string
}

PostResponse container for completed post upload response

type PutObjectPartResult

type PutObjectPartResult struct {
	ETag                    string
	SseType                 string
	SseAwsKmsKeyIdBase64    string
	SseCustomerAlgorithm    string
	SseCustomerKeyMd5Base64 string
}

type PutObjectResult

type PutObjectResult struct {
	Md5          string
	VersionId    string
	LastModified time.Time
}

type Redirect

type Redirect struct {
	XMLName              xml.Name `xml:"Redirect"`
	Protocol             string   `xml:"Protocol,omitempty"`
	HostName             string   `xml:"HostName,omitempty"`
	ReplaceKeyPrefixWith string   `xml:"ReplaceKeyPrefixWith,omitempty"`
	ReplaceKeyWith       string   `xml:"ReplaceKeyWith,omitempty"`
	HttpRedirectCode     string   `xml:"HttpRedirectCode,omitempty"`
}

type RedirectAllRequestsTo

type RedirectAllRequestsTo struct {
	XMLName  xml.Name `xml:"RedirectAllRequestsTo"`
	HostName string   `xml:"HostName"`
	Protocol string   `xml:"Protocol,omitempty"`
}

type RenameObjectResponse

type RenameObjectResponse struct {
	XMLName      xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ RenameObjectResult" json:"-"`
	LastModified string   // time string of format "2006-01-02T15:04:05.000Z"
}

type RenameObjectResult

type RenameObjectResult struct {
	LastModified time.Time
}

type Restore

type Restore struct {
	XMLName              xml.Name             `xml:"RestoreRequest"`
	Days                 int                  `xml:"Days"`
	GlacierJobParameters GlacierJobParameters `xml:"GlacierJobParameters"`
}

func GetRestoreInfo

func GetRestoreInfo(r *http.Request) (*Restore, error)

type RoutingRule

type RoutingRule struct {
	XMLName   xml.Name   `xml:"RoutingRule"`
	Condition *Condition `xml:"Condition,omitempty"`
	Redirect  *Redirect  `xml:"Redirect"`
}

func (RoutingRule) DoRedirect

func (rr RoutingRule) DoRedirect(w http.ResponseWriter, r *http.Request, objectName string)

func (RoutingRule) Match

func (rr RoutingRule) Match(objectName string, errorCode string) bool

type Rule

type Rule struct {
	XMLName                            xml.Name                            `xml:"Rule"`
	ApplyServerSideEncryptionByDefault *ApplyServerSideEncryptionByDefault `xml:"ApplyServerSideEncryptionByDefault,omitempty"`
}

type SseRequest

type SseRequest struct {
	// type of Server Side Encryption, could be "SSE-KMS", "SSE-S3", "SSE-C"(custom), or ""(none),
	// KMS is not implemented yet
	Type string

	// AWS-managed specific(KMS and S3)
	SseAwsKmsKeyId string
	SseContext     string

	// customer-provided specific(SSE-C)
	SseCustomerAlgorithm string
	SseCustomerKey       []byte

	// keys for copy
	CopySourceSseCustomerAlgorithm string
	CopySourceSseCustomerKey       []byte
}

type Upload

type Upload struct {
	Key          string
	UploadId     string
	Initiator    Initiator
	Owner        Owner
	StorageClass string
	Initiated    string // time string of format "2006-01-02T15:04:05.000Z"
}

Upload container for in progress multipart upload

type VersionedListObjectsResponse

type VersionedListObjectsResponse struct {
	XMLName xml.Name `xml:"ListVersionsResult"`

	Contents            []VersionedObject
	CommonPrefixes      []CommonPrefix
	Delimiter           string
	EncodingType        string `xml:"Encoding-Type,omitempty"`
	IsTruncated         bool
	MaxKeys             int
	KeyCount            int
	Prefix              string
	BucketName          string `xml:"Name"`
	KeyMarker           string
	NextKeyMarker       string
	VersionIdMarker     string
	NextVersionIdMarker string
}

type VersionedObject

type VersionedObject struct {
	XMLName   xml.Name
	Key       string
	VersionId string

	DeleteMarker bool
	LastModified string // time string of format "2006-01-02T15:04:05.000Z"
	ETag         string
	Size         int64
	StorageClass string
	Owner        Owner
}

type Versioning

type Versioning struct {
	XMLName xml.Name             `xml:"VersioningConfiguration"`
	Status  BucketVersioningType `xml:",omitempty"`
}

func VersioningFromXml

func VersioningFromXml(xmlBytes []byte) (versioning Versioning, err error)

type WebsiteConfiguration

type WebsiteConfiguration struct {
	XMLName               xml.Name               `xml:"WebsiteConfiguration"`
	Xmlns                 string                 `xml:"xmlns,attr,omitempty"`
	RedirectAllRequestsTo *RedirectAllRequestsTo `xml:"RedirectAllRequestsTo,omitempty"`
	IndexDocument         *IndexDocument         `xml:"IndexDocument,omitempty"`
	ErrorDocument         *ErrorDocument         `xml:"ErrorDocument,omitempty"`
	RoutingRules          []RoutingRule          `xml:"RoutingRules>RoutingRule,omitempty"`
}

func ParseWebsiteConfig

func ParseWebsiteConfig(reader io.Reader) (*WebsiteConfiguration, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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