containers

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

Blob Storage Container SDK for API version 2018-11-09

This package allows you to interact with the Containers Blob Storage API

Supported Authorizers

  • Azure Active Directory (for the Resource Endpoint https://storage.azure.com)
  • SharedKeyLite (Blob, File & Queue)

Note: when using the ListBlobs operation, only SharedKeyLite authentication is supported.

Example Usage

package main

import (
	"context"
	"fmt"
	"time"
	
	"github.com/Azure/go-autorest/autorest"
	"github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    containerName := "mycontainer"
    
    storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
    containersClient := containers.New()
    containersClient.Client.Authorizer = storageAuth
    
    ctx := context.TODO()
    createInput := containers.CreateInput{
        AccessLevel: containers.Private,
    }
    if _, err := containersClient.Create(ctx, accountName, containerName, createInput); err != nil {
        return fmt.Errorf("Error creating Container: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

View Source
const APIVersion = "2018-11-09"

APIVersion is the version of the API used for all Storage API Operations

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

Types

type AccessLevel

type AccessLevel string
var (
	// Blob specifies public read access for blobs.
	// Blob data within this container can be read via anonymous request,
	// but container data is not available.
	// Clients cannot enumerate blobs within the container via anonymous request.
	Blob AccessLevel = "blob"

	// Container specifies full public read access for container and blob data.
	// Clients can enumerate blobs within the container via anonymous request,
	// but cannot enumerate containers within the storage account.
	Container AccessLevel = "container"

	// Private specifies that container data is private to the account owner
	Private AccessLevel = ""
)

type AcquireLeaseInput

type AcquireLeaseInput struct {
	// Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires.
	// A non-infinite lease can be between 15 and 60 seconds
	LeaseDuration int

	ProposedLeaseID string
}

type AcquireLeaseResponse

type AcquireLeaseResponse struct {
	autorest.Response

	LeaseID string
}

type BlobDetails

type BlobDetails struct {
	Name       string                 `xml:"Name"`
	Deleted    bool                   `xml:"Deleted,omitempty"`
	MetaData   map[string]interface{} `map:"Metadata,omitempty"`
	Properties *BlobProperties        `xml:"Properties,omitempty"`
	Snapshot   *string                `xml:"Snapshot,omitempty"`
}

type BlobPrefix

type BlobPrefix struct {
	Name string `xml:"Name"`
}

type BlobProperties

type BlobProperties struct {
	AccessTier             *string `xml:"AccessTier,omitempty"`
	AccessTierInferred     *bool   `xml:"AccessTierInferred,omitempty"`
	AccessTierChangeTime   *string `xml:"AccessTierChangeTime,omitempty"`
	BlobType               *string `xml:"BlobType,omitempty"`
	BlobSequenceNumber     *string `xml:"x-ms-blob-sequence-number,omitempty"`
	CacheControl           *string `xml:"Cache-Control,omitempty"`
	ContentEncoding        *string `xml:"ContentEncoding,omitempty"`
	ContentLanguage        *string `xml:"Content-Language,omitempty"`
	ContentLength          *int64  `xml:"Content-Length,omitempty"`
	ContentMD5             *string `xml:"Content-MD5,omitempty"`
	ContentType            *string `xml:"Content-Type,omitempty"`
	CopyCompletionTime     *string `xml:"CopyCompletionTime,omitempty"`
	CopyId                 *string `xml:"CopyId,omitempty"`
	CopyStatus             *string `xml:"CopyStatus,omitempty"`
	CopySource             *string `xml:"CopySource,omitempty"`
	CopyProgress           *string `xml:"CopyProgress,omitempty"`
	CopyStatusDescription  *string `xml:"CopyStatusDescription,omitempty"`
	CreationTime           *string `xml:"CreationTime,omitempty"`
	ETag                   *string `xml:"Etag,omitempty"`
	DeletedTime            *string `xml:"DeletedTime,omitempty"`
	IncrementalCopy        *bool   `xml:"IncrementalCopy,omitempty"`
	LastModified           *string `xml:"Last-Modified,omitempty"`
	LeaseDuration          *string `xml:"LeaseDuration,omitempty"`
	LeaseState             *string `xml:"LeaseState,omitempty"`
	LeaseStatus            *string `xml:"LeaseStatus,omitempty"`
	RemainingRetentionDays *string `xml:"RemainingRetentionDays,omitempty"`
	ServerEncrypted        *bool   `xml:"ServerEncrypted,omitempty"`
}

type Blobs

type Blobs struct {
	Blobs      []BlobDetails `xml:"Blob"`
	BlobPrefix *BlobPrefix   `xml:"BlobPrefix"`
}

type BreakLeaseInput

type BreakLeaseInput struct {
	//  For a break operation, proposed duration the lease should continue
	//  before it is broken, in seconds, between 0 and 60.
	//  This break period is only used if it is shorter than the time remaining on the lease.
	//  If longer, the time remaining on the lease is used.
	//  A new lease will not be available before the break period has expired,
	//  but the lease may be held for longer than the break period.
	//  If this header does not appear with a break operation, a fixed-duration lease breaks
	//  after the remaining lease period elapses, and an infinite lease breaks immediately.
	BreakPeriod *int

	LeaseID string
}

type BreakLeaseResponse

type BreakLeaseResponse struct {
	autorest.Response

	// Approximate time remaining in the lease period, in seconds.
	// If the break is immediate, 0 is returned.
	LeaseTime int
}

type ChangeLeaseInput

type ChangeLeaseInput struct {
	ExistingLeaseID string
	ProposedLeaseID string
}

type ChangeLeaseResponse

type ChangeLeaseResponse struct {
	autorest.Response

	LeaseID string
}

type Client

type Client struct {
	autorest.Client
	BaseURI string
}

Client is the base client for Blob Storage Containers.

func New

func New() Client

New creates an instance of the Client client.

func NewWithEnvironment

func NewWithEnvironment(environment azure.Environment) Client

NewWithBaseURI creates an instance of the Client client.

func (Client) AcquireLease

func (client Client) AcquireLease(ctx context.Context, accountName, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error)

AcquireLease establishes and manages a lock on a container for delete operations.

func (Client) AcquireLeasePreparer

func (client Client) AcquireLeasePreparer(ctx context.Context, accountName string, containerName string, input AcquireLeaseInput) (*http.Request, error)

AcquireLeasePreparer prepares the AcquireLease request.

func (Client) AcquireLeaseResponder

func (client Client) AcquireLeaseResponder(resp *http.Response) (result AcquireLeaseResponse, err error)

AcquireLeaseResponder handles the response to the AcquireLease request. The method always closes the http.Response Body.

func (Client) AcquireLeaseSender

func (client Client) AcquireLeaseSender(req *http.Request) (*http.Response, error)

AcquireLeaseSender sends the AcquireLease request. The method will close the http.Response Body if it receives an error.

func (Client) BreakLease

func (client Client) BreakLease(ctx context.Context, accountName, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error)

BreakLease breaks a lock based on it's Lease ID

func (Client) BreakLeasePreparer

func (client Client) BreakLeasePreparer(ctx context.Context, accountName string, containerName string, input BreakLeaseInput) (*http.Request, error)

BreakLeasePreparer prepares the BreakLease request.

func (Client) BreakLeaseResponder

func (client Client) BreakLeaseResponder(resp *http.Response) (result BreakLeaseResponse, err error)

BreakLeaseResponder handles the response to the BreakLease request. The method always closes the http.Response Body.

func (Client) BreakLeaseSender

func (client Client) BreakLeaseSender(req *http.Request) (*http.Response, error)

BreakLeaseSender sends the BreakLease request. The method will close the http.Response Body if it receives an error.

func (Client) ChangeLease

func (client Client) ChangeLease(ctx context.Context, accountName, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error)

ChangeLease changes the lock from one Lease ID to another Lease ID

func (Client) ChangeLeasePreparer

func (client Client) ChangeLeasePreparer(ctx context.Context, accountName string, containerName string, input ChangeLeaseInput) (*http.Request, error)

ChangeLeasePreparer prepares the ChangeLease request.

func (Client) ChangeLeaseResponder

func (client Client) ChangeLeaseResponder(resp *http.Response) (result ChangeLeaseResponse, err error)

ChangeLeaseResponder handles the response to the ChangeLease request. The method always closes the http.Response Body.

func (Client) ChangeLeaseSender

func (client Client) ChangeLeaseSender(req *http.Request) (*http.Response, error)

ChangeLeaseSender sends the ChangeLease request. The method will close the http.Response Body if it receives an error.

func (Client) Create

func (client Client) Create(ctx context.Context, accountName, containerName string, input CreateInput) (result CreateResponse, err error)

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

func (Client) CreatePreparer

func (client Client) CreatePreparer(ctx context.Context, accountName string, containerName string, input CreateInput) (*http.Request, error)

CreatePreparer prepares the Create request.

func (Client) CreateResponder

func (client Client) CreateResponder(resp *http.Response) (result CreateResponse, err error)

CreateResponder handles the response to the Create request. The method always closes the http.Response Body.

func (Client) CreateSender

func (client Client) CreateSender(req *http.Request) (*http.Response, error)

CreateSender sends the Create request. The method will close the http.Response Body if it receives an error.

func (Client) Delete

func (client Client) Delete(ctx context.Context, accountName, containerName string) (result autorest.Response, err error)

Delete marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.

func (Client) DeletePreparer

func (client Client) DeletePreparer(ctx context.Context, accountName string, containerName string) (*http.Request, error)

DeletePreparer prepares the Delete request.

func (Client) DeleteResponder

func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error)

DeleteResponder handles the response to the Delete request. The method always closes the http.Response Body.

func (Client) DeleteSender

func (client Client) DeleteSender(req *http.Request) (*http.Response, error)

DeleteSender sends the Delete request. The method will close the http.Response Body if it receives an error.

func (Client) GetProperties

func (client Client) GetProperties(ctx context.Context, accountName, containerName string) (ContainerProperties, error)

GetProperties returns the properties for this Container without a Lease

func (Client) GetPropertiesWithLeaseID

func (client Client) GetPropertiesWithLeaseID(ctx context.Context, accountName, containerName, leaseID string) (result ContainerProperties, err error)

GetPropertiesWithLeaseID returns the properties for this Container using the specified LeaseID

func (Client) GetPropertiesWithLeaseIDPreparer

func (client Client) GetPropertiesWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string) (*http.Request, error)

GetPropertiesWithLeaseIDPreparer prepares the GetPropertiesWithLeaseID request.

func (Client) GetPropertiesWithLeaseIDResponder

func (client Client) GetPropertiesWithLeaseIDResponder(resp *http.Response) (result ContainerProperties, err error)

GetPropertiesWithLeaseIDResponder handles the response to the GetPropertiesWithLeaseID request. The method always closes the http.Response Body.

func (Client) GetPropertiesWithLeaseIDSender

func (client Client) GetPropertiesWithLeaseIDSender(req *http.Request) (*http.Response, error)

GetPropertiesWithLeaseIDSender sends the GetPropertiesWithLeaseID request. The method will close the http.Response Body if it receives an error.

func (Client) GetResourceID

func (client Client) GetResourceID(accountName, containerName string) string

GetResourceID returns the Resource ID for the given Container This can be useful when, for example, you're using this as a unique identifier

func (Client) GetResourceManagerResourceID added in v0.10.0

func (client Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string

GetResourceManagerResourceID returns the Resource Manager specific ResourceID for a specific Storage Container

func (Client) ListBlobs

func (client Client) ListBlobs(ctx context.Context, accountName, containerName string, input ListBlobsInput) (result ListBlobsResult, err error)

ListBlobs lists the blobs matching the specified query within the specified Container

func (Client) ListBlobsPreparer

func (client Client) ListBlobsPreparer(ctx context.Context, accountName, containerName string, input ListBlobsInput) (*http.Request, error)

ListBlobsPreparer prepares the ListBlobs request.

func (Client) ListBlobsResponder

func (client Client) ListBlobsResponder(resp *http.Response) (result ListBlobsResult, err error)

ListBlobsResponder handles the response to the ListBlobs request. The method always closes the http.Response Body.

func (Client) ListBlobsSender

func (client Client) ListBlobsSender(req *http.Request) (*http.Response, error)

ListBlobsSender sends the ListBlobs request. The method will close the http.Response Body if it receives an error.

func (Client) ReleaseLease

func (client Client) ReleaseLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error)

ReleaseLease releases the lock based on the Lease ID

func (Client) ReleaseLeasePreparer

func (client Client) ReleaseLeasePreparer(ctx context.Context, accountName string, containerName string, leaseID string) (*http.Request, error)

ReleaseLeasePreparer prepares the ReleaseLease request.

func (Client) ReleaseLeaseResponder

func (client Client) ReleaseLeaseResponder(resp *http.Response) (result autorest.Response, err error)

ReleaseLeaseResponder handles the response to the ReleaseLease request. The method always closes the http.Response Body.

func (Client) ReleaseLeaseSender

func (client Client) ReleaseLeaseSender(req *http.Request) (*http.Response, error)

ReleaseLeaseSender sends the ReleaseLease request. The method will close the http.Response Body if it receives an error.

func (Client) RenewLease

func (client Client) RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error)

RenewLease renews the lock based on the Lease ID

func (Client) RenewLeasePreparer

func (client Client) RenewLeasePreparer(ctx context.Context, accountName string, containerName string, leaseID string) (*http.Request, error)

RenewLeasePreparer prepares the RenewLease request.

func (Client) RenewLeaseResponder

func (client Client) RenewLeaseResponder(resp *http.Response) (result autorest.Response, err error)

RenewLeaseResponder handles the response to the RenewLease request. The method always closes the http.Response Body.

func (Client) RenewLeaseSender

func (client Client) RenewLeaseSender(req *http.Request) (*http.Response, error)

RenewLeaseSender sends the RenewLease request. The method will close the http.Response Body if it receives an error.

func (Client) SetAccessControl

func (client Client) SetAccessControl(ctx context.Context, accountName, containerName string, level AccessLevel) (autorest.Response, error)

SetAccessControl sets the Access Control for a Container without a Lease ID

func (Client) SetAccessControlWithLeaseID

func (client Client) SetAccessControlWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (result autorest.Response, err error)

SetAccessControlWithLeaseID sets the Access Control for a Container using the specified Lease ID

func (Client) SetAccessControlWithLeaseIDPreparer

func (client Client) SetAccessControlWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (*http.Request, error)

SetAccessControlWithLeaseIDPreparer prepares the SetAccessControlWithLeaseID request.

func (Client) SetAccessControlWithLeaseIDResponder

func (client Client) SetAccessControlWithLeaseIDResponder(resp *http.Response) (result autorest.Response, err error)

SetAccessControlWithLeaseIDResponder handles the response to the SetAccessControlWithLeaseID request. The method always closes the http.Response Body.

func (Client) SetAccessControlWithLeaseIDSender

func (client Client) SetAccessControlWithLeaseIDSender(req *http.Request) (*http.Response, error)

SetAccessControlWithLeaseIDSender sends the SetAccessControlWithLeaseID request. The method will close the http.Response Body if it receives an error.

func (Client) SetMetaData

func (client Client) SetMetaData(ctx context.Context, accountName, containerName string, metaData map[string]string) (autorest.Response, error)

SetMetaData sets the specified MetaData on the Container without a Lease ID

func (Client) SetMetaDataWithLeaseID

func (client Client) SetMetaDataWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (result autorest.Response, err error)

SetMetaDataWithLeaseID sets the specified MetaData on the Container using the specified Lease ID

func (Client) SetMetaDataWithLeaseIDPreparer

func (client Client) SetMetaDataWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (*http.Request, error)

SetMetaDataWithLeaseIDPreparer prepares the SetMetaDataWithLeaseID request.

func (Client) SetMetaDataWithLeaseIDResponder

func (client Client) SetMetaDataWithLeaseIDResponder(resp *http.Response) (result autorest.Response, err error)

SetMetaDataWithLeaseIDResponder handles the response to the SetMetaDataWithLeaseID request. The method always closes the http.Response Body.

func (Client) SetMetaDataWithLeaseIDSender

func (client Client) SetMetaDataWithLeaseIDSender(req *http.Request) (*http.Response, error)

SetMetaDataWithLeaseIDSender sends the SetMetaDataWithLeaseID request. The method will close the http.Response Body if it receives an error.

type ContainerProperties

type ContainerProperties struct {
	autorest.Response

	AccessLevel           AccessLevel
	LeaseStatus           LeaseStatus
	LeaseState            LeaseState
	LeaseDuration         *LeaseDuration
	MetaData              map[string]string
	HasImmutabilityPolicy bool
	HasLegalHold          bool
}

type CreateInput

type CreateInput struct {
	// Specifies whether data in the container may be accessed publicly and the level of access
	AccessLevel AccessLevel

	// A name-value pair to associate with the container as metadata.
	MetaData map[string]string
}

type CreateResponse

type CreateResponse struct {
	autorest.Response
	Error *ErrorResponse `xml:"Error"`
}

type Dataset

type Dataset string
var (
	Copy             Dataset = "copy"
	Deleted          Dataset = "deleted"
	MetaData         Dataset = "metadata"
	Snapshots        Dataset = "snapshots"
	UncommittedBlobs Dataset = "uncommittedblobs"
)

type ErrorResponse

type ErrorResponse struct {
	Code    *string `xml:"Code"`
	Message *string `xml:"Message"`
}

type LeaseDuration

type LeaseDuration string
var (
	// If this lease is for a Fixed Duration
	Fixed LeaseDuration = "fixed"

	// If this lease is for an Indefinite Duration
	Infinite LeaseDuration = "infinite"
)

type LeaseState

type LeaseState string
var (
	Available LeaseState = "available"
	Breaking  LeaseState = "breaking"
	Broken    LeaseState = "broken"
	Expired   LeaseState = "expired"
	Leased    LeaseState = "leased"
)

type LeaseStatus

type LeaseStatus string
var (
	Locked   LeaseStatus = "locked"
	Unlocked LeaseStatus = "unlocked"
)

type ListBlobsInput

type ListBlobsInput struct {
	Delimiter  *string
	Include    *[]Dataset
	Marker     *string
	MaxResults *int
	Prefix     *string
}

type ListBlobsResult

type ListBlobsResult struct {
	autorest.Response

	Delimiter  string  `xml:"Delimiter"`
	Marker     string  `xml:"Marker"`
	MaxResults int     `xml:"MaxResults"`
	NextMarker *string `xml:"NextMarker,omitempty"`
	Prefix     string  `xml:"Prefix"`
	Blobs      Blobs   `xml:"Blobs"`
}

type ResourceID

type ResourceID struct {
	AccountName   string
	ContainerName string
}

func ParseResourceID added in v0.2.0

func ParseResourceID(id string) (*ResourceID, error)

ParseResourceID parses the Resource ID and returns an object which can be used to interact with the Container Resource

type StorageContainer added in v0.11.0

type StorageContainer interface {
	Create(ctx context.Context, accountName, containerName string, input CreateInput) (result CreateResponse, err error)
	Delete(ctx context.Context, accountName, containerName string) (result autorest.Response, err error)
	GetProperties(ctx context.Context, accountName, containerName string) (ContainerProperties, error)
	GetPropertiesWithLeaseID(ctx context.Context, accountName, containerName, leaseID string) (result ContainerProperties, err error)
	AcquireLease(ctx context.Context, accountName, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error)
	BreakLease(ctx context.Context, accountName, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error)
	ChangeLease(ctx context.Context, accountName, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error)
	ReleaseLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error)
	RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error)
	ListBlobs(ctx context.Context, accountName, containerName string, input ListBlobsInput) (result ListBlobsResult, err error)
	GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string
	SetAccessControl(ctx context.Context, accountName, containerName string, level AccessLevel) (autorest.Response, error)
	SetAccessControlWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (result autorest.Response, err error)
	SetMetaData(ctx context.Context, accountName, containerName string, metaData map[string]string) (autorest.Response, error)
	SetMetaDataWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (result autorest.Response, err error)
}

Jump to

Keyboard shortcuts

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