container

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 18 Imported by: 112

Documentation

Overview

Example (Container_ClientCreate)
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	containerCreateResponse, err := containerClient.Create(context.TODO(), &container.CreateOptions{
		Metadata: map[string]string{"Foo": "Bar"},
	})
	handleError(err)
	fmt.Println(containerCreateResponse)
}
Output:

Example (Container_ClientDelete)
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	containerDeleteResponse, err := containerClient.Delete(context.TODO(), nil)
	handleError(err)
	fmt.Println(containerDeleteResponse)
}
Output:

Example (Container_ClientGetSASURL)
package main

import (
	"fmt"
	"log"
	"os"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	permission := sas.ContainerPermissions{Read: true}
	start := time.Now()
	expiry := start.AddDate(1, 0, 0)
	sasURL, err := containerClient.GetSASURL(permission, start, expiry)
	handleError(err)
	_ = sasURL
}
Output:

Example (Container_ClientListBlobsFlat)
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	pager := containerClient.NewListBlobsFlatPager(&container.ListBlobsFlatOptions{
		Include: container.ListBlobsInclude{Snapshots: true, Versions: true},
	})

	for pager.More() {
		resp, err := pager.NextPage(context.TODO())
		if err != nil {
			log.Fatal(err)
		}
		for _, blob := range resp.Segment.BlobItems {
			fmt.Println(*blob.Name)
		}
	}
}
Output:

Example (Container_ClientListBlobsHierarchy)
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	maxResults := int32(5)
	pager := containerClient.NewListBlobsHierarchyPager("/", &container.ListBlobsHierarchyOptions{
		Include:    container.ListBlobsInclude{Metadata: true, Tags: true},
		MaxResults: &maxResults,
	})

	for pager.More() {
		resp, err := pager.NextPage(context.TODO())
		if err != nil {
			log.Fatal(err)
		}
		for _, blob := range resp.ListBlobsHierarchySegmentResponse.Segment.BlobItems {
			fmt.Println(*blob.Name)
		}
	}
}
Output:

Example (Container_ClientNewAppendBlobClient)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	appendBlobClient := containerClient.NewAppendBlobClient("test_append_blob")
	handleError(err)
	fmt.Println(appendBlobClient.URL())
}
Output:

Example (Container_ClientNewBlobClient)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	blobClient := containerClient.NewBlobClient("test_blob")
	handleError(err)
	fmt.Println(blobClient.URL())
}
Output:

Example (Container_ClientNewBlockBlobClient)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	blockBlobClient := containerClient.NewBlockBlobClient("test_block_blob")
	handleError(err)
	fmt.Println(blockBlobClient.URL())
}
Output:

Example (Container_ClientNewPageBlobClient)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	pageBlobClient := containerClient.NewPageBlobClient("test_page_blob")
	handleError(err)
	fmt.Println(pageBlobClient.URL())
}
Output:

Example (Container_ClientSetAccessPolicy)

This example shows how to manipulate a container's permissions.

package main

import (
	"bytes"
	"context"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
	"strings"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	// Create the container
	_, err = containerClient.Create(context.TODO(), nil)
	handleError(err)

	// Upload a simple blob.
	blockBlobClient := containerClient.NewBlockBlobClient("HelloWorld.txt")
	handleError(err)

	_, err = blockBlobClient.Upload(context.TODO(), streaming.NopCloser(strings.NewReader("Hello World!")), nil)
	handleError(err)

	// Attempt to read the blob
	get, err := http.Get(blockBlobClient.URL())
	handleError(err)
	if get.StatusCode == http.StatusNotFound {
		// ChangeLease the blob to be public access blob
		_, err := containerClient.SetAccessPolicy(
			context.TODO(),
			nil,
			&container.SetAccessPolicyOptions{
				Access: to.Ptr(container.PublicAccessTypeBlob),
			},
		)
		if err != nil {
			log.Fatal(err)
		}

		// Now, this works
		get, err = http.Get(blockBlobClient.URL())
		if err != nil {
			log.Fatal(err)
		}
		var text bytes.Buffer
		_, err = text.ReadFrom(get.Body)
		if err != nil {
			return
		}
		defer func(Body io.ReadCloser) {
			_ = Body.Close()
		}(get.Body)

		fmt.Println("Public access blob data: ", text.String())
	}
}
Output:

Example (Container_ClientSetMetadata)
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)

	// Create a container with some metadata, key names are converted to lowercase before being sent to the service.
	// You should always use lowercase letters, especially when querying a map for a metadata key.
	creatingApp, err := os.Executable()
	handleError(err)
	_, err = containerClient.Create(context.TODO(), &container.CreateOptions{Metadata: map[string]string{"author": "azblob", "app": creatingApp}})
	handleError(err)

	// Query the container's metadata
	containerGetPropertiesResponse, err := containerClient.GetProperties(context.TODO(), nil)
	handleError(err)

	if containerGetPropertiesResponse.Metadata == nil {
		log.Fatal("metadata is empty!")
	}

	for k, v := range containerGetPropertiesResponse.Metadata {
		fmt.Printf("%s=%s\n", k, v)
	}

	// Update the metadata and write it back to the container
	containerGetPropertiesResponse.Metadata["author"] = "Mohit"
	_, err = containerClient.SetMetadata(context.TODO(), &container.SetMetadataOptions{Metadata: containerGetPropertiesResponse.Metadata})
	handleError(err)

	// NOTE: SetMetadata & SetProperties methods update the container's ETag & LastModified properties
}
Output:

Example (Container_NewClient)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	containerClient, err := container.NewClient(containerURL, cred, nil)
	handleError(err)
	fmt.Println(containerClient.URL())
}
Output:

Example (Container_NewClientFromConnectionString)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	// Your connection string can be obtained from the Azure Portal.
	connectionString, ok := os.LookupEnv("AZURE_STORAGE_CONNECTION_STRING")
	if !ok {
		log.Fatal("the environment variable 'AZURE_STORAGE_CONNECTION_STRING' could not be found")
	}
	containerName := "testcontainer"
	containerClient, err := container.NewClientFromConnectionString(connectionString, containerName, nil)
	handleError(err)
	fmt.Println(containerClient.URL())
}
Output:

Example (Container_NewClientWithNoCredential)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	sharedAccessSignature, ok := os.LookupEnv("AZURE_STORAGE_SHARED_ACCESS_SIGNATURE")
	if !ok {
		panic("AZURE_STORAGE_SHARED_ACCESS_SIGNATURE could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s?%s", accountName, containerName, sharedAccessSignature)

	containerClient, err := container.NewClientWithNoCredential(containerURL, nil)
	handleError(err)
	fmt.Println(containerClient.URL())
}
Output:

Example (Container_NewClientWithSharedKeyCredential)
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	accountKey, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_KEY")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_KEY could not be found")
	}
	containerName := "testcontainer"
	containerURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName)

	cred, err := azblob.NewSharedKeyCredential(accountName, accountKey)
	handleError(err)
	containerClient, err := container.NewClientWithSharedKeyCredential(containerURL, cred, nil)
	handleError(err)
	fmt.Println(containerClient.URL())
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessConditions

type AccessConditions = exported.ContainerAccessConditions

AccessConditions identifies container-specific access conditions which you optionally set.

type AccessPolicy

type AccessPolicy = generated.AccessPolicy

AccessPolicy - An Access policy

type AccessPolicyPermission

type AccessPolicyPermission = exported.AccessPolicyPermission

AccessPolicyPermission type simplifies creating the permissions string for a container's access policy. Initialize an instance of this type and then call its String method to set AccessPolicy's Permission field.

type AccessTier added in v0.6.0

type AccessTier = generated.AccessTier

AccessTier defines values for blob access tiers.

func PossibleAccessTierValues added in v0.6.0

func PossibleAccessTierValues() []AccessTier

PossibleAccessTierValues returns the possible values for the AccessTier const type.

type AccountKind

type AccountKind = generated.AccountKind

AccountKind defines values for AccountKind

const (
	AccountKindStorage          AccountKind = generated.AccountKindStorage
	AccountKindBlobStorage      AccountKind = generated.AccountKindBlobStorage
	AccountKindStorageV2        AccountKind = generated.AccountKindStorageV2
	AccountKindFileStorage      AccountKind = generated.AccountKindFileStorage
	AccountKindBlockBlobStorage AccountKind = generated.AccountKindBlockBlobStorage
)

func PossibleAccountKindValues

func PossibleAccountKindValues() []AccountKind

PossibleAccountKindValues returns the possible values for the AccountKind const type.

type ArchiveStatus

type ArchiveStatus = generated.ArchiveStatus

ArchiveStatus defines values for ArchiveStatus

const (
	ArchiveStatusRehydratePendingToCool ArchiveStatus = generated.ArchiveStatusRehydratePendingToCool
	ArchiveStatusRehydratePendingToHot  ArchiveStatus = generated.ArchiveStatusRehydratePendingToHot
)

func PossibleArchiveStatusValues

func PossibleArchiveStatusValues() []ArchiveStatus

PossibleArchiveStatusValues returns the possible values for the ArchiveStatus const type.

type BlobItem

type BlobItem = generated.BlobItem

BlobItem - An Azure Storage blob

type BlobPrefix added in v0.6.0

type BlobPrefix = generated.BlobPrefix

BlobPrefix is a blob's prefix when hierarchically listing blobs.

type BlobProperties

type BlobProperties = generated.BlobProperties

BlobProperties - Properties of a blob

type BlobTag added in v0.6.0

type BlobTag = generated.BlobTag

BlobTag - a key/value pair on a blob

type BlobType

type BlobType = generated.BlobType

BlobType defines values for BlobType

const (
	BlobTypeBlockBlob  BlobType = generated.BlobTypeBlockBlob
	BlobTypePageBlob   BlobType = generated.BlobTypePageBlob
	BlobTypeAppendBlob BlobType = generated.BlobTypeAppendBlob
)

func PossibleBlobTypeValues

func PossibleBlobTypeValues() []BlobType

PossibleBlobTypeValues returns the possible values for the BlobType const type.

type Client

Client represents a URL to the Azure Storage container allowing you to manipulate its blobs.

func NewClient

func NewClient(containerURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates an instance of Client with the specified values.

  • containerURL - the URL of the container e.g. https://<account>.blob.core.windows.net/container
  • cred - an Azure AD credential, typically obtained via the azidentity module
  • options - client options; pass nil to accept the default values

func NewClientFromConnectionString

func NewClientFromConnectionString(connectionString string, containerName string, options *ClientOptions) (*Client, error)

NewClientFromConnectionString creates an instance of Client with the specified values.

  • connectionString - a connection string for the desired storage account
  • containerName - the name of the container within the storage account
  • options - client options; pass nil to accept the default values

func NewClientWithNoCredential

func NewClientWithNoCredential(containerURL string, options *ClientOptions) (*Client, error)

NewClientWithNoCredential creates an instance of Client with the specified values. This is used to anonymously access a container or with a shared access signature (SAS) token.

  • containerURL - the URL of the container e.g. https://<account>.blob.core.windows.net/container?<sas token>
  • options - client options; pass nil to accept the default values

func NewClientWithSharedKeyCredential

func NewClientWithSharedKeyCredential(containerURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error)

NewClientWithSharedKeyCredential creates an instance of Client with the specified values.

  • containerURL - the URL of the container e.g. https://<account>.blob.core.windows.net/container
  • cred - a SharedKeyCredential created with the matching container's storage account and access key
  • options - client options; pass nil to accept the default values

func (*Client) Create

func (c *Client) Create(ctx context.Context, options *CreateOptions) (CreateResponse, error)

Create creates a new container within a storage account. If a container with the same name already exists, the operation fails. For more information, see https://docs.microsoft.com/rest/api/storageservices/create-container.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResponse, error)

Delete marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection. For more information, see https://docs.microsoft.com/rest/api/storageservices/delete-container.

func (*Client) GetAccessPolicy

GetAccessPolicy returns the container's access policy. The access policy indicates whether container's blobs may be accessed publicly. For more information, see https://docs.microsoft.com/rest/api/storageservices/get-container-acl.

func (*Client) GetProperties

GetProperties returns the container's properties. For more information, see https://docs.microsoft.com/rest/api/storageservices/get-container-metadata.

func (*Client) GetSASURL

func (c *Client) GetSASURL(permissions sas.ContainerPermissions, start time.Time, expiry time.Time) (string, error)

GetSASURL is a convenience method for generating a SAS token for the currently pointed at container. It can only be used if the credential supplied during creation was a SharedKeyCredential.

func (*Client) NewAppendBlobClient

func (c *Client) NewAppendBlobClient(blobName string) *appendblob.Client

NewAppendBlobClient creates a new appendblob.Client object by concatenating blobName to the end of this Client's URL. The blob name will be URL-encoded. The new appendblob.Client uses the same request policy pipeline as this Client.

func (*Client) NewBlobClient

func (c *Client) NewBlobClient(blobName string) *blob.Client

NewBlobClient creates a new blob.Client object by concatenating blobName to the end of Client's URL. The blob name will be URL-encoded. The new blob.Client uses the same request policy pipeline as this Client.

func (*Client) NewBlockBlobClient

func (c *Client) NewBlockBlobClient(blobName string) *blockblob.Client

NewBlockBlobClient creates a new blockblob.Client object by concatenating blobName to the end of this Client's URL. The blob name will be URL-encoded. The new blockblob.Client uses the same request policy pipeline as this Client.

func (*Client) NewListBlobsFlatPager

func (c *Client) NewListBlobsFlatPager(o *ListBlobsFlatOptions) *runtime.Pager[ListBlobsFlatResponse]

NewListBlobsFlatPager returns a pager for blobs starting from the specified Marker. Use an empty Marker to start enumeration from the beginning. Blob names are returned in lexicographic order. For more information, see https://docs.microsoft.com/rest/api/storageservices/list-blobs.

func (*Client) NewListBlobsHierarchyPager

func (c *Client) NewListBlobsHierarchyPager(delimiter string, o *ListBlobsHierarchyOptions) *runtime.Pager[ListBlobsHierarchyResponse]

NewListBlobsHierarchyPager returns a channel of blobs starting from the specified Marker. Use an empty Marker to start enumeration from the beginning. Blob names are returned in lexicographic order. After getting a segment, process it, and then call ListBlobsHierarchicalSegment again (passing the the previously-returned Marker) to get the next segment. For more information, see https://docs.microsoft.com/rest/api/storageservices/list-blobs. AutoPagerTimeout specifies the amount of time with no read operations before the channel times out and closes. Specify no time and it will be ignored. AutoPagerBufferSize specifies the channel's buffer size. Both the blob item channel and error channel should be watched. Only one error will be released via this channel (or a nil error, to register a clean exit.)

func (*Client) NewPageBlobClient

func (c *Client) NewPageBlobClient(blobName string) *pageblob.Client

NewPageBlobClient creates a new pageblob.Client object by concatenating blobName to the end of this Client's URL. The blob name will be URL-encoded. The new pageblob.Client uses the same request policy pipeline as this Client.

func (*Client) Restore

func (c *Client) Restore(ctx context.Context, deletedContainerVersion string, options *RestoreOptions) (RestoreResponse, error)

Restore operation restore the contents and properties of a soft deleted container to a specified container. For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/restore-container.

func (*Client) SetAccessPolicy

func (c *Client) SetAccessPolicy(ctx context.Context, containerACL []*SignedIdentifier, o *SetAccessPolicyOptions) (SetAccessPolicyResponse, error)

SetAccessPolicy sets the container's permissions. The access policy indicates whether blobs in a container may be accessed publicly. For more information, see https://docs.microsoft.com/rest/api/storageservices/set-container-acl.

func (*Client) SetMetadata

SetMetadata sets the container's metadata. For more information, see https://docs.microsoft.com/rest/api/storageservices/set-container-metadata.

func (*Client) URL

func (c *Client) URL() string

URL returns the URL endpoint used by the Client object.

type ClientOptions

type ClientOptions struct {
	azcore.ClientOptions
}

ClientOptions contains the optional parameters when creating a Client.

type CopyStatusType

type CopyStatusType = generated.CopyStatusType

CopyStatusType defines values for CopyStatusType

const (
	CopyStatusTypePending CopyStatusType = generated.CopyStatusTypePending
	CopyStatusTypeSuccess CopyStatusType = generated.CopyStatusTypeSuccess
	CopyStatusTypeAborted CopyStatusType = generated.CopyStatusTypeAborted
	CopyStatusTypeFailed  CopyStatusType = generated.CopyStatusTypeFailed
)

func PossibleCopyStatusTypeValues

func PossibleCopyStatusTypeValues() []CopyStatusType

PossibleCopyStatusTypeValues returns the possible values for the CopyStatusType const type.

type CpkScopeInfo

type CpkScopeInfo = generated.ContainerCpkScopeInfo

CpkScopeInfo contains a group of parameters for the ContainerClient.Create method.

type CreateOptions

type CreateOptions struct {
	// Specifies whether data in the container may be accessed publicly and the level of access
	Access *PublicAccessType

	// Optional. Specifies a user-defined name-value pair associated with the blob.
	Metadata map[string]string

	// Optional. Specifies the encryption scope settings to set on the container.
	CpkScopeInfo *CpkScopeInfo
}

CreateOptions contains the optional parameters for the Client.Create method.

type CreateResponse

CreateResponse contains the response from method Client.Create.

type DeleteOptions

type DeleteOptions struct {
	AccessConditions *AccessConditions
}

DeleteOptions contains the optional parameters for the Client.Delete method.

type DeleteResponse

DeleteResponse contains the response from method Client.Delete.

type GetAccessPolicyOptions

type GetAccessPolicyOptions struct {
	LeaseAccessConditions *LeaseAccessConditions
}

GetAccessPolicyOptions contains the optional parameters for the Client.GetAccessPolicy method.

type GetAccessPolicyResponse

type GetAccessPolicyResponse = generated.ContainerClientGetAccessPolicyResponse

GetAccessPolicyResponse contains the response from method Client.GetAccessPolicy.

type GetPropertiesOptions

type GetPropertiesOptions struct {
	LeaseAccessConditions *LeaseAccessConditions
}

GetPropertiesOptions contains the optional parameters for the ContainerClient.GetProperties method.

type GetPropertiesResponse

type GetPropertiesResponse = generated.ContainerClientGetPropertiesResponse

GetPropertiesResponse contains the response from method Client.GetProperties.

type ImmutabilityPolicyMode

type ImmutabilityPolicyMode = generated.ImmutabilityPolicyMode

ImmutabilityPolicyMode defines values for ImmutabilityPolicyMode

func PossibleImmutabilityPolicyModeValues

func PossibleImmutabilityPolicyModeValues() []ImmutabilityPolicyMode

PossibleImmutabilityPolicyModeValues returns the possible values for the ImmutabilityPolicyMode const type.

type LeaseAccessConditions

type LeaseAccessConditions = exported.LeaseAccessConditions

LeaseAccessConditions contains optional parameters to access leased entity.

type ListBlobsFlatOptions

type ListBlobsFlatOptions struct {
	// Include this parameter to specify one or more datasets to include in the response.
	Include ListBlobsInclude
	// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The
	// operation returns the NextMarker value within the response body if the listing
	// operation did not return all containers remaining to be listed with the current page. The NextMarker value can be used
	// as the value for the marker parameter in a subsequent call to request the next
	// page of list items. The marker value is opaque to the client.
	Marker *string
	// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value
	// greater than 5000, the server will return up to 5000 items. Note that if the
	// listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder
	// of the results. For this reason, it is possible that the service will
	// return fewer results than specified by maxresults, or than the default of 5000.
	MaxResults *int32
	// Filters the results to return only containers whose name begins with the specified prefix.
	Prefix *string
}

ListBlobsFlatOptions contains the optional parameters for the ContainerClient.ListBlobFlatSegment method.

type ListBlobsFlatResponse

ListBlobsFlatResponse contains the response from method Client.ListBlobFlatSegment.

type ListBlobsHierarchyOptions

type ListBlobsHierarchyOptions struct {
	// Include this parameter to specify one or more datasets to include in the response.
	Include ListBlobsInclude
	// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The
	// operation returns the NextMarker value within the response body if the listing
	// operation did not return all containers remaining to be listed with the current page. The NextMarker value can be used
	// as the value for the marker parameter in a subsequent call to request the next
	// page of list items. The marker value is opaque to the client.
	Marker *string
	// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value
	// greater than 5000, the server will return up to 5000 items. Note that if the
	// listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder
	// of the results. For this reason, it is possible that the service will
	// return fewer results than specified by maxresults, or than the default of 5000.
	MaxResults *int32
	// Filters the results to return only containers whose name begins with the specified prefix.
	Prefix *string
}

ListBlobsHierarchyOptions provides set of configurations for Client.NewListBlobsHierarchyPager

type ListBlobsHierarchyResponse

ListBlobsHierarchyResponse contains the response from method Client.ListBlobHierarchySegment.

type ListBlobsInclude

type ListBlobsInclude struct {
	Copy, Metadata, Snapshots, UncommittedBlobs, Deleted, Tags, Versions, LegalHold, ImmutabilityPolicy, DeletedWithVersions bool
}

ListBlobsInclude indicates what additional information the service should return with each blob.

type ModifiedAccessConditions

type ModifiedAccessConditions = exported.ModifiedAccessConditions

ModifiedAccessConditions contains a group of parameters for specifying access conditions.

type PublicAccessType

type PublicAccessType = generated.PublicAccessType

PublicAccessType defines values for AccessType - private (default) or blob or container

const (
	PublicAccessTypeBlob      PublicAccessType = generated.PublicAccessTypeBlob
	PublicAccessTypeContainer PublicAccessType = generated.PublicAccessTypeContainer
)

func PossiblePublicAccessTypeValues

func PossiblePublicAccessTypeValues() []PublicAccessType

PossiblePublicAccessTypeValues returns the possible values for the PublicAccessType const type.

type RehydratePriority

type RehydratePriority = generated.RehydratePriority

RehydratePriority - If an object is in rehydrate pending state then this header is returned with priority of rehydrate. Valid values are High and Standard.

const (
	RehydratePriorityHigh     RehydratePriority = generated.RehydratePriorityHigh
	RehydratePriorityStandard RehydratePriority = generated.RehydratePriorityStandard
)

func PossibleRehydratePriorityValues

func PossibleRehydratePriorityValues() []RehydratePriority

PossibleRehydratePriorityValues returns the possible values for the RehydratePriority const type.

type RestoreOptions

type RestoreOptions struct {
}

RestoreOptions contains the optional parameters for the Client.Restore method.

type RestoreResponse

type RestoreResponse = generated.ContainerClientRestoreResponse

RestoreResponse contains the response from method Client.Restore.

type SKUName

type SKUName = generated.SKUName

SKUName defines values for SkuName - LRS, GRS, RAGRS, ZRS, Premium LRS

const (
	SKUNameStandardLRS   SKUName = generated.SKUNameStandardLRS
	SKUNameStandardGRS   SKUName = generated.SKUNameStandardGRS
	SKUNameStandardRAGRS SKUName = generated.SKUNameStandardRAGRS
	SKUNameStandardZRS   SKUName = generated.SKUNameStandardZRS
	SKUNamePremiumLRS    SKUName = generated.SKUNamePremiumLRS
)

func PossibleSKUNameValues

func PossibleSKUNameValues() []SKUName

PossibleSKUNameValues returns the possible values for the SKUName const type.

type SetAccessPolicyOptions

type SetAccessPolicyOptions struct {
	// Specifies whether data in the container may be accessed publicly and the level of access
	Access *PublicAccessType
	// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage
	// analytics logging is enabled.
	AccessConditions *AccessConditions
}

SetAccessPolicyOptions provides set of configurations for ContainerClient.SetAccessPolicy operation

type SetAccessPolicyResponse

type SetAccessPolicyResponse = generated.ContainerClientSetAccessPolicyResponse

SetAccessPolicyResponse contains the response from method Client.SetAccessPolicy.

type SetMetadataOptions

type SetMetadataOptions struct {
	Metadata                 map[string]string
	LeaseAccessConditions    *LeaseAccessConditions
	ModifiedAccessConditions *ModifiedAccessConditions
}

SetMetadataOptions contains the optional parameters for the Client.SetMetadata method.

type SetMetadataResponse

type SetMetadataResponse = generated.ContainerClientSetMetadataResponse

SetMetadataResponse contains the response from method Client.SetMetadata.

type SharedKeyCredential

type SharedKeyCredential = exported.SharedKeyCredential

SharedKeyCredential contains an account's name and its primary or secondary key.

func NewSharedKeyCredential

func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error)

NewSharedKeyCredential creates an immutable SharedKeyCredential containing the storage account's name and either its primary or secondary key.

type SignedIdentifier

type SignedIdentifier = generated.SignedIdentifier

SignedIdentifier - signed identifier

Jump to

Keyboard shortcuts

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