storage

package
v1.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package storage provides clients for Microsoft Azure Storage Services.

Index

Constants

View Source
const (
	MaxBlobBlockSize = 4 * 1024 * 1024
	MaxBlobPageSize  = 4 * 1024 * 1024
)

Maximum sizes (per REST API) for various concepts

View Source
const (
	// DefaultBaseURL is the domain name used for storage requests when a
	// default client is created.
	DefaultBaseURL = "core.windows.net"

	// DefaultAPIVersion is the  Azure Storage API version string used when a
	// basic client is created.
	DefaultAPIVersion = "2014-02-14"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureStorageServiceError

type AzureStorageServiceError struct {
	Code                      string `xml:"Code"`
	Message                   string `xml:"Message"`
	AuthenticationErrorDetail string `xml:"AuthenticationErrorDetail"`
	QueryParameterName        string `xml:"QueryParameterName"`
	QueryParameterValue       string `xml:"QueryParameterValue"`
	Reason                    string `xml:"Reason"`
	StatusCode                int
	RequestID                 string
}

AzureStorageServiceError contains fields of the error response from Azure Storage Service REST API. See https://msdn.microsoft.com/en-us/library/azure/dd179382.aspx Some fields might be specific to certain calls.

func (AzureStorageServiceError) Error

func (e AzureStorageServiceError) Error() string

type Blob

type Blob struct {
	Name       string         `xml:"Name"`
	Properties BlobProperties `xml:"Properties"`
}

A Blob is an entry in BlobListResponse.

type BlobListResponse

type BlobListResponse struct {
	XMLName    xml.Name `xml:"EnumerationResults"`
	Xmlns      string   `xml:"xmlns,attr"`
	Prefix     string   `xml:"Prefix"`
	Marker     string   `xml:"Marker"`
	NextMarker string   `xml:"NextMarker"`
	MaxResults int64    `xml:"MaxResults"`
	Blobs      []Blob   `xml:"Blobs>Blob"`
}

BlobListResponse contains the response fields from ListBlobs call.

See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx

type BlobProperties

type BlobProperties struct {
	LastModified          string   `xml:"Last-Modified"`
	Etag                  string   `xml:"Etag"`
	ContentMD5            string   `xml:"Content-MD5"`
	ContentLength         int64    `xml:"Content-Length"`
	ContentType           string   `xml:"Content-Type"`
	ContentEncoding       string   `xml:"Content-Encoding"`
	BlobType              BlobType `xml:"x-ms-blob-blob-type"`
	SequenceNumber        int64    `xml:"x-ms-blob-sequence-number"`
	CopyID                string   `xml:"CopyId"`
	CopyStatus            string   `xml:"CopyStatus"`
	CopySource            string   `xml:"CopySource"`
	CopyProgress          string   `xml:"CopyProgress"`
	CopyCompletionTime    string   `xml:"CopyCompletionTime"`
	CopyStatusDescription string   `xml:"CopyStatusDescription"`
}

BlobProperties contains various properties of a blob returned in various endpoints like ListBlobs or GetBlobProperties.

type BlobStorageClient

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

BlobStorageClient contains operations for Microsoft Azure Blob Storage Service.

func (BlobStorageClient) BlobExists

func (b BlobStorageClient) BlobExists(container, name string) (bool, error)

BlobExists returns true if a blob with given name exists on the specified container of the storage account.

func (BlobStorageClient) ContainerExists

func (b BlobStorageClient) ContainerExists(name string) (bool, error)

ContainerExists returns true if a container with given name exists on the storage account, otherwise returns false.

func (BlobStorageClient) CopyBlob

func (b BlobStorageClient) CopyBlob(container, name, sourceBlob string) error

CopyBlob starts a blob copy operation and waits for the operation to complete. sourceBlob parameter must be a canonical URL to the blob (can be obtained using GetBlobURL method.) There is no SLA on blob copy and therefore this helper method works faster on smaller files.

See https://msdn.microsoft.com/en-us/library/azure/dd894037.aspx

func (BlobStorageClient) CreateBlockBlob

func (b BlobStorageClient) CreateBlockBlob(container, name string) error

CreateBlockBlob initializes an empty block blob with no blocks.

See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx

func (BlobStorageClient) CreateContainer

func (b BlobStorageClient) CreateContainer(name string, access ContainerAccessType) error

CreateContainer creates a blob container within the storage account with given name and access level. Returns error if container already exists.

See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx

func (BlobStorageClient) CreateContainerIfNotExists

func (b BlobStorageClient) CreateContainerIfNotExists(name string, access ContainerAccessType) (bool, error)

CreateContainerIfNotExists creates a blob container if it does not exist. Returns true if container is newly created or false if container already exists.

func (BlobStorageClient) DeleteBlob

func (b BlobStorageClient) DeleteBlob(container, name string) error

DeleteBlob deletes the given blob from the specified container. If the blob does not exists at the time of the Delete Blob operation, it returns error. See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx

func (BlobStorageClient) DeleteBlobIfExists

func (b BlobStorageClient) DeleteBlobIfExists(container, name string) (bool, error)

DeleteBlobIfExists deletes the given blob from the specified container If the blob is deleted with this call, returns true. Otherwise returns false.

See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx

func (BlobStorageClient) DeleteContainer

func (b BlobStorageClient) DeleteContainer(name string) error

DeleteContainer deletes the container with given name on the storage account. If the container does not exist returns error.

See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx

func (BlobStorageClient) DeleteContainerIfExists

func (b BlobStorageClient) DeleteContainerIfExists(name string) (bool, error)

DeleteContainerIfExists deletes the container with given name on the storage account if it exists. Returns true if container is deleted with this call, or false if the container did not exist at the time of the Delete Container operation.

See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx

func (BlobStorageClient) GetBlob

func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error)

GetBlob returns a stream to read the blob. Caller must call Close() the reader to close on the underlying connection.

See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx

func (BlobStorageClient) GetBlobProperties

func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobProperties, error)

GetBlobProperties provides various information about the specified blob. See https://msdn.microsoft.com/en-us/library/azure/dd179394.aspx

func (BlobStorageClient) GetBlobRange

func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io.ReadCloser, error)

GetBlobRange reads the specified range of a blob to a stream. The bytesRange string must be in a format like "0-", "10-100" as defined in HTTP 1.1 spec.

See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx

func (BlobStorageClient) GetBlobSASURI

func (b BlobStorageClient) GetBlobSASURI(container, name string, expiry time.Time, permissions string) (string, error)

GetBlobSASURI creates an URL to the specified blob which contains the Shared Access Signature with specified permissions and expiration time.

See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx

func (BlobStorageClient) GetBlobURL

func (b BlobStorageClient) GetBlobURL(container, name string) string

GetBlobURL gets the canonical URL to the blob with the specified name in the specified container. This method does not create a publicly accessible URL if the blob or container is private and this method does not check if the blob exists.

func (BlobStorageClient) GetBlockList

func (b BlobStorageClient) GetBlockList(container, name string, blockType BlockListType) (BlockListResponse, error)

GetBlockList retrieves list of blocks in the specified block blob.

See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx

func (BlobStorageClient) GetPageRanges

func (b BlobStorageClient) GetPageRanges(container, name string) (GetPageRangesResponse, error)

GetPageRanges returns the list of valid page ranges for a page blob.

See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx

func (BlobStorageClient) ListBlobs

func (b BlobStorageClient) ListBlobs(container string, params ListBlobsParameters) (BlobListResponse, error)

ListBlobs returns an object that contains list of blobs in the container, pagination token and other information in the response of List Blobs call.

See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx

func (BlobStorageClient) ListContainers

ListContainers returns the list of containers in a storage account along with pagination token and other response details.

See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx

func (BlobStorageClient) PutBlock

func (b BlobStorageClient) PutBlock(container, name, blockID string, chunk []byte) error

PutBlock saves the given data chunk to the specified block blob with given ID.

See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx

func (BlobStorageClient) PutBlockList

func (b BlobStorageClient) PutBlockList(container, name string, blocks []Block) error

PutBlockList saves list of blocks to the specified block blob.

See https://msdn.microsoft.com/en-us/library/azure/dd179467.aspx

func (BlobStorageClient) PutBlockWithLength

func (b BlobStorageClient) PutBlockWithLength(container, name, blockID string, size uint64, blob io.Reader) error

PutBlockWithLength saves the given data stream of exactly specified size to the block blob with given ID. It is an alternative to PutBlocks where data comes as stream but the length is known in advance.

See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx

func (BlobStorageClient) PutPage

func (b BlobStorageClient) PutPage(container, name string, startByte, endByte int64, writeType PageWriteType, chunk []byte) error

PutPage writes a range of pages to a page blob or clears the given range. In case of 'clear' writes, given chunk is discarded. Ranges must be aligned with 512-byte boundaries and chunk must be of size multiplies by 512.

See https://msdn.microsoft.com/en-us/library/ee691975.aspx

func (BlobStorageClient) PutPageBlob

func (b BlobStorageClient) PutPageBlob(container, name string, size int64) error

PutPageBlob initializes an empty page blob with specified name and maximum size in bytes (size must be aligned to a 512-byte boundary). A page blob must be created using this method before writing pages.

See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx

type BlobType

type BlobType string

BlobType defines the type of the Azure Blob.

const (
	BlobTypeBlock BlobType = "BlockBlob"
	BlobTypePage  BlobType = "PageBlob"
)

Types of page blobs

type Block

type Block struct {
	ID     string
	Status BlockStatus
}

Block is used to create Block entities for Put Block List call.

type BlockListResponse

type BlockListResponse struct {
	XMLName           xml.Name        `xml:"BlockList"`
	CommittedBlocks   []BlockResponse `xml:"CommittedBlocks>Block"`
	UncommittedBlocks []BlockResponse `xml:"UncommittedBlocks>Block"`
}

BlockListResponse contains the response fields from Get Block List call.

See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx

type BlockListType

type BlockListType string

BlockListType is used to filter out types of blocks in a Get Blocks List call for a block blob.

See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx for all block types.

const (
	BlockListTypeAll         BlockListType = "all"
	BlockListTypeCommitted   BlockListType = "committed"
	BlockListTypeUncommitted BlockListType = "uncommitted"
)

Filters for listing blocks in block blobs

type BlockResponse

type BlockResponse struct {
	Name string `xml:"Name"`
	Size int64  `xml:"Size"`
}

BlockResponse contains the block information returned in the GetBlockListCall.

type BlockStatus

type BlockStatus string

BlockStatus defines states a block for a block blob can be in.

const (
	BlockStatusUncommitted BlockStatus = "Uncommitted"
	BlockStatusCommitted   BlockStatus = "Committed"
	BlockStatusLatest      BlockStatus = "Latest"
)

List of statuses that can be used to refer to a block in a block list

type Client

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

Client is the object that needs to be constructed to perform operations on the storage account.

func NewBasicClient

func NewBasicClient(accountName, accountKey string) (Client, error)

NewBasicClient constructs a Client with given storage service name and key.

func NewClient

func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error)

NewClient constructs a Client. This should be used if the caller wants to specify whether to use HTTPS, a specific REST API version or a custom storage endpoint than Azure Public Cloud.

func (Client) GetBlobService

func (c Client) GetBlobService() BlobStorageClient

GetBlobService returns a BlobStorageClient which can operate on the blob service of the storage account.

func (Client) GetQueueService

func (c Client) GetQueueService() QueueServiceClient

GetQueueService returns a QueueServiceClient which can operate on the queue service of the storage account.

type Container

type Container struct {
	Name       string              `xml:"Name"`
	Properties ContainerProperties `xml:"Properties"`
}

A Container is an entry in ContainerListResponse.

type ContainerAccessType

type ContainerAccessType string

ContainerAccessType defines the access level to the container from a public request.

See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx and "x-ms- blob-public-access" header.

const (
	ContainerAccessTypePrivate   ContainerAccessType = ""
	ContainerAccessTypeBlob      ContainerAccessType = "blob"
	ContainerAccessTypeContainer ContainerAccessType = "container"
)

Access options for containers

type ContainerListResponse

type ContainerListResponse struct {
	XMLName    xml.Name    `xml:"EnumerationResults"`
	Xmlns      string      `xml:"xmlns,attr"`
	Prefix     string      `xml:"Prefix"`
	Marker     string      `xml:"Marker"`
	NextMarker string      `xml:"NextMarker"`
	MaxResults int64       `xml:"MaxResults"`
	Containers []Container `xml:"Containers>Container"`
}

ContainerListResponse contains the response fields from ListContainers call.

See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx

type ContainerProperties

type ContainerProperties struct {
	LastModified  string `xml:"Last-Modified"`
	Etag          string `xml:"Etag"`
	LeaseStatus   string `xml:"LeaseStatus"`
	LeaseState    string `xml:"LeaseState"`
	LeaseDuration string `xml:"LeaseDuration"`
}

ContainerProperties contains various properties of a container returned from various endpoints like ListContainers.

type GetMessageResponse

type GetMessageResponse struct {
	MessageID       string `xml:"MessageId"`
	InsertionTime   string `xml:"InsertionTime"`
	ExpirationTime  string `xml:"ExpirationTime"`
	PopReceipt      string `xml:"PopReceipt"`
	TimeNextVisible string `xml:"TimeNextVisible"`
	DequeueCount    int    `xml:"DequeueCount"`
	MessageText     string `xml:"MessageText"`
}

GetMessageResponse represents a QueueMessage object returned from Get Messages operation response.

type GetMessagesParameters

type GetMessagesParameters struct {
	NumOfMessages     int
	VisibilityTimeout int
}

GetMessagesParameters is the set of options can be specified for Get Messsages operation. A zero struct does not use any preferences for the request.

type GetMessagesResponse

type GetMessagesResponse struct {
	XMLName           xml.Name             `xml:"QueueMessagesList"`
	QueueMessagesList []GetMessageResponse `xml:"QueueMessage"`
}

GetMessagesResponse represents a response returned from Get Messages operation.

type GetPageRangesResponse

type GetPageRangesResponse struct {
	XMLName  xml.Name    `xml:"PageList"`
	PageList []PageRange `xml:"PageRange"`
}

GetPageRangesResponse contains the reponse fields from Get Page Ranges call.

See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx

type ListBlobsParameters

type ListBlobsParameters struct {
	Prefix     string
	Delimiter  string
	Marker     string
	Include    string
	MaxResults uint
	Timeout    uint
}

ListBlobsParameters defines the set of customizable parameters to make a List Blobs call.

See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx

type ListContainersParameters

type ListContainersParameters struct {
	Prefix     string
	Marker     string
	Include    string
	MaxResults uint
	Timeout    uint
}

ListContainersParameters defines the set of customizable parameters to make a List Containers call.

See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx

type PageRange

type PageRange struct {
	Start int64 `xml:"Start"`
	End   int64 `xml:"End"`
}

PageRange contains information about a page of a page blob from Get Pages Range call.

See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx

type PageWriteType

type PageWriteType string

PageWriteType defines the type updates that are going to be done on the page blob.

const (
	PageWriteTypeUpdate PageWriteType = "update"
	PageWriteTypeClear  PageWriteType = "clear"
)

Types of operations on page blobs

type PeekMessageResponse

type PeekMessageResponse struct {
	MessageID      string `xml:"MessageId"`
	InsertionTime  string `xml:"InsertionTime"`
	ExpirationTime string `xml:"ExpirationTime"`
	DequeueCount   int    `xml:"DequeueCount"`
	MessageText    string `xml:"MessageText"`
}

PeekMessageResponse represents a QueueMessage object returned from Peek Messages operation response.

type PeekMessagesParameters

type PeekMessagesParameters struct {
	NumOfMessages int
}

PeekMessagesParameters is the set of options can be specified for Peek Messsage operation. A zero struct does not use any preferences for the request.

type PeekMessagesResponse

type PeekMessagesResponse struct {
	XMLName           xml.Name              `xml:"QueueMessagesList"`
	QueueMessagesList []PeekMessageResponse `xml:"QueueMessage"`
}

PeekMessagesResponse represents a response returned from Get Messages operation.

type PutMessageParameters

type PutMessageParameters struct {
	VisibilityTimeout int
	MessageTTL        int
}

PutMessageParameters is the set of options can be specified for Put Messsage operation. A zero struct does not use any preferences for the request.

type QueueServiceClient

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

QueueServiceClient contains operations for Microsoft Azure Queue Storage Service.

func (QueueServiceClient) ClearMessages

func (c QueueServiceClient) ClearMessages(queue string) error

ClearMessages operation deletes all messages from the specified queue.

See https://msdn.microsoft.com/en-us/library/azure/dd179454.aspx

func (QueueServiceClient) CreateQueue

func (c QueueServiceClient) CreateQueue(name string) error

CreateQueue operation creates a queue under the given account.

See https://msdn.microsoft.com/en-us/library/azure/dd179342.aspx

func (QueueServiceClient) DeleteMessage

func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) error

DeleteMessage operation deletes the specified message.

See https://msdn.microsoft.com/en-us/library/azure/dd179347.aspx

func (QueueServiceClient) DeleteQueue

func (c QueueServiceClient) DeleteQueue(name string) error

DeleteQueue operation permanently deletes the specified queue.

See https://msdn.microsoft.com/en-us/library/azure/dd179436.aspx

func (QueueServiceClient) GetMessages

GetMessages operation retrieves one or more messages from the front of the queue.

See https://msdn.microsoft.com/en-us/library/azure/dd179474.aspx

func (QueueServiceClient) PeekMessages

PeekMessages retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.

See https://msdn.microsoft.com/en-us/library/azure/dd179472.aspx

func (QueueServiceClient) PutMessage

func (c QueueServiceClient) PutMessage(queue string, message string, params PutMessageParameters) error

PutMessage operation adds a new message to the back of the message queue.

See https://msdn.microsoft.com/en-us/library/azure/dd179346.aspx

func (QueueServiceClient) QueueExists

func (c QueueServiceClient) QueueExists(name string) (bool, error)

QueueExists returns true if a queue with given name exists.

type UnexpectedStatusCodeError

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

UnexpectedStatusCodeError is returned when a storage service responds with neither an error nor with an HTTP status code indicating success.

func (UnexpectedStatusCodeError) Error

Jump to

Keyboard shortcuts

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