|
Packit |
63bb0d |
package azblob
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
import (
|
|
Packit |
63bb0d |
"context"
|
|
Packit |
63bb0d |
"github.com/Azure/azure-pipeline-go/pipeline"
|
|
Packit Service |
3a6627 |
"net/url"
|
|
Packit Service |
3a6627 |
"strings"
|
|
Packit |
63bb0d |
)
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// A BlobURL represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.
|
|
Packit |
63bb0d |
type BlobURL struct {
|
|
Packit |
63bb0d |
blobClient blobClient
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
type BlobTagsMap map[string]string
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
var DefaultAccessTier AccessTierType = AccessTierNone
|
|
Packit Service |
3a6627 |
var DefaultPremiumBlobAccessTier PremiumPageBlobAccessTierType = PremiumPageBlobAccessTierNone
|
|
Packit Service |
3a6627 |
|
|
Packit |
63bb0d |
// NewBlobURL creates a BlobURL object using the specified URL and request policy pipeline.
|
|
Packit |
63bb0d |
func NewBlobURL(url url.URL, p pipeline.Pipeline) BlobURL {
|
|
Packit |
63bb0d |
blobClient := newBlobClient(url, p)
|
|
Packit |
63bb0d |
return BlobURL{blobClient: blobClient}
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// URL returns the URL endpoint used by the BlobURL object.
|
|
Packit |
63bb0d |
func (b BlobURL) URL() url.URL {
|
|
Packit |
63bb0d |
return b.blobClient.URL()
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// String returns the URL as a string.
|
|
Packit |
63bb0d |
func (b BlobURL) String() string {
|
|
Packit |
63bb0d |
u := b.URL()
|
|
Packit |
63bb0d |
return u.String()
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
func (b BlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfoResponse, error) {
|
|
Packit Service |
3a6627 |
return b.blobClient.GetAccountInfo(ctx)
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit |
63bb0d |
// WithPipeline creates a new BlobURL object identical to the source but with the specified request policy pipeline.
|
|
Packit |
63bb0d |
func (b BlobURL) WithPipeline(p pipeline.Pipeline) BlobURL {
|
|
Packit |
63bb0d |
return NewBlobURL(b.blobClient.URL(), p)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// WithSnapshot creates a new BlobURL object identical to the source but with the specified snapshot timestamp.
|
|
Packit |
63bb0d |
// Pass "" to remove the snapshot returning a URL to the base blob.
|
|
Packit |
63bb0d |
func (b BlobURL) WithSnapshot(snapshot string) BlobURL {
|
|
Packit |
63bb0d |
p := NewBlobURLParts(b.URL())
|
|
Packit |
63bb0d |
p.Snapshot = snapshot
|
|
Packit |
63bb0d |
return NewBlobURL(p.URL(), b.blobClient.Pipeline())
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// WithVersionID creates a new BlobURL object identical to the source but with the specified version id.
|
|
Packit Service |
3a6627 |
// Pass "" to remove the snapshot returning a URL to the base blob.
|
|
Packit Service |
3a6627 |
func (b BlobURL) WithVersionID(versionID string) BlobURL {
|
|
Packit Service |
3a6627 |
p := NewBlobURLParts(b.URL())
|
|
Packit Service |
3a6627 |
p.VersionID = versionID
|
|
Packit Service |
3a6627 |
return NewBlobURL(p.URL(), b.blobClient.Pipeline())
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit |
63bb0d |
// ToAppendBlobURL creates an AppendBlobURL using the source's URL and pipeline.
|
|
Packit |
63bb0d |
func (b BlobURL) ToAppendBlobURL() AppendBlobURL {
|
|
Packit |
63bb0d |
return NewAppendBlobURL(b.URL(), b.blobClient.Pipeline())
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// ToBlockBlobURL creates a BlockBlobURL using the source's URL and pipeline.
|
|
Packit |
63bb0d |
func (b BlobURL) ToBlockBlobURL() BlockBlobURL {
|
|
Packit |
63bb0d |
return NewBlockBlobURL(b.URL(), b.blobClient.Pipeline())
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// ToPageBlobURL creates a PageBlobURL using the source's URL and pipeline.
|
|
Packit |
63bb0d |
func (b BlobURL) ToPageBlobURL() PageBlobURL {
|
|
Packit |
63bb0d |
return NewPageBlobURL(b.URL(), b.blobClient.Pipeline())
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
func SerializeBlobTagsHeader(blobTagsMap BlobTagsMap) *string {
|
|
Packit Service |
3a6627 |
if blobTagsMap == nil {
|
|
Packit Service |
3a6627 |
return nil
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
tags := make([]string, 0)
|
|
Packit Service |
3a6627 |
for key, val := range blobTagsMap {
|
|
Packit Service |
3a6627 |
tags = append(tags, url.QueryEscape(key)+"="+url.QueryEscape(val))
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
//tags = tags[:len(tags)-1]
|
|
Packit Service |
3a6627 |
blobTagsString := strings.Join(tags, "&")
|
|
Packit Service |
3a6627 |
return &blobTagsString
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
func SerializeBlobTags(blobTagsMap BlobTagsMap) BlobTags {
|
|
Packit Service |
3a6627 |
if blobTagsMap == nil {
|
|
Packit Service |
3a6627 |
return BlobTags{}
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
blobTagSet := make([]BlobTag, 0, len(blobTagsMap))
|
|
Packit Service |
3a6627 |
for key, val := range blobTagsMap {
|
|
Packit Service |
3a6627 |
blobTagSet = append(blobTagSet, BlobTag{Key: key, Value: val})
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
return BlobTags{BlobTagSet: blobTagSet}
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
// Download reads a range of bytes from a blob. The response also includes the blob's properties and metadata.
|
|
Packit |
63bb0d |
// Passing azblob.CountToEnd (0) for count will download the blob from the offset to the end.
|
|
Packit Service |
3a6627 |
// Note: Snapshot/VersionId are optional parameters which are part of request URL query params.
|
|
Packit Service |
3a6627 |
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
|
|
Packit Service |
3a6627 |
// Therefore it not required to pass these here.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob.
|
|
Packit Service |
3a6627 |
func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac BlobAccessConditions, rangeGetContentMD5 bool, cpk ClientProvidedKeyOptions) (*DownloadResponse, error) {
|
|
Packit |
63bb0d |
var xRangeGetContentMD5 *bool
|
|
Packit |
63bb0d |
if rangeGetContentMD5 {
|
|
Packit |
63bb0d |
xRangeGetContentMD5 = &rangeGetContentMD5
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit Service |
3a6627 |
dr, err := b.blobClient.Download(ctx, nil, nil, nil,
|
|
Packit |
63bb0d |
httpRange{offset: offset, count: count}.pointers(),
|
|
Packit Service |
3a6627 |
ac.LeaseAccessConditions.pointers(), xRangeGetContentMD5, nil,
|
|
Packit Service |
3a6627 |
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return &DownloadResponse{
|
|
Packit |
63bb0d |
b: b,
|
|
Packit |
63bb0d |
r: dr,
|
|
Packit |
63bb0d |
ctx: ctx,
|
|
Packit |
63bb0d |
getInfo: HTTPGetterInfo{Offset: offset, Count: count, ETag: dr.ETag()},
|
|
Packit |
63bb0d |
}, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection.
|
|
Packit Service |
3a6627 |
// Note 1: that deleting a blob also deletes all its snapshots.
|
|
Packit Service |
3a6627 |
// Note 2: Snapshot/VersionId are optional parameters which are part of request URL query params.
|
|
Packit Service |
3a6627 |
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
|
|
Packit Service |
3a6627 |
// Therefore it not required to pass these here.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/delete-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) Delete(ctx context.Context, deleteOptions DeleteSnapshotsOptionType, ac BlobAccessConditions) (*BlobDeleteResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit Service |
3a6627 |
return b.blobClient.Delete(ctx, nil, nil, nil, ac.LeaseAccessConditions.pointers(), deleteOptions,
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
// SetTags operation enables users to set tags on a blob or specific blob version, but not snapshot.
|
|
Packit Service |
3a6627 |
// Each call to this operation replaces all existing tags attached to the blob.
|
|
Packit Service |
3a6627 |
// To remove all tags from the blob, call this operation with no tags set.
|
|
Packit Service |
3a6627 |
// https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tags
|
|
Packit Service |
3a6627 |
func (b BlobURL) SetTags(ctx context.Context, timeout *int32, versionID *string, transactionalContentMD5 []byte, transactionalContentCrc64 []byte, requestID *string, ifTags *string, blobTagsMap BlobTagsMap) (*BlobSetTagsResponse, error) {
|
|
Packit Service |
3a6627 |
tags := SerializeBlobTags(blobTagsMap)
|
|
Packit Service |
3a6627 |
return b.blobClient.SetTags(ctx, timeout, versionID, transactionalContentMD5, transactionalContentCrc64, requestID, ifTags, &tags)
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
// GetTags operation enables users to get tags on a blob or specific blob version, or snapshot.
|
|
Packit Service |
3a6627 |
// https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-tags
|
|
Packit Service |
3a6627 |
func (b BlobURL) GetTags(ctx context.Context, timeout *int32, requestID *string, snapshot *string, versionID *string, ifTags *string) (*BlobTags, error) {
|
|
Packit Service |
3a6627 |
return b.blobClient.GetTags(ctx, timeout, requestID, snapshot, versionID, ifTags)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// Undelete restores the contents and metadata of a soft-deleted blob and any associated soft-deleted snapshots.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/undelete-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) Undelete(ctx context.Context) (*BlobUndeleteResponse, error) {
|
|
Packit |
63bb0d |
return b.blobClient.Undelete(ctx, nil, nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// SetTier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage account
|
|
Packit Service |
3a6627 |
// and on a block blob in a blob storage account (locally redundant storage only).
|
|
Packit Service |
3a6627 |
// A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob.
|
|
Packit Service |
3a6627 |
// A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.
|
|
Packit Service |
3a6627 |
// Note: VersionId is an optional parameter which is part of request URL query params.
|
|
Packit Service |
3a6627 |
// It can be explicitly set by calling WithVersionID(versionID string) function and hence it not required to pass it here.
|
|
Packit |
63bb0d |
// For detailed information about block blob level tiering see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers.
|
|
Packit |
63bb0d |
func (b BlobURL) SetTier(ctx context.Context, tier AccessTierType, lac LeaseAccessConditions) (*BlobSetTierResponse, error) {
|
|
Packit Service |
3a6627 |
return b.blobClient.SetTier(ctx, tier, nil,
|
|
Packit Service |
3a6627 |
nil, // Blob versioning
|
|
Packit Service |
3a6627 |
nil, RehydratePriorityNone, nil, lac.pointers())
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// GetProperties returns the blob's properties.
|
|
Packit Service |
3a6627 |
// Note: Snapshot/VersionId are optional parameters which are part of request URL query params.
|
|
Packit Service |
3a6627 |
// These parameters can be explicitly set by calling WithSnapshot(snapshot string)/WithVersionID(versionID string)
|
|
Packit Service |
3a6627 |
// Therefore it not required to pass these here.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob-properties.
|
|
Packit Service |
3a6627 |
func (b BlobURL) GetProperties(ctx context.Context, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobGetPropertiesResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit Service |
3a6627 |
return b.blobClient.GetProperties(ctx, nil,
|
|
Packit Service |
3a6627 |
nil, // Blob versioning
|
|
Packit Service |
3a6627 |
nil, ac.LeaseAccessConditions.pointers(),
|
|
Packit Service |
3a6627 |
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// SetHTTPHeaders changes a blob's HTTP headers.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/set-blob-properties.
|
|
Packit |
63bb0d |
func (b BlobURL) SetHTTPHeaders(ctx context.Context, h BlobHTTPHeaders, ac BlobAccessConditions) (*BlobSetHTTPHeadersResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.SetHTTPHeaders(ctx, nil,
|
|
Packit |
63bb0d |
&h.CacheControl, &h.ContentType, h.ContentMD5, &h.ContentEncoding, &h.ContentLanguage,
|
|
Packit |
63bb0d |
ac.LeaseAccessConditions.pointers(), ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit |
63bb0d |
&h.ContentDisposition, nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit Service |
3a6627 |
// SetMetadata changes a blob's metadata.
|
|
Packit |
63bb0d |
// https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata.
|
|
Packit Service |
3a6627 |
func (b BlobURL) SetMetadata(ctx context.Context, metadata Metadata, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobSetMetadataResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.SetMetadata(ctx, nil, metadata, ac.LeaseAccessConditions.pointers(),
|
|
Packit Service |
3a6627 |
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
|
|
Packit Service |
3a6627 |
cpk.EncryptionScope, // CPK-N
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// CreateSnapshot creates a read-only snapshot of a blob.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/snapshot-blob.
|
|
Packit Service |
3a6627 |
func (b BlobURL) CreateSnapshot(ctx context.Context, metadata Metadata, ac BlobAccessConditions, cpk ClientProvidedKeyOptions) (*BlobCreateSnapshotResponse, error) {
|
|
Packit |
63bb0d |
// CreateSnapshot does NOT panic if the user tries to create a snapshot using a URL that already has a snapshot query parameter
|
|
Packit |
63bb0d |
// because checking this would be a performance hit for a VERY unusual path and I don't think the common case should suffer this
|
|
Packit |
63bb0d |
// performance hit.
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
|
Packit Service |
3a6627 |
return b.blobClient.CreateSnapshot(ctx, nil, metadata,
|
|
Packit Service |
3a6627 |
cpk.EncryptionKey, cpk.EncryptionKeySha256, cpk.EncryptionAlgorithm, // CPK-V
|
|
Packit Service |
3a6627 |
cpk.EncryptionScope, // CPK-N
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
ac.LeaseAccessConditions.pointers(), nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// AcquireLease acquires a lease on the blob for write and delete operations. The lease duration must be between
|
|
Packit |
63bb0d |
// 15 to 60 seconds, or infinite (-1).
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) AcquireLease(ctx context.Context, proposedID string, duration int32, ac ModifiedAccessConditions) (*BlobAcquireLeaseResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.AcquireLease(ctx, nil, &duration, &proposedID,
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// RenewLease renews the blob's previously-acquired lease.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) RenewLease(ctx context.Context, leaseID string, ac ModifiedAccessConditions) (*BlobRenewLeaseResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.RenewLease(ctx, leaseID, nil,
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// ReleaseLease releases the blob's previously-acquired lease.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) ReleaseLease(ctx context.Context, leaseID string, ac ModifiedAccessConditions) (*BlobReleaseLeaseResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.ReleaseLease(ctx, leaseID, nil,
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// BreakLease breaks the blob's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1)
|
|
Packit |
63bb0d |
// constant to break a fixed-duration lease when it expires or an infinite lease immediately.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) BreakLease(ctx context.Context, breakPeriodInSeconds int32, ac ModifiedAccessConditions) (*BlobBreakLeaseResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.BreakLease(ctx, nil, leasePeriodPointer(breakPeriodInSeconds),
|
|
Packit Service |
3a6627 |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// ChangeLease changes the blob's lease ID.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) ChangeLease(ctx context.Context, leaseID string, proposedID string, ac ModifiedAccessConditions) (*BlobChangeLeaseResponse, error) {
|
|
Packit |
63bb0d |
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
|
Packit |
63bb0d |
return b.blobClient.ChangeLease(ctx, leaseID, proposedID,
|
|
Packit Service |
3a6627 |
nil, ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// LeaseBreakNaturally tells ContainerURL's or BlobURL's BreakLease method to break the lease using service semantics.
|
|
Packit |
63bb0d |
const LeaseBreakNaturally = -1
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
func leasePeriodPointer(period int32) (p *int32) {
|
|
Packit |
63bb0d |
if period != LeaseBreakNaturally {
|
|
Packit |
63bb0d |
p = &period
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return nil
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// StartCopyFromURL copies the data at the source URL to a blob.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/copy-blob.
|
|
Packit Service |
3a6627 |
func (b BlobURL) StartCopyFromURL(ctx context.Context, source url.URL, metadata Metadata, srcac ModifiedAccessConditions, dstac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlobStartCopyFromURLResponse, error) {
|
|
Packit |
63bb0d |
srcIfModifiedSince, srcIfUnmodifiedSince, srcIfMatchETag, srcIfNoneMatchETag := srcac.pointers()
|
|
Packit |
63bb0d |
dstIfModifiedSince, dstIfUnmodifiedSince, dstIfMatchETag, dstIfNoneMatchETag := dstac.ModifiedAccessConditions.pointers()
|
|
Packit |
63bb0d |
dstLeaseID := dstac.LeaseAccessConditions.pointers()
|
|
Packit Service |
3a6627 |
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
|
Packit |
63bb0d |
return b.blobClient.StartCopyFromURL(ctx, source.String(), nil, metadata,
|
|
Packit Service |
3a6627 |
tier, RehydratePriorityNone, srcIfModifiedSince, srcIfUnmodifiedSince,
|
|
Packit |
63bb0d |
srcIfMatchETag, srcIfNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // source ifTags
|
|
Packit |
63bb0d |
dstIfModifiedSince, dstIfUnmodifiedSince,
|
|
Packit |
63bb0d |
dstIfMatchETag, dstIfNoneMatchETag,
|
|
Packit Service |
3a6627 |
nil, // Blob ifTags
|
|
Packit Service |
3a6627 |
dstLeaseID,
|
|
Packit Service |
3a6627 |
nil,
|
|
Packit Service |
3a6627 |
blobTagsString, // Blob tags
|
|
Packit Service |
3a6627 |
nil)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// AbortCopyFromURL stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.
|
|
Packit |
63bb0d |
// For more information, see https://docs.microsoft.com/rest/api/storageservices/abort-copy-blob.
|
|
Packit |
63bb0d |
func (b BlobURL) AbortCopyFromURL(ctx context.Context, copyID string, ac LeaseAccessConditions) (*BlobAbortCopyFromURLResponse, error) {
|
|
Packit |
63bb0d |
return b.blobClient.AbortCopyFromURL(ctx, copyID, nil, ac.pointers(), nil)
|
|
Packit |
63bb0d |
}
|