storage

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const API_VERSION = "v1"
View Source
const AUTH_HEADER = "X-Auth-Token"
View Source
const STR_ACCOUNT = "/Storage-%s"
View Source
const STR_QUALIFIED_NAME = "%s%s/%s"
View Source
const STR_USERNAME = "/Storage-%s:%s"

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	// The name of the Container
	Name string
	// A container access control list (ACL) that grants read access.
	ReadACLs []string
	// A container access control list (ACL) that grants write access
	WriteACLs []string
	// The secret key value for temporary URLs.
	PrimaryKey string
	// The second secret key value for temporary URLs.
	SecondaryKey string
	// List of origins to be allowed to make cross-origin Requests.
	AllowedOrigins []string
	// List of headers exposed to the user agent (e.g. browser) in the actual request response.
	ExposedHeaders []string
	// Maximum age in seconds for the origin to hold the preflight results.
	MaxAge int
}

Container describes an existing Container.

type CreateContainerInput

type CreateContainerInput struct {
	// The unique name for the container. The container name must be from 1 to 256 characters long and can
	// start with any character and contain any pattern. Character set must be UTF-8. The container name
	// cannot contain a slash (/) character because this character delimits the container and object name.
	// For example, /account/container/object.
	// Required
	Name string `json:"name"`
	// Sets a container access control list (ACL) that grants read access.
	// Optional
	ReadACLs []string
	// Sets a container access control list (ACL) that grants read access.
	// Optional
	WriteACLs []string
	// Sets a secret key value for temporary URLs.
	// Optional
	PrimaryKey string
	// Sets a second secret key value for temporary URLs.
	// Optional
	SecondaryKey string
	// Sets the list of origins allowed to make cross-origin requests.
	// Optional
	AllowedOrigins []string
	// List of headers exposed to the user agent (e.g. browser) in the actual request response.
	// Optional
	ExposedHeaders []string
	// Sets the maximum age in seconds for the origin to hold the preflight results.
	// Optional
	MaxAge int
}

CreateContainerInput defines an Container to be created.

type CreateObjectInput added in v0.3.0

type CreateObjectInput struct {
	// Name of the object.
	// Required
	Name string
	// Body of the request to use. Accepts an io.ReadSeeker, so options are open to
	// the downstream consumer
	// Required
	Body io.ReadSeeker
	// Name of the container to place the object
	// Required
	Container string
	// Override the behavior of the browser.
	// Optional
	ContentDisposition string
	// Set the content-encoding metadata
	// Optional
	ContentEncoding string
	// Changes the MIME type for the object
	// Optional - Defaults to 'text/plain'
	ContentType string
	// Specify the `container/object` to copy from. Must be UTF-8 encoded
	// and the name of the container and object must be URL-encoded
	// Optional
	CopyFrom string
	// Specify the number of seconds after which the system deletes the object.
	// Optional
	DeleteAt int

	// MD5 checksum value of the request body. Unquoted
	// Strongly recommended, not required.
	ETag string

	// Sets the transfer encoding. Can only be "chunked" or nil.
	// Requires content-length to be 0 if set.
	// Optional
	TransferEncoding string
}

CreateObjectInput struct for a Create Method to create a storage object TODO: Add query parameters if needed

type DeleteContainerInput

type DeleteContainerInput struct {
	// The name of the Container
	// Required
	Name string `json:"name"`
}

DeleteKeyInput describes the container to delete

type DeleteObjectInput added in v0.3.0

type DeleteObjectInput struct {
	// ID is the container name + "/" + object name
	// Optional - Either ID or Name + Container are required
	ID string
	// Name of the Object to delete
	// Optional - Either ID or Name + Container are required
	Name string
	// Name of the container
	// Optional - Either ID or Name + Container are required
	Container string
}

DeleteObjectInput struct for deleting objects TODO: Add query parameters if needed

type GetContainerInput

type GetContainerInput struct {
	// The name of the Container
	// Required
	Name string `json:"name"`
}

GetContainerInput describes the container to get

type GetObjectInput added in v0.3.0

type GetObjectInput struct {

	// ID of the object (container/object)
	// Optional - Either ID or Name + Container are required
	ID string

	// Name of the object to get details on
	// Optional - Either ID or Name + Container are required
	Name string
	// Name of the container
	// Optional - Either ID or Name + Container are required
	Container string
	// Range of data to receive. Must be specified via a byte range:
	// bytes=-5; bytes=10-15. Accept the entire string here, as multiple ranges
	// can be specified with a comma delimiter
	// Optional
	Range string
	// 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.
	// Optional
	Newest bool
}

GetObjectInput details on a storage object TODO: Add query parameters if needed

type ObjectClient added in v0.3.0

type ObjectClient struct {
	StorageClient
}

func (*ObjectClient) CreateObject added in v0.3.0

func (c *ObjectClient) CreateObject(input *CreateObjectInput) (*ObjectInfo, error)

CreateObject creates a new Object inside of a container.

func (*ObjectClient) DeleteObject added in v0.3.0

func (c *ObjectClient) DeleteObject(input *DeleteObjectInput) error

DeleteObject will delete the supplied object

func (*ObjectClient) GetObject added in v0.3.0

func (c *ObjectClient) GetObject(input *GetObjectInput) (*ObjectInfo, error)

GetObject accepts a input struct, returns an info struct

type ObjectInfo added in v0.3.0

type ObjectInfo struct {
	// ID is the container name + "/" object name for convenience
	ID string
	// Name of the object
	Name string
	// Type of ranges the object accepts
	AcceptRanges string
	// Name of the container
	Container string
	// Optional: Specifies the override behavior for the browser
	ContentDisposition string
	// Optional: Content's Encoding header
	ContentEncoding string
	// Length of the object in bytes
	ContentLength int
	// Type of the content
	ContentType string
	// Date of the transaction in ISO 8601 format.
	// Null value means the token never expires
	Date string
	// For objects smaller than 5GB, MD5 checksum of the object content.
	// Otherwise MD5 sum of the concatenated string of MD5 sums and ETAGS
	// for each segment of the manifest. Enclosed in double-quote characters
	Etag string
	// Date and time when the object was created/modified. ISO 8601.
	LastModified string
	// Optional: Date+Time in EPOCH that the object will be deleted.
	DeleteAt int
	// Optional: The dynamic large object manifest object.
	ObjectManifest string

	// Date and time in UNIX EPOCH when the account, container, _or_ object
	// was initially created as a current version.
	Timestamp string
	// Transaction ID of the request - Used for bug reports to service providers
	TransactionID string
}

ObjectInfo describes an existing object Optional values may not be passed in as response headers TODO: Add query parameters if needed

type StorageClient

type StorageClient struct {
	// contains filtered or unexported fields
}

Client represents an authenticated compute client, with compute credentials and an api client.

func NewStorageClient

func NewStorageClient(c *opc.Config) (*StorageClient, error)

func (*StorageClient) CreateContainer

func (c *StorageClient) CreateContainer(input *CreateContainerInput) (*Container, error)

CreateContainer creates a new Container with the given name, key and enabled flag.

func (*StorageClient) DeleteContainer

func (c *StorageClient) DeleteContainer(input *DeleteContainerInput) error

DeleteContainer deletes the Container with the given name.

func (*StorageClient) GetContainer

func (c *StorageClient) GetContainer(input *GetContainerInput) (*Container, error)

GetContainer retrieves the Container with the given name.

func (*StorageClient) Objects added in v0.3.0

func (c *StorageClient) Objects() *ObjectClient

func (*StorageClient) UpdateContainer

func (c *StorageClient) UpdateContainer(input *UpdateContainerInput) (*Container, error)

UpdateContainer updates the key and enabled flag of the Container with the given name.

type UpdateContainerInput

type UpdateContainerInput struct {
	// The name of the Container
	// Required
	Name string `json:"name"`
	// Updates a container access control list (ACL) that grants read access.
	// Optional
	ReadACLs []string
	// Updates a container access control list (ACL) that grants write access.
	// Optional
	WriteACLs []string
	// Updates the secret key value for temporary URLs.
	// Optional
	PrimaryKey string
	// Update the second secret key value for temporary URLs.
	// Optional
	SecondaryKey string
	// Updates the list of origins allowed to make cross-origin requests.
	// Optional
	AllowedOrigins []string
	// List of headers exposed to the user agent (e.g. browser) in the actual request response.
	// Optional
	ExposedHeaders []string
	// Updates the maximum age in seconds for the origin to hold the preflight results.
	// Optional
	MaxAge int
}

UpdateContainerInput defines an Container to be updated

Jump to

Keyboard shortcuts

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