storage

package
v5.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

README

Azure Storage SDK for Go

The github.com/Azure/azure-sdk-for-go/storage package is used to perform operations in Azure Storage Service. To manage your storage accounts (Azure Resource Manager / ARM), use the github.com/Azure/azure-sdk-for-go/arm/storage package. For your classic storage accounts (Azure Service Management / ASM), use github.com/Azure/azure-sdk-for-go/management/storageservice package.

This package includes support for Azure Storage Emulator

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 = "2015-02-21"

	// StorageEmulatorAccountName is the fixed storage account used by Azure Storage Emulator
	StorageEmulatorAccountName = "devstoreaccount1"

	// StorageEmulatorAccountKey is the the fixed storage account used by Azure Storage Emulator
	StorageEmulatorAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
)

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 AzureTable

type AzureTable string

AzureTable is the typedef of the Azure Table name

type Blob

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

A Blob is an entry in BlobListResponse.

type BlobHeaders

type BlobHeaders struct {
	ContentMD5      string `header:"x-ms-blob-content-md5"`
	ContentLanguage string `header:"x-ms-blob-content-language"`
	ContentEncoding string `header:"x-ms-blob-content-encoding"`
	ContentType     string `header:"x-ms-blob-content-type"`
	CacheControl    string `header:"x-ms-blob-cache-control"`
}

BlobHeaders contains various properties of a blob and is an entry in SetBlobProperties

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"`

	// BlobPrefix is used to traverse blobs as if it were a file system.
	// It is returned if ListBlobsParameters.Delimiter is specified.
	// The list here can be thought of as "folders" that may contain
	// other folders or blobs.
	BlobPrefixes []string `xml:"Blobs>BlobPrefix>Name"`

	// Delimiter is used to traverse blobs as if it were a file system.
	// It is returned if ListBlobsParameters.Delimiter is specified.
	Delimiter string `xml:"Delimiter"`
}

BlobListResponse contains the response fields from ListBlobs call.

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

type BlobMetadata

type BlobMetadata map[string]string

BlobMetadata is a set of custom name/value pairs.

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

func (BlobMetadata) MarshalXML

func (bm BlobMetadata) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface. It encodes metadata name/value pairs as they would appear in an Azure ListBlobs response.

func (*BlobMetadata) UnmarshalXML

func (bm *BlobMetadata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML converts the xml:Metadata into Metadata map

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"`
	CacheControl          string   `xml:"Cache-Control"`
	ContentLanguage       string   `xml:"Cache-Language"`
	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"`
	LeaseStatus           string   `xml:"LeaseStatus"`
}

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) AppendBlock

func (b BlobStorageClient) AppendBlock(container, name string, chunk []byte, extraHeaders map[string]string) error

AppendBlock appends a block to an append blob.

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

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) CreateBlockBlobFromReader

func (b BlobStorageClient) CreateBlockBlobFromReader(container, name string, size uint64, blob io.Reader, extraHeaders map[string]string) error

CreateBlockBlobFromReader initializes a block blob using data from reader. Size must be the number of bytes read from reader. To create an empty blob, use size==0 and reader==nil.

The API rejects requests with size > 64 MiB (but this limit is not checked by the SDK). To write a larger blob, use CreateBlockBlob, PutBlock, and PutBlockList.

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, extraHeaders map[string]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, extraHeaders map[string]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) GetBlobMetadata

func (b BlobStorageClient) GetBlobMetadata(container, name string) (map[string]string, error)

GetBlobMetadata returns all user-defined metadata for the specified blob.

All metadata keys will be returned in lower case. (HTTP header names are case-insensitive.)

See https://msdn.microsoft.com/en-us/library/azure/dd179414.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, extraHeaders map[string]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) PutAppendBlob

func (b BlobStorageClient) PutAppendBlob(container, name string, extraHeaders map[string]string) error

PutAppendBlob initializes an empty append blob with specified name. An append blob must be created using this method before appending blocks.

See https://msdn.microsoft.com/en-us/library/azure/dd179451.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.

The API rejects chunks larger than 4 MiB (but this limit is not checked by the SDK).

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, extraHeaders map[string]string) 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.

The API rejects requests with size > 4 MiB (but this limit is not checked by the SDK).

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, extraHeaders map[string]string) 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, extraHeaders map[string]string) 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

func (BlobStorageClient) SetBlobMetadata

func (b BlobStorageClient) SetBlobMetadata(container, name string, metadata map[string]string, extraHeaders map[string]string) error

SetBlobMetadata replaces the metadata for the specified blob.

Some keys may be converted to Camel-Case before sending. All keys are returned in lower case by GetBlobMetadata. HTTP header names are case-insensitive so case munging should not matter to other applications either.

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

func (BlobStorageClient) SetBlobProperties

func (b BlobStorageClient) SetBlobProperties(container, name string, blobHeaders BlobHeaders) error

SetBlobProperties replaces the BlobHeaders for the specified blob.

Some keys may be converted to Camel-Case before sending. All keys are returned in lower case by GetBlobProperties. HTTP header names are case-insensitive so case munging should not matter to other applications either.

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

type BlobType

type BlobType string

BlobType defines the type of the Azure Blob.

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

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 {
	// HTTPClient is the http.Client used to initiate API
	// requests.  If it is nil, http.DefaultClient is used.
	HTTPClient *http.Client
	// 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 NewEmulatorClient

func NewEmulatorClient() (Client, error)

NewEmulatorClient contructs a Client intended to only work with Azure Storage Emulator

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) GetFileService

func (c Client) GetFileService() FileServiceClient

GetFileService returns a FileServiceClient which can operate on the file 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.

func (Client) GetTableService

func (c Client) GetTableService() TableServiceClient

GetTableService returns a TableServiceClient which can operate on the table 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 ContinuationToken

type ContinuationToken struct {
	NextPartitionKey string
	NextRowKey       string
}

ContinuationToken is an opaque (ie not useful to inspect) struct that Get... methods can return if there are more entries to be returned than the ones already returned. Just pass it to the same function to continue receiving the remaining entries.

type FileServiceClient

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

FileServiceClient contains operations for Microsoft Azure File Service.

func (FileServiceClient) CreateShare

func (f FileServiceClient) CreateShare(name string) error

CreateShare operation creates a new share under the specified account. If the share with the same name already exists, the operation fails.

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

func (FileServiceClient) CreateShareIfNotExists

func (f FileServiceClient) CreateShareIfNotExists(name string) (bool, error)

CreateShareIfNotExists creates a new share under the specified account if it does not exist. Returns true if container is newly created or false if container already exists.

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

func (FileServiceClient) DeleteShare

func (f FileServiceClient) DeleteShare(name string) error

DeleteShare operation marks the specified share for deletion. The share and any files contained within it are later deleted during garbage collection.

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

func (FileServiceClient) DeleteShareIfExists

func (f FileServiceClient) DeleteShareIfExists(name string) (bool, error)

DeleteShareIfExists operation marks the specified share for deletion if it exists. The share and any files contained within it are later deleted during garbage collection. Returns true if share existed and deleted with this call, false otherwise.

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

func (FileServiceClient) GetShareMetadata

func (f FileServiceClient) GetShareMetadata(name string) (map[string]string, error)

GetShareMetadata returns all user-defined metadata for the specified share.

All metadata keys will be returned in lower case. (HTTP header names are case-insensitive.)

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

func (FileServiceClient) GetShareProperties

func (f FileServiceClient) GetShareProperties(name string) (*ShareProperties, error)

GetShareProperties provides various information about the specified file. See https://msdn.microsoft.com/en-us/library/azure/dn689099.aspx

func (FileServiceClient) GetShareURL

func (f FileServiceClient) GetShareURL(name string) string

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

func (FileServiceClient) ListShares

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

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

func (FileServiceClient) SetShareMetadata

func (f FileServiceClient) SetShareMetadata(name string, metadata map[string]string, extraHeaders map[string]string) error

SetShareMetadata replaces the metadata for the specified Share.

Some keys may be converted to Camel-Case before sending. All keys are returned in lower case by GetShareMetadata. HTTP header names are case-insensitive so case munging should not matter to other applications either.

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

func (FileServiceClient) SetShareProperties

func (f FileServiceClient) SetShareProperties(name string, shareHeaders ShareHeaders) error

SetShareProperties replaces the ShareHeaders for the specified file.

Some keys may be converted to Camel-Case before sending. All keys are returned in lower case by SetShareProperties. HTTP header names are case-insensitive so case munging should not matter to other applications either.

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

func (FileServiceClient) ShareExists

func (f FileServiceClient) ShareExists(name string) (bool, error)

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

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 ListSharesParameters

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

ListSharesParameters defines the set of customizable parameters to make a List Shares call.

See https://msdn.microsoft.com/en-us/library/azure/dn167009.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 QueueMetadataResponse

type QueueMetadataResponse struct {
	ApproximateMessageCount int
	UserDefinedMetadata     map[string]string
}

QueueMetadataResponse represents user defined metadata and queue properties on a specific queue.

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

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) GetMetadata

func (c QueueServiceClient) GetMetadata(name string) (QueueMetadataResponse, error)

GetMetadata operation retrieves user-defined metadata and queue properties on the specified queue. Metadata is associated with the queue as name-values pairs.

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

Because the way Golang's http client (and http.Header in particular) canonicalize header names, the returned metadata names would always be all lower case.

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.

func (QueueServiceClient) SetMetadata

func (c QueueServiceClient) SetMetadata(name string, metadata map[string]string) error

SetMetadata operation sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs.

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

type Share

type Share struct {
	Name       string          `xml:"Name"`
	Properties ShareProperties `xml:"Properties"`
}

A Share is an entry in ShareListResponse.

type ShareHeaders

type ShareHeaders struct {
	Quota string `header:"x-ms-share-quota"`
}

ShareHeaders contains various properties of a file and is an entry in SetShareProperties

type ShareListResponse

type ShareListResponse 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"`
	Shares     []Share  `xml:"Shares>Share"`
}

ShareListResponse contains the response fields from ListShares call.

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

type ShareProperties

type ShareProperties struct {
	LastModified string `xml:"Last-Modified"`
	Etag         string `xml:"Etag"`
	Quota        string `xml:"Quota"`
}

ShareProperties contains various properties of a share returned from various endpoints like ListShares.

type TableEntity

type TableEntity interface {
	PartitionKey() string
	RowKey() string
	SetPartitionKey(string) error
	SetRowKey(string) error
}

TableEntity interface specifies the functions needed to support marshaling and unmarshaling into Azure Tables. The struct must only contain simple types because Azure Tables do not support hierarchy.

type TableServiceClient

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

TableServiceClient contains operations for Microsoft Azure Table Storage Service.

func (*TableServiceClient) CreateTable

func (c *TableServiceClient) CreateTable(table AzureTable) error

CreateTable creates the table given the specific name. This function fails if the name is not compliant with the specification or the tables already exists.

func (*TableServiceClient) DeleteEntity

func (c *TableServiceClient) DeleteEntity(table AzureTable, entity TableEntity, ifMatch string) error

DeleteEntity deletes the entity matching by PartitionKey, RowKey and ifMatch field. The function fails if there is no entity with the same PartitionKey and RowKey in the table or the ifMatch is different.

func (*TableServiceClient) DeleteEntityWithoutCheck

func (c *TableServiceClient) DeleteEntityWithoutCheck(table AzureTable, entity TableEntity) error

DeleteEntityWithoutCheck deletes the entity matching by PartitionKey and RowKey. There is no check on IfMatch parameter so the entity is always deleted. The function fails if there is no entity with the same PartitionKey and RowKey in the table.

func (*TableServiceClient) DeleteTable

func (c *TableServiceClient) DeleteTable(table AzureTable) error

DeleteTable deletes the table given the specific name. This function fails if the table is not present. Be advised: DeleteTable deletes all the entries that may be present.

func (*TableServiceClient) InsertEntity

func (c *TableServiceClient) InsertEntity(table AzureTable, entity TableEntity) error

InsertEntity inserts an entity in the specified table. The function fails if there is an entity with the same PartitionKey and RowKey in the table.

func (*TableServiceClient) InsertOrMergeEntity

func (c *TableServiceClient) InsertOrMergeEntity(table AzureTable, entity TableEntity) error

InsertOrMergeEntity inserts an entity in the specified table or merges the existing one.

func (*TableServiceClient) InsertOrReplaceEntity

func (c *TableServiceClient) InsertOrReplaceEntity(table AzureTable, entity TableEntity) error

InsertOrReplaceEntity inserts an entity in the specified table or replaced the existing one.

func (*TableServiceClient) MergeEntity

func (c *TableServiceClient) MergeEntity(table AzureTable, entity TableEntity) error

MergeEntity merges the contents of an entity with the one passed as parameter. The function fails if there is no entity with the same PartitionKey and RowKey in the table.

func (*TableServiceClient) QueryTableEntities

func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousContToken *ContinuationToken, retType reflect.Type, top int, query string) ([]TableEntity, *ContinuationToken, error)

QueryTableEntities queries the specified table and returns the unmarshaled entities of type retType. top parameter limits the returned entries up to top. Maximum top allowed by Azure API is 1000. In case there are more than top entries to be returned the function will return a non nil *ContinuationToken. You can call the same function again passing the received ContinuationToken as previousContToken parameter in order to get the following entries. The query parameter is the odata query. To retrieve all the entries pass the empty string. The function returns a pointer to a TableEntity slice, the *ContinuationToken if there are more entries to be returned and an error in case something went wrong.

Example:

entities, cToken, err = tSvc.QueryTableEntities("table", cToken, reflect.TypeOf(entity), 20, "")

func (*TableServiceClient) QueryTables

func (c *TableServiceClient) QueryTables() ([]AzureTable, error)

QueryTables returns the tables created in the *TableServiceClient storage account.

func (*TableServiceClient) UpdateEntity

func (c *TableServiceClient) UpdateEntity(table AzureTable, entity TableEntity) error

UpdateEntity updates the contents of an entity with the one passed as parameter. The function fails if there is no entity with the same PartitionKey and RowKey in the table.

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

func (UnexpectedStatusCodeError) Got

Got is the actual status code returned by Azure.

Jump to

Keyboard shortcuts

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