|
Packit |
63bb0d |
package azblob
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
Packit |
63bb0d |
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
import (
|
|
Packit |
63bb0d |
"context"
|
|
Packit |
63bb0d |
"encoding/base64"
|
|
Packit |
63bb0d |
"github.com/Azure/azure-pipeline-go/pipeline"
|
|
Packit |
63bb0d |
"io"
|
|
Packit |
63bb0d |
"io/ioutil"
|
|
Packit |
63bb0d |
"net/http"
|
|
Packit |
63bb0d |
"net/url"
|
|
Packit |
63bb0d |
"strconv"
|
|
Packit |
63bb0d |
"time"
|
|
Packit |
63bb0d |
)
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// appendBlobClient is the client for the AppendBlob methods of the Azblob service.
|
|
Packit |
63bb0d |
type appendBlobClient struct {
|
|
Packit |
63bb0d |
managementClient
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// newAppendBlobClient creates an instance of the appendBlobClient client.
|
|
Packit |
63bb0d |
func newAppendBlobClient(url url.URL, p pipeline.Pipeline) appendBlobClient {
|
|
Packit |
63bb0d |
return appendBlobClient{newManagementClient(url, p)}
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// AppendBlock the Append Block operation commits a new block of data to the end of an existing append blob. The Append
|
|
Packit |
63bb0d |
// Block operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is
|
|
Packit |
63bb0d |
// supported only on version 2015-02-21 version or later.
|
|
Packit |
63bb0d |
//
|
|
Packit |
63bb0d |
// body is initial data body will be closed upon successful return. Callers should ensure closure when receiving an
|
|
Packit |
63bb0d |
// error.contentLength is the length of the request. timeout is the timeout parameter is expressed in seconds. For more
|
|
Packit |
63bb0d |
// information, see
|
|
Packit |
63bb0d |
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
|
|
Packit |
63bb0d |
// Timeouts for Blob Service Operations. transactionalContentMD5 is specify the transactional md5 for the body, to
|
|
Packit |
63bb0d |
// be validated by the service. leaseID is if specified, the operation only succeeds if the resource's lease is active
|
|
Packit |
63bb0d |
// and matches this ID. maxSize is optional conditional header. The max length in bytes permitted for the append blob.
|
|
Packit |
63bb0d |
// If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than
|
|
Packit |
63bb0d |
// the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code
|
|
Packit |
63bb0d |
// 412 - Precondition Failed). appendPosition is optional conditional header, used only for the Append Block operation.
|
|
Packit |
63bb0d |
// A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to
|
|
Packit |
63bb0d |
// this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412
|
|
Packit |
63bb0d |
// - Precondition Failed). ifModifiedSince is specify this header value to operate only on a blob if it has been
|
|
Packit |
63bb0d |
// modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate only on a blob if
|
|
Packit |
63bb0d |
// it has not been modified since the specified date/time. ifMatch is specify an ETag value to operate only on blobs
|
|
Packit |
63bb0d |
// with a matching value. ifNoneMatch is specify an ETag value to operate only on blobs without a matching value.
|
|
Packit |
63bb0d |
// requestID is provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics
|
|
Packit |
63bb0d |
// logs when storage analytics logging is enabled.
|
|
Packit |
63bb0d |
func (client appendBlobClient) AppendBlock(ctx context.Context, body io.ReadSeeker, contentLength int64, timeout *int32, transactionalContentMD5 []byte, leaseID *string, maxSize *int64, appendPosition *int64, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, requestID *string) (*AppendBlobAppendBlockResponse, error) {
|
|
Packit |
63bb0d |
if err := validate([]validation{
|
|
Packit |
63bb0d |
{targetValue: body,
|
|
Packit |
63bb0d |
constraints: []constraint{{target: "body", name: null, rule: true, chain: nil}}},
|
|
Packit |
63bb0d |
{targetValue: timeout,
|
|
Packit |
63bb0d |
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
|
Packit |
63bb0d |
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req, err := client.appendBlockPreparer(body, contentLength, timeout, transactionalContentMD5, leaseID, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, requestID)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.appendBlockResponder}, req)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return resp.(*AppendBlobAppendBlockResponse), err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// appendBlockPreparer prepares the AppendBlock request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) appendBlockPreparer(body io.ReadSeeker, contentLength int64, timeout *int32, transactionalContentMD5 []byte, leaseID *string, maxSize *int64, appendPosition *int64, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, requestID *string) (pipeline.Request, error) {
|
|
Packit |
63bb0d |
req, err := pipeline.NewRequest("PUT", client.url, body)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return req, pipeline.NewError(err, "failed to create request")
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
params := req.URL.Query()
|
|
Packit |
63bb0d |
if timeout != nil {
|
|
Packit |
63bb0d |
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
params.Set("comp", "appendblock")
|
|
Packit |
63bb0d |
req.URL.RawQuery = params.Encode()
|
|
Packit |
63bb0d |
req.Header.Set("Content-Length", strconv.FormatInt(contentLength, 10))
|
|
Packit |
63bb0d |
if transactionalContentMD5 != nil {
|
|
Packit |
63bb0d |
req.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(transactionalContentMD5))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if leaseID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-lease-id", *leaseID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if maxSize != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-condition-maxsize", strconv.FormatInt(*maxSize, 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if appendPosition != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-condition-appendpos", strconv.FormatInt(*appendPosition, 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifModifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifUnmodifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Match", string(*ifMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifNoneMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-None-Match", string(*ifNoneMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-version", ServiceVersion)
|
|
Packit |
63bb0d |
if requestID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-client-request-id", *requestID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return req, nil
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// appendBlockResponder handles the response to the AppendBlock request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) appendBlockResponder(resp pipeline.Response) (pipeline.Response, error) {
|
|
Packit |
63bb0d |
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
|
Packit |
63bb0d |
if resp == nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
io.Copy(ioutil.Discard, resp.Response().Body)
|
|
Packit |
63bb0d |
resp.Response().Body.Close()
|
|
Packit |
63bb0d |
return &AppendBlobAppendBlockResponse{rawResponse: resp.Response()}, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// AppendBlockFromURL the Append Block operation commits a new block of data to the end of an existing append blob
|
|
Packit |
63bb0d |
// where the contents are read from a source url. The Append Block operation is permitted only if the blob was created
|
|
Packit |
63bb0d |
// with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later.
|
|
Packit |
63bb0d |
//
|
|
Packit |
63bb0d |
// sourceURL is specify a URL to the copy source. contentLength is the length of the request. sourceRange is bytes of
|
|
Packit |
63bb0d |
// source data in the specified range. sourceContentMD5 is specify the md5 calculated for the range of bytes that must
|
|
Packit |
63bb0d |
// be read from the copy source. timeout is the timeout parameter is expressed in seconds. For more information, see
|
|
Packit |
63bb0d |
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
|
|
Packit |
63bb0d |
// Timeouts for Blob Service Operations. leaseID is if specified, the operation only succeeds if the resource's
|
|
Packit |
63bb0d |
// lease is active and matches this ID. maxSize is optional conditional header. The max length in bytes permitted for
|
|
Packit |
63bb0d |
// the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is
|
|
Packit |
63bb0d |
// already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error
|
|
Packit |
63bb0d |
// (HTTP status code 412 - Precondition Failed). appendPosition is optional conditional header, used only for the
|
|
Packit |
63bb0d |
// Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append
|
|
Packit |
63bb0d |
// position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error
|
|
Packit |
63bb0d |
// (HTTP status code 412 - Precondition Failed). ifModifiedSince is specify this header value to operate only on a blob
|
|
Packit |
63bb0d |
// if it has been modified since the specified date/time. ifUnmodifiedSince is specify this header value to operate
|
|
Packit |
63bb0d |
// only on a blob if it has not been modified since the specified date/time. ifMatch is specify an ETag value to
|
|
Packit |
63bb0d |
// operate only on blobs with a matching value. ifNoneMatch is specify an ETag value to operate only on blobs without a
|
|
Packit |
63bb0d |
// matching value. sourceIfModifiedSince is specify this header value to operate only on a blob if it has been modified
|
|
Packit |
63bb0d |
// since the specified date/time. sourceIfUnmodifiedSince is specify this header value to operate only on a blob if it
|
|
Packit |
63bb0d |
// has not been modified since the specified date/time. sourceIfMatch is specify an ETag value to operate only on blobs
|
|
Packit |
63bb0d |
// with a matching value. sourceIfNoneMatch is specify an ETag value to operate only on blobs without a matching value.
|
|
Packit |
63bb0d |
// requestID is provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics
|
|
Packit |
63bb0d |
// logs when storage analytics logging is enabled.
|
|
Packit |
63bb0d |
func (client appendBlobClient) AppendBlockFromURL(ctx context.Context, sourceURL string, contentLength int64, sourceRange *string, sourceContentMD5 []byte, timeout *int32, leaseID *string, maxSize *int64, appendPosition *int64, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, sourceIfModifiedSince *time.Time, sourceIfUnmodifiedSince *time.Time, sourceIfMatch *ETag, sourceIfNoneMatch *ETag, requestID *string) (*AppendBlobAppendBlockFromURLResponse, error) {
|
|
Packit |
63bb0d |
if err := validate([]validation{
|
|
Packit |
63bb0d |
{targetValue: timeout,
|
|
Packit |
63bb0d |
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
|
Packit |
63bb0d |
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req, err := client.appendBlockFromURLPreparer(sourceURL, contentLength, sourceRange, sourceContentMD5, timeout, leaseID, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, requestID)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.appendBlockFromURLResponder}, req)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return resp.(*AppendBlobAppendBlockFromURLResponse), err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// appendBlockFromURLPreparer prepares the AppendBlockFromURL request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) appendBlockFromURLPreparer(sourceURL string, contentLength int64, sourceRange *string, sourceContentMD5 []byte, timeout *int32, leaseID *string, maxSize *int64, appendPosition *int64, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, sourceIfModifiedSince *time.Time, sourceIfUnmodifiedSince *time.Time, sourceIfMatch *ETag, sourceIfNoneMatch *ETag, requestID *string) (pipeline.Request, error) {
|
|
Packit |
63bb0d |
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return req, pipeline.NewError(err, "failed to create request")
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
params := req.URL.Query()
|
|
Packit |
63bb0d |
if timeout != nil {
|
|
Packit |
63bb0d |
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
params.Set("comp", "appendblock")
|
|
Packit |
63bb0d |
req.URL.RawQuery = params.Encode()
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-copy-source", sourceURL)
|
|
Packit |
63bb0d |
if sourceRange != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-range", *sourceRange)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if sourceContentMD5 != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-content-md5", base64.StdEncoding.EncodeToString(sourceContentMD5))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.Header.Set("Content-Length", strconv.FormatInt(contentLength, 10))
|
|
Packit |
63bb0d |
if leaseID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-lease-id", *leaseID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if maxSize != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-condition-maxsize", strconv.FormatInt(*maxSize, 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if appendPosition != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-condition-appendpos", strconv.FormatInt(*appendPosition, 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifModifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifUnmodifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Match", string(*ifMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifNoneMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-None-Match", string(*ifNoneMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if sourceIfModifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-if-modified-since", (*sourceIfModifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if sourceIfUnmodifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-if-unmodified-since", (*sourceIfUnmodifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if sourceIfMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-if-match", string(*sourceIfMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if sourceIfNoneMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-source-if-none-match", string(*sourceIfNoneMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-version", ServiceVersion)
|
|
Packit |
63bb0d |
if requestID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-client-request-id", *requestID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return req, nil
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// appendBlockFromURLResponder handles the response to the AppendBlockFromURL request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) appendBlockFromURLResponder(resp pipeline.Response) (pipeline.Response, error) {
|
|
Packit |
63bb0d |
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
|
Packit |
63bb0d |
if resp == nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
io.Copy(ioutil.Discard, resp.Response().Body)
|
|
Packit |
63bb0d |
resp.Response().Body.Close()
|
|
Packit |
63bb0d |
return &AppendBlobAppendBlockFromURLResponse{rawResponse: resp.Response()}, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// Create the Create Append Blob operation creates a new append blob.
|
|
Packit |
63bb0d |
//
|
|
Packit |
63bb0d |
// contentLength is the length of the request. timeout is the timeout parameter is expressed in seconds. For more
|
|
Packit |
63bb0d |
// information, see
|
|
Packit |
63bb0d |
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
|
|
Packit |
63bb0d |
// Timeouts for Blob Service Operations. blobContentType is optional. Sets the blob's content type. If specified,
|
|
Packit |
63bb0d |
// this property is stored with the blob and returned with a read request. blobContentEncoding is optional. Sets the
|
|
Packit |
63bb0d |
// blob's content encoding. If specified, this property is stored with the blob and returned with a read request.
|
|
Packit |
63bb0d |
// blobContentLanguage is optional. Set the blob's content language. If specified, this property is stored with the
|
|
Packit |
63bb0d |
// blob and returned with a read request. blobContentMD5 is optional. An MD5 hash of the blob content. Note that this
|
|
Packit |
63bb0d |
// hash is not validated, as the hashes for the individual blocks were validated when each was uploaded.
|
|
Packit |
63bb0d |
// blobCacheControl is optional. Sets the blob's cache control. If specified, this property is stored with the blob and
|
|
Packit |
63bb0d |
// returned with a read request. metadata is optional. Specifies a user-defined name-value pair associated with the
|
|
Packit |
63bb0d |
// blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the
|
|
Packit |
63bb0d |
// destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified
|
|
Packit |
63bb0d |
// metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19,
|
|
Packit |
63bb0d |
// metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and
|
|
Packit |
63bb0d |
// Metadata for more information. leaseID is if specified, the operation only succeeds if the resource's lease is
|
|
Packit |
63bb0d |
// active and matches this ID. blobContentDisposition is optional. Sets the blob's Content-Disposition header.
|
|
Packit |
63bb0d |
// ifModifiedSince is specify this header value to operate only on a blob if it has been modified since the specified
|
|
Packit |
63bb0d |
// date/time. ifUnmodifiedSince is specify this header value to operate only on a blob if it has not been modified
|
|
Packit |
63bb0d |
// since the specified date/time. ifMatch is specify an ETag value to operate only on blobs with a matching value.
|
|
Packit |
63bb0d |
// ifNoneMatch is specify an ETag value to operate only on blobs without a matching value. requestID is provides a
|
|
Packit |
63bb0d |
// client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage
|
|
Packit |
63bb0d |
// analytics logging is enabled.
|
|
Packit |
63bb0d |
func (client appendBlobClient) Create(ctx context.Context, contentLength int64, timeout *int32, blobContentType *string, blobContentEncoding *string, blobContentLanguage *string, blobContentMD5 []byte, blobCacheControl *string, metadata map[string]string, leaseID *string, blobContentDisposition *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, requestID *string) (*AppendBlobCreateResponse, error) {
|
|
Packit |
63bb0d |
if err := validate([]validation{
|
|
Packit |
63bb0d |
{targetValue: timeout,
|
|
Packit |
63bb0d |
constraints: []constraint{{target: "timeout", name: null, rule: false,
|
|
Packit |
63bb0d |
chain: []constraint{{target: "timeout", name: inclusiveMinimum, rule: 0, chain: nil}}}}}}); err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req, err := client.createPreparer(contentLength, timeout, blobContentType, blobContentEncoding, blobContentLanguage, blobContentMD5, blobCacheControl, metadata, leaseID, blobContentDisposition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, requestID)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createResponder}, req)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
return resp.(*AppendBlobCreateResponse), err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// createPreparer prepares the Create request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) createPreparer(contentLength int64, timeout *int32, blobContentType *string, blobContentEncoding *string, blobContentLanguage *string, blobContentMD5 []byte, blobCacheControl *string, metadata map[string]string, leaseID *string, blobContentDisposition *string, ifModifiedSince *time.Time, ifUnmodifiedSince *time.Time, ifMatch *ETag, ifNoneMatch *ETag, requestID *string) (pipeline.Request, error) {
|
|
Packit |
63bb0d |
req, err := pipeline.NewRequest("PUT", client.url, nil)
|
|
Packit |
63bb0d |
if err != nil {
|
|
Packit |
63bb0d |
return req, pipeline.NewError(err, "failed to create request")
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
params := req.URL.Query()
|
|
Packit |
63bb0d |
if timeout != nil {
|
|
Packit |
63bb0d |
params.Set("timeout", strconv.FormatInt(int64(*timeout), 10))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.URL.RawQuery = params.Encode()
|
|
Packit |
63bb0d |
req.Header.Set("Content-Length", strconv.FormatInt(contentLength, 10))
|
|
Packit |
63bb0d |
if blobContentType != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-content-type", *blobContentType)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if blobContentEncoding != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-content-encoding", *blobContentEncoding)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if blobContentLanguage != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-content-language", *blobContentLanguage)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if blobContentMD5 != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-content-md5", base64.StdEncoding.EncodeToString(blobContentMD5))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if blobCacheControl != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-cache-control", *blobCacheControl)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if metadata != nil {
|
|
Packit |
63bb0d |
for k, v := range metadata {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-meta-"+k, v)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if leaseID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-lease-id", *leaseID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if blobContentDisposition != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-content-disposition", *blobContentDisposition)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifModifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Modified-Since", (*ifModifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifUnmodifiedSince != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Unmodified-Since", (*ifUnmodifiedSince).In(gmt).Format(time.RFC1123))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-Match", string(*ifMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
if ifNoneMatch != nil {
|
|
Packit |
63bb0d |
req.Header.Set("If-None-Match", string(*ifNoneMatch))
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-version", ServiceVersion)
|
|
Packit |
63bb0d |
if requestID != nil {
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-client-request-id", *requestID)
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
req.Header.Set("x-ms-blob-type", "AppendBlob")
|
|
Packit |
63bb0d |
return req, nil
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
|
|
Packit |
63bb0d |
// createResponder handles the response to the Create request.
|
|
Packit |
63bb0d |
func (client appendBlobClient) createResponder(resp pipeline.Response) (pipeline.Response, error) {
|
|
Packit |
63bb0d |
err := validateResponse(resp, http.StatusOK, http.StatusCreated)
|
|
Packit |
63bb0d |
if resp == nil {
|
|
Packit |
63bb0d |
return nil, err
|
|
Packit |
63bb0d |
}
|
|
Packit |
63bb0d |
io.Copy(ioutil.Discard, resp.Response().Body)
|
|
Packit |
63bb0d |
resp.Response().Body.Close()
|
|
Packit |
63bb0d |
return &AppendBlobCreateResponse{rawResponse: resp.Response()}, err
|
|
Packit |
63bb0d |
}
|