objectstorageV1

package
v0.0.0-...-a83d163 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// P2Region -> region
	P2Region pointTo = iota + 1
	// P2Container -> container
	P2Container
	// P2VPath -> virtual path: /virt/ua/l/object
	P2VPath
	// P2VPathOrObject -> virual path or object
	P2VPathOrObject
	// P2Object -> object
	P2Object
)

Variables

View Source
var (
	// ErrContainerNotFound when a container is not found
	ErrContainerNotFound = errors.New("container nor found")
)

Functions

func GetRegions

func GetRegions() []string

GetRegions returns available regions

Types

type Account

type Account struct {
	Name           string
	ObjectCount    int // the number of objects in the account.
	BytesUsed      int // the total number of bytes that are stored in Object Storage for the account.
	ContainerCount int // the number of container in the account
	//TODO XMetaY
	Timestamp   *time.Time  // The time and date, in UNIX Epoch timestamp format, when the account was initially created as a current version.
	TempURLKey  string      // The secret key value for temporary URLs. If not set, this header is not returned by this operation.
	TempURLKey2 string      // A second secret key value for temporary URLs. If not set, this header is not returned by this operation.
	Containers  []Container // Slice of containers
}

Account représents an objext storage account

func GetAccountInfo

func GetAccountInfo(regionName string) (account Account, err error)

GetAccountInfo return object storage account (GET)

type Container

type Container struct {
	// Name is the name of the container
	Name string `json:"name"`

	// region is the region where is the conatier
	Region string

	// The time and date, in UNIX Epoch timestamp format, when the container was
	// initially created as a current version.
	CreatedAt *time.Time

	// ObjectCount: number of object in the container
	ObjectCount uint64 `json:"count"`

	// BytesUsed: The count of bytes used in total.
	BytesUsed uint64 `json:"bytes"`

	// QuotaBytes Sets maximum size of the container, in bytes. Typically
	// these values are set by an administrator. Returns a 413 response (request
	// entity too large) when an object PUT operation exceeds this quota value.
	QuotaBytes int64

	// QuotaCount Sets maximum object count of the container. Typically these
	// values are set by an administrator. Returns a 413 response (request entity
	// too large) when an object PUT operation exceeds this quota value.
	QuotaCount int64

	// Objects in container
	Objects []Object

	// AclRead
	AclRead string

	// AclWrite
	AclWrite string

	// SyncTo Sets the secret key for container synchronization.
	// If you remove the secret key, synchronization is halted.
	SyncTo string

	// Sets the secret key for container synchronization. If you remove the secret
	// key, synchronization is halted.
	SyncKey string

	// VersionsLocation: Enables versioning on this container. The value is the name of another
	// container. You must UTF-8-encode and then URL-encode the name before you
	// include it in the header. To disable versioning, set the header to an
	// empty string.
	VersionsLocation string

	// MetaWebDirectoryType Sets the content-type of directory marker objects.
	// If the header is not set, default is application/directory.
	// Directory marker objects are 0-byte objects that represent directories to
	// create a simulated hierarchical structure.
	// For example, if you set "X-Container-Meta-Web-Directory-Type: text/directory",
	// Object Storage treats 0-byte objects with a content-type of text/directory
	// as directories rather than objects.
	MetaWebDirectoryType string

	// ContentType the MIME type for
	ContentType string

	// AcceptRanges The type of ranges that the object accepts.
	AcceptRanges string

	// DetectContentType If set to true, Object Storage guesses the content type
	// based on the file extension and ignores the value sent in the Content-Type
	// header, if present.
	DetectContentType bool

	// IfNoneMatch In combination with Expect: 100-Continue, specify
	// an "If-None-Match: *" header to query whether the server already has a
	// copy of the object before any data is sent.
	IfNoneMatch string
}

Container represents a object container

func (*Container) Delete

func (c *Container) Delete() error

Delete deletes a container

func (*Container) Get

func (c *Container) Get(requestParams *ContainerRequestParameters) error

Get return a container (with full propriety fetched)

func (*Container) Head

func (c *Container) Head(requestParams *ContainerRequestParameters) error

Head do a HEAD request an populate container with basic infos

func (*Container) Post

func (c *Container) Post() error

Post update (or create a container

func (*Container) Put

func (c *Container) Put(requestParams *ContainerRequestParameters) error

Put creates new container

type ContainerRequestParameters

type ContainerRequestParameters struct {
	// For an integer value n, limits the number of results to n.
	Limit uint

	// Marker: For a string value x, returns container names that are greater in
	// value than the specified marker.
	Marker string

	// EndMarker For a string value x, returns container names that are less in
	// value than the specified marker.
	EndMarker string

	// Prefix: Prefix value. Named items in the response begin with this value.
	Prefix string

	// Delimiter Delimiter value, which returns the object names that are nested
	// in the container.
	Delimiter string

	// Path For a string value, returns the object names that are nested in the
	// pseudo path. Equivalent to setting delimiter to / and prefix to the path
	// with a / at the end.
	Path string

	// Newest If set to True, Object Storage queries all replicas to return the
	// most recent one. If you omit this header, Object Storage responds faster
	// after it finds one valid replica. Because setting this header to True is
	// more expensive for the back end, use it only when it is absolutely needed.
	Newest bool

	// In combination with Expect: 100-Continue, specify an "If-None-Match: *"
	// header to query whether the server already has a copy of the object before
	// any data is sent.
	IfNoneMatch bool
}

ContainerRequestParameters represents parameters for queries

type Object

type Object struct {
	// Region
	Region string

	// Container
	Container string

	//Name: name of the object
	Name string `json:"name"`

	// AcceptRanges The type of ranges that the object accepts.
	AcceptRanges string

	// Hash: MD5 checksum value of the object content
	Hash string `json:"hash"`

	// Etag For objects smaller than 5 GB, this value is the MD5 checksum of
	// the object content. The value is not quoted.
	// For manifest objects, this value is the MD5 checksum of the concatenated
	// string of MD5 checksums and ETags for each of the segments in the manifest,
	// and not the MD5 checksum of the content that was downloaded. Also the value
	// is enclosed in double-quote characters.
	// You are strongly recommended to compute the MD5 checksum of the response
	// body as it is received and compare this value with the one in the ETag
	//header. If they differ, the content was corrupted, so retry the operation.
	Etag string

	// Bytes: total number of bytes that are stored for this Object
	Bytes int64 `json:"bytes"`

	// ContentType: content type of the object
	ContentType string `json:"content_type"`

	// DetectContentType If set to true, Object Storage guesses the content type
	// based on the file extension and ignores the value sent in the
	// Content-Type header, if present.
	DetectContentType bool

	// ContentEncoding if set, the value of the Content-Encoding metadata.
	ContentEncoding string

	// ContentDisposition If set, specifies the override behavior for the browser.
	// For example, this header might specify that the browser use a download
	// program to save this file rather than show the file, which is the default.
	ContentDisposition string

	// LastModified: The date and time when the object was last modified
	LastModified gopenstack.TimeNano `json:"last_modified"`

	// CreatedAt The date  when the object was initially created as a current
	// version.
	CreatedAt *time.Time

	// DeleteAt the time when the object will be deleted by the system.
	DeleteAt *time.Time

	// DeleteAfter Specifies the number of seconds after which the object is
	// removed. Internally, the Object Storage system stores this value in
	// the X-Delete-At metadata item.
	DeleteAfter uint64

	// Manifest if set this is a dynamic large object manifest object.
	// The value is the container and object name prefix of the segment objects
	// in the form container/prefix.
	Manifest string

	// IsStaticLargeObject True if this object is a static large object manifest object.
	IsStaticLargeObject bool

	//LocalPath local path of an object. Used for transfers
	LocalPath string

	// RawData is a reader to the raw data
	RawData io.Reader

	// CopiedFromLastModified (copy) : For a copied object, shows the last
	// modified date and time for the container and object name from which the
	// new object was copied.
	CopiedFromLastModified *time.Time

	// CopiedFrom For a copied object, shows the last modified date and time for
	// the container and object name from which the new object was copied.
	CopiedFrom string
}

Object represents an openstack object

func (*Object) Copy

func (o *Object) Copy(destination string) error

Copy an object

func (*Object) Delete

func (o *Object) Delete(MultiPartManifestDelete bool) error

Delete an object

func (*Object) Get

func (o *Object) Get(requestParameters *ObjectRequestParameters) error

Get fetch object to retrieve raw data -> Save(path)

func (*Object) Head

func (o *Object) Head(requestParameters *ObjectRequestParameters) error

Head do an HEAD request an parse response

func (*Object) Post

func (o *Object) Post(requestParameters *ObjectRequestParameters) error

Post update object

func (*Object) Put

func (o *Object) Put(requestParameters *ObjectRequestParameters) error

Put upload object to openstack

type ObjectRequestParameters

type ObjectRequestParameters struct {
	// TempURLSig Used with temporary URLs to sign the request with an
	// HMAC-SHA1 cryptographic signature that defines the allowed HTTP method,
	// expiration date, full path to the object, and the secret key for the
	// temporary URL. For more information about temporary URLs, see OpenStack
	// Object Storage API v1 Reference:
	// http://docs.openstack.org/developer/swift/api/temporary_url_middleware.html
	TempURLSig string

	// TempURLExpires Used with temporary URLs to specify the expiry time of the
	// signature as a UNIX Epoch timestamp, which is an integer value.
	// For example, 1390852007 represents Mon, 27 Jan 2014 19:46:47 GMT.
	// For more information about temporary URLs, see OpenStack Object
	// Storage API v1 Reference:
	// http://docs.openstack.org/developer/swift/api/temporary_url_middleware.html
	TempURLExpires string

	// Filename Used with temporary URLs to override the default file name.
	// Object Storage generates a default file name for GET temporary URLs that
	// is based on the object name. Object Storage returns this value in the
	// Content-Disposition response header. Browsers can interpret this file name
	// value as a file attachment to be saved. For more information about
	// temporary URLs, see OpenStack Object Storage API v1 Reference:
	// http://docs.openstack.org/developer/swift/api/temporary_url_middleware.html
	Filename string

	// MultipartManifest If you include the multipart-manifest=get query parameter
	// and the object is a large object, the object contents are not returned.
	// Instead, the manifest is returned in the X-Object-Manifest response header
	// for dynamic large objects or in the response body for static large objects.
	MultipartManifest string

	// Range The ranges of content to get.
	Range string

	// IfMatch (etag)
	IfMatch string

	// IfNoneMatch In combination with Expect: 100-Continue,
	// specify an "If-None-Match: *" header to query whether the server already
	// has a copy of the object before any data is sent.
	IfNoneMatch bool

	// IfModifiedSince
	IfModifiedSince *time.Time

	// IfUnmodifiedSince
	IfUnmodifiedSince *time.Time

	// Destination (copy)
	Destination string

	// Newest
	Newest bool
}

ObjectRequestParameters is used to add parameters to HEAD and GET request

type OsPath

type OsPath struct {
	FullPath  string
	Region    string
	Container string
	Object    string
	// if path is P2VPathOrObject VpathObject represents the last parts of the path
	// eg: /region/container/path/to/object -> path/to/object
	// /region/container/path/to -> path/to
	VpathObject string
	PointTo     pointTo
}

OsPath represent a full path to an "object"

func NewOsPathFromPath

func NewOsPathFromPath(fullpath string) (p OsPath)

NewOsPathFromPath returns an OsPath form a string path (/region/container/to/object)

func (*OsPath) IsContainer

func (p *OsPath) IsContainer() bool

IsContainer check if path point to container

func (*OsPath) String

func (p *OsPath) String() string

Jump to

Keyboard shortcuts

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