Storage Blob Service Access Conditions, Bitwise enum class (#252)

* access conditions

* bitwise enum class

* Update x-ms-date on each retry

* add a header for all constant strings

* fix some ut

* rename ModifiedTimeAccessConditons->LastModifiedTimeAccessConditions
This commit is contained in:
JinmingHu 2020-07-10 12:03:32 +08:00 committed by GitHub
parent f6defdf25a
commit 83406f23dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 506 additions and 836 deletions

View File

@ -11,6 +11,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(BUILD_STORAGE_SAMPLES "Build sample codes" ON)
set (AZURE_STORAGE_BLOB_HEADER
inc/common/constants.hpp
inc/common/storage_common.hpp
inc/common/storage_credential.hpp
inc/common/storage_url_builder.hpp
@ -20,6 +21,7 @@ set (AZURE_STORAGE_BLOB_HEADER
inc/common/xml_wrapper.hpp
inc/common/concurrent_transfer.hpp
inc/common/file_io.hpp
inc/common/access_conditions.hpp
inc/blobs/blob.hpp
inc/blobs/blob_service_client.hpp
inc/blobs/blob_container_client.hpp

View File

@ -3,6 +3,7 @@
#pragma once
#include "common/access_conditions.hpp"
#include "internal/protocol/blob_rest_client.hpp"
#include <limits>
@ -11,6 +12,65 @@
namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Specifies access conditions for a container.
*/
struct ContainerAccessConditions : public LastModifiedTimeAccessConditions,
public LeaseAccessConditions
{
};
/**
* @brief Specifies access conditions for a blob.
*/
struct BlobAccessConditions : public LastModifiedTimeAccessConditions,
public ETagAccessConditions,
public LeaseAccessConditions
{
};
/**
* @brief Specifies access conditions for a append blob.
*/
struct AppendBlobAccessConditions : public BlobAccessConditions
{
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append blob's size
* is less than or equal to this value.
*/
Azure::Core::Nullable<int64_t> MaxSize;
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append position is equal
* to this value.
*/
Azure::Core::Nullable<int64_t> AppendPosition;
};
/**
* @brief Specifies access conditions for a page blob.
*/
struct PageBlobAccessConditions : public BlobAccessConditions
{
/**
* @brief IfSequenceNumberLessThan ensures that the page blob operation succeeds only if
* the blob's sequence number is less than a value.
*/
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThan;
/**
* @brief IfSequenceNumberLessThanOrEqual ensures that the page blob operation succeeds
* only if the blob's sequence number is less than or equal to a value.
*/
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThanOrEqual;
/**
* @brief IfSequenceNumberEqual ensures that the page blob operation succeeds only
* if the blob's sequence number is equal to a value.
*/
Azure::Core::Nullable<int64_t> IfSequenceNumberEqual;
};
/**
* @brief Service client options used to initalize BlobServiceClient.
*/
@ -63,7 +123,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Specifies that the container's metadata be returned.
*/
std::vector<ListBlobContainersIncludeOption> Include;
ListBlobContainersIncludeOption Include = ListBlobContainersIncludeOption::None;
};
/**
@ -128,16 +188,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
ContainerAccessConditions Conditions;
};
/**
@ -149,6 +202,11 @@ namespace Azure { namespace Storage { namespace Blobs {
* @brief Context for cancelling long running operations.
*/
Azure::Core::Context Context;
/**
* @brief Optional conditions that must be met to perform this operation.
*/
LeaseAccessConditions Conditions;
};
/**
@ -162,10 +220,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
ContainerAccessConditions Conditions;
};
/**
@ -208,7 +265,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Specifies one or more datasets to include in the response.
*/
std::vector<ListBlobsIncludeItem> Include;
ListBlobsIncludeItem Include = ListBlobsIncludeItem::None;
};
/**
@ -261,29 +318,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -297,29 +334,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -333,29 +350,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -396,16 +393,14 @@ namespace Azure { namespace Storage { namespace Blobs {
std::map<std::string, std::string> Metadata;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
BlobAccessConditions Conditions;
/**
* @brief Specify this header to perform the operation only if the lease id given
* matches the active lease id of the source blob.
* @brief Optional conditions that the source must meet to perform this operation.
*/
Azure::Core::Nullable<std::string> SourceLeaseId;
BlobAccessConditions SourceConditions;
/**
* @brief Specifies the tier to be set on the target blob.
@ -418,55 +413,6 @@ namespace Azure { namespace Storage { namespace Blobs {
* same blob.
*/
Azure::Core::Nullable<Blobs::RehydratePriority> RehydratePriority;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
/**
* @brief Specify this conditional header to copy the blob only if the source blob has
* been modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> SourceIfModifiedSince;
/**
* @brief Specify this conditional header to copy the blob only if the source blob has
* not been modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> SourceIfUnmodifiedSince;
/**
* @brief Specify this conditional header to copy the source blob only if its ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> SourceIfMatch;
/**
* @brief Specify this conditional header to copy the blob only if its ETag does not
* match the value specified.
*/
Azure::Core::Nullable<std::string> SourceIfNoneMatch;
};
/**
@ -480,10 +426,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
LeaseAccessConditions Conditions;
};
/**
@ -508,29 +453,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<int64_t> Length;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -596,35 +521,9 @@ namespace Azure { namespace Storage { namespace Blobs {
std::map<std::string, std::string> Metadata;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -645,29 +544,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<DeleteSnapshotsOption> DeleteSnapshots;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -721,29 +600,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<AccessTier> Tier;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -805,6 +664,11 @@ namespace Azure { namespace Storage { namespace Blobs {
* that has arrived with the one that was sent.
*/
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Optional conditions that must be met to perform this operation.
*/
LeaseAccessConditions Conditions;
};
/**
@ -843,34 +707,14 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
LeaseAccessConditions Conditions;
/**
* @brief Specify this conditional header to copy the blob only if the source blob has
* been modified since the specified date/time.
* @brief Optional conditions that the source must meet to perform this operation.
*/
Azure::Core::Nullable<std::string> SourceIfModifiedSince;
/**
* @brief Specify this conditional header to copy the blob only if the source blob has
* not been modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> SourceIfUnmodifiedSince;
/**
* @brief Specify this conditional header to copy the source blob only if its ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> SourceIfMatch;
/**
* @brief Specify this conditional header to copy the blob only if its ETag does not
* match the value specified.
*/
Azure::Core::Nullable<std::string> SourceIfNoneMatch;
BlobAccessConditions SourceConditions;
};
/**
@ -899,29 +743,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<AccessTier> Tier;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -933,32 +757,17 @@ namespace Azure { namespace Storage { namespace Blobs {
* @brief Context for cancelling long running operations.
*/
Azure::Core::Context Context;
/**
* @brief Specifies whether to return the list of committed blocks, the list of uncommitted
* blocks, or both lists together.
*/
Azure::Core::Nullable<BlockListTypeOption> ListType;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
LeaseAccessConditions Conditions;
};
/**
@ -982,29 +791,9 @@ namespace Azure { namespace Storage { namespace Blobs {
std::map<std::string, std::string> Metadata;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -1032,47 +821,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append blob's size
* is less than or equal to this value.
*/
Azure::Core::Nullable<int64_t> MaxSize;
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append position is equal
* to this value.
*/
Azure::Core::Nullable<int64_t> AppendPosition;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
AppendBlobAccessConditions Conditions;
};
/**
@ -1111,47 +862,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append blob's size
* is less than or equal to this value.
*/
Azure::Core::Nullable<int64_t> MaxSize;
/**
* @brief Ensures that the AppendBlock operation succeeds only if the append position is
* equal to this value.
*/
Azure::Core::Nullable<int64_t> AppendPosition;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
AppendBlobAccessConditions Conditions;
};
/**
@ -1181,29 +894,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<AccessTier> Tier;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -1231,35 +924,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
PageBlobAccessConditions Conditions;
};
/**
@ -1287,35 +954,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> ContentCRC64;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
PageBlobAccessConditions Conditions;
};
/**
@ -1329,35 +970,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
PageBlobAccessConditions Conditions;
};
/**
@ -1371,29 +986,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -1433,35 +1028,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<int64_t> Length;
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> LeaseId;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
/**
@ -1475,29 +1044,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Context Context;
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
* @brief Optional conditions that must be met to perform this operation.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
BlobAccessConditions Conditions;
};
}}} // namespace Azure::Storage::Blobs

View File

@ -611,94 +611,131 @@ namespace Azure { namespace Storage { namespace Blobs {
enum class ListBlobContainersIncludeOption
{
None,
Metadata,
}; // enum class ListBlobContainersIncludeOption
None = 0,
Metadata = 1,
}; // bitwise enum ListBlobContainersIncludeOption
inline std::string ListBlobContainersIncludeOptionToString(
const ListBlobContainersIncludeOption& list_blob_containers_include_option)
inline ListBlobContainersIncludeOption operator|(
ListBlobContainersIncludeOption lhs,
ListBlobContainersIncludeOption rhs)
{
switch (list_blob_containers_include_option)
{
case ListBlobContainersIncludeOption::None:
return "";
case ListBlobContainersIncludeOption::Metadata:
return "metadata";
default:
return std::string();
}
using type = std::underlying_type_t<ListBlobContainersIncludeOption>;
return static_cast<ListBlobContainersIncludeOption>(
static_cast<type>(lhs) | static_cast<type>(rhs));
}
inline ListBlobContainersIncludeOption ListBlobContainersIncludeOptionFromString(
const std::string& list_blob_containers_include_option)
inline ListBlobContainersIncludeOption& operator|=(
ListBlobContainersIncludeOption& lhs,
ListBlobContainersIncludeOption rhs)
{
if (list_blob_containers_include_option == "")
lhs = lhs | rhs;
return lhs;
}
inline ListBlobContainersIncludeOption operator&(
ListBlobContainersIncludeOption lhs,
ListBlobContainersIncludeOption rhs)
{
using type = std::underlying_type_t<ListBlobContainersIncludeOption>;
return static_cast<ListBlobContainersIncludeOption>(
static_cast<type>(lhs) & static_cast<type>(rhs));
}
inline ListBlobContainersIncludeOption& operator&=(
ListBlobContainersIncludeOption& lhs,
ListBlobContainersIncludeOption rhs)
{
lhs = lhs & rhs;
return lhs;
}
inline std::string ListBlobContainersIncludeOptionToString(
const ListBlobContainersIncludeOption& val)
{
ListBlobContainersIncludeOption value_list[] = {
ListBlobContainersIncludeOption::Metadata,
};
const char* string_list[] = {
"metadata",
};
std::string ret;
for (std::size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobContainersIncludeOption); ++i)
{
return ListBlobContainersIncludeOption::None;
if ((val & value_list[i]) == value_list[i])
{
if (!ret.empty())
{
ret += ",";
}
ret += string_list[i];
}
}
if (list_blob_containers_include_option == "metadata")
{
return ListBlobContainersIncludeOption::Metadata;
}
throw std::runtime_error(
"cannot convert " + list_blob_containers_include_option
+ " to ListBlobContainersIncludeOption");
return ret;
}
enum class ListBlobsIncludeItem
{
Copy,
Deleted,
Metadata,
Snapshots,
UncomittedBlobs,
}; // enum class ListBlobsIncludeItem
None = 0,
Copy = 1,
Deleted = 2,
Metadata = 4,
Snapshots = 8,
UncomittedBlobs = 16,
}; // bitwise enum ListBlobsIncludeItem
inline std::string ListBlobsIncludeItemToString(
const ListBlobsIncludeItem& list_blobs_include_item)
inline ListBlobsIncludeItem operator|(ListBlobsIncludeItem lhs, ListBlobsIncludeItem rhs)
{
switch (list_blobs_include_item)
{
case ListBlobsIncludeItem::Copy:
return "copy";
case ListBlobsIncludeItem::Deleted:
return "deleted";
case ListBlobsIncludeItem::Metadata:
return "metadata";
case ListBlobsIncludeItem::Snapshots:
return "snapshots";
case ListBlobsIncludeItem::UncomittedBlobs:
return "uncommittedblobs";
default:
return std::string();
}
using type = std::underlying_type_t<ListBlobsIncludeItem>;
return static_cast<ListBlobsIncludeItem>(static_cast<type>(lhs) | static_cast<type>(rhs));
}
inline ListBlobsIncludeItem ListBlobsIncludeItemFromString(
const std::string& list_blobs_include_item)
inline ListBlobsIncludeItem& operator|=(ListBlobsIncludeItem& lhs, ListBlobsIncludeItem rhs)
{
if (list_blobs_include_item == "copy")
lhs = lhs | rhs;
return lhs;
}
inline ListBlobsIncludeItem operator&(ListBlobsIncludeItem lhs, ListBlobsIncludeItem rhs)
{
using type = std::underlying_type_t<ListBlobsIncludeItem>;
return static_cast<ListBlobsIncludeItem>(static_cast<type>(lhs) & static_cast<type>(rhs));
}
inline ListBlobsIncludeItem& operator&=(ListBlobsIncludeItem& lhs, ListBlobsIncludeItem rhs)
{
lhs = lhs & rhs;
return lhs;
}
inline std::string ListBlobsIncludeItemToString(const ListBlobsIncludeItem& val)
{
ListBlobsIncludeItem value_list[] = {
ListBlobsIncludeItem::Copy,
ListBlobsIncludeItem::Deleted,
ListBlobsIncludeItem::Metadata,
ListBlobsIncludeItem::Snapshots,
ListBlobsIncludeItem::UncomittedBlobs,
};
const char* string_list[] = {
"copy",
"deleted",
"metadata",
"snapshots",
"uncommittedblobs",
};
std::string ret;
for (std::size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobsIncludeItem); ++i)
{
return ListBlobsIncludeItem::Copy;
if ((val & value_list[i]) == value_list[i])
{
if (!ret.empty())
{
ret += ",";
}
ret += string_list[i];
}
}
if (list_blobs_include_item == "deleted")
{
return ListBlobsIncludeItem::Deleted;
}
if (list_blobs_include_item == "metadata")
{
return ListBlobsIncludeItem::Metadata;
}
if (list_blobs_include_item == "snapshots")
{
return ListBlobsIncludeItem::Snapshots;
}
if (list_blobs_include_item == "uncommittedblobs")
{
return ListBlobsIncludeItem::UncomittedBlobs;
}
throw std::runtime_error(
"cannot convert " + list_blobs_include_item + " to ListBlobsIncludeItem");
return ret;
}
struct PageBlobInfo
@ -1052,7 +1089,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> Prefix;
Azure::Core::Nullable<std::string> Marker;
Azure::Core::Nullable<int32_t> MaxResults;
Azure::Core::Nullable<ListBlobContainersIncludeOption> IncludeMetadata;
ListBlobContainersIncludeOption IncludeMetadata = ListBlobContainersIncludeOption::None;
}; // struct ListBlobContainersOptions
static Azure::Core::Http::Request ListBlobContainersConstructRequest(
@ -1081,10 +1118,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddQueryParameter("maxresults", std::to_string(options.MaxResults.GetValue()));
}
if (options.IncludeMetadata.HasValue())
std::string list_blob_containers_include_option
= ListBlobContainersIncludeOptionToString(options.IncludeMetadata);
if (!list_blob_containers_include_option.empty())
{
std::string list_blob_containers_include_option
= ListBlobContainersIncludeOptionToString(options.IncludeMetadata.GetValue());
request.AddQueryParameter("include", list_blob_containers_include_option);
}
return request;
@ -1752,6 +1789,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct DeleteOptions
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
}; // struct DeleteOptions
@ -1770,6 +1808,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -1826,6 +1868,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySHA256;
Azure::Core::Nullable<std::string> EncryptionAlgorithm;
Azure::Core::Nullable<std::string> LeaseId;
}; // struct GetPropertiesOptions
static Azure::Core::Http::Request GetPropertiesConstructRequest(
@ -1854,6 +1897,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("x-ms-encryption-algorithm", options.EncryptionAlgorithm.GetValue());
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
return request;
}
@ -1927,6 +1974,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Core::Nullable<int32_t> Timeout;
std::map<std::string, std::string> Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
}; // struct SetMetadataOptions
@ -1959,6 +2007,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -2014,7 +2066,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> Delimiter;
Azure::Core::Nullable<std::string> Marker;
Azure::Core::Nullable<int32_t> MaxResults;
std::vector<ListBlobsIncludeItem> Include;
ListBlobsIncludeItem Include = ListBlobsIncludeItem::None;
}; // struct ListBlobsOptions
static Azure::Core::Http::Request ListBlobsConstructRequest(
@ -2048,18 +2100,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddQueryParameter("maxresults", std::to_string(options.MaxResults.GetValue()));
}
std::string options_include_str;
for (auto i : options.Include)
std::string list_blobs_include_item = ListBlobsIncludeItemToString(options.Include);
if (!list_blobs_include_item.empty())
{
if (!options_include_str.empty())
{
options_include_str += ",";
}
options_include_str += ListBlobsIncludeItemToString(i);
}
if (!options_include_str.empty())
{
request.AddQueryParameter("include", options_include_str);
request.AddQueryParameter("include", list_blobs_include_item);
}
return request;
}
@ -2563,6 +2607,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySHA256;
Azure::Core::Nullable<std::string> EncryptionAlgorithm;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
@ -2625,6 +2670,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("If-None-Match", options.IfNoneMatch.GetValue());
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
return request;
}
@ -2776,6 +2825,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<DeleteSnapshotsOption> DeleteSnapshots;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
@ -2801,6 +2851,10 @@ namespace Azure { namespace Storage { namespace Blobs {
"x-ms-delete-snapshots",
DeleteSnapshotsOptionToString(options.DeleteSnapshots.GetValue()));
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -2923,6 +2977,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct GetPropertiesOptions
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
@ -2942,6 +2997,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -3147,6 +3206,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySHA256;
Azure::Core::Nullable<std::string> EncryptionAlgorithm;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
@ -3204,6 +3264,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("x-ms-encryption-algorithm", options.EncryptionAlgorithm.GetValue());
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -3277,6 +3341,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySHA256;
Azure::Core::Nullable<std::string> EncryptionAlgorithm;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
@ -3323,6 +3388,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("x-ms-encryption-algorithm", options.EncryptionAlgorithm.GetValue());
}
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
if (options.IfModifiedSince.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
@ -4437,10 +4506,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<BlockListTypeOption> ListType;
Azure::Core::Nullable<std::string> IfModifiedSince;
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
Azure::Core::Nullable<std::string> IfMatch;
Azure::Core::Nullable<std::string> IfNoneMatch;
Azure::Core::Nullable<std::string> LeaseId;
}; // struct GetBlockListOptions
static Azure::Core::Http::Request GetBlockListConstructRequest(
@ -4463,21 +4529,9 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
}
if (options.IfModifiedSince.HasValue())
if (options.LeaseId.HasValue())
{
request.AddHeader("If-Modified-Since", options.IfModifiedSince.GetValue());
}
if (options.IfUnmodifiedSince.HasValue())
{
request.AddHeader("If-Unmodified-Since", options.IfUnmodifiedSince.GetValue());
}
if (options.IfMatch.HasValue())
{
request.AddHeader("If-Match", options.IfMatch.GetValue());
}
if (options.IfNoneMatch.HasValue())
{
request.AddHeader("If-None-Match", options.IfNoneMatch.GetValue());
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
}
return request;
}

View File

@ -0,0 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#pragma once
#include "nullable.hpp"
#include <string>
namespace Azure { namespace Storage {
/**
* @brief Specifies HTTP options for conditional requests based on modification time value.
*/
struct LastModifiedTimeAccessConditions
{
/**
* @brief Specify this header to perform the operation only if the resource has been
* modified since the specified time.
*/
Azure::Core::Nullable<std::string> IfModifiedSince;
/**
* @brief Specify this header to perform the operation only if the resource has not been
* modified since the specified date/time.
*/
Azure::Core::Nullable<std::string> IfUnmodifiedSince;
};
/**
* @brief Specifies HTTP options for conditional requests based on and ETag value.
*/
struct ETagAccessConditions
{
/**
* @brief Specify this header to perform the operation only if the resource's ETag
* matches the value specified.
*/
Azure::Core::Nullable<std::string> IfMatch;
/**
* @brief Specify this header to perform the operation only if the resource's ETag does
* not match the value specified. Specify the wildcard character (*) to perform the operation
* only if the resource does not exist, and fail the operation if it does exist.
*/
Azure::Core::Nullable<std::string> IfNoneMatch;
};
/**
* @brief Specifies HTTP options for conditional requests based on lease.
*/
struct LeaseAccessConditions
{
/**
* @brief Specify this header to perform the operation only if the resource has an
* active lease mathing this id.
*/
Azure::Core::Nullable<std::string> LeaseId;
};
}} // namespace Azure::Storage

View File

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#pragma once
namespace Azure { namespace Storage { namespace Details {
constexpr static const char* c_ConnectionStringTagAccountName = "AccountName";
constexpr static const char* c_ConnectionStringTagAccountKey = "AccountKey";
constexpr static const char* c_ConnectionStringTagBlobEndpoint = "BlobEndpoint";
constexpr static const char* c_ConnectionStringTagDataLakeEndpoint = "AdlsEndpoint";
constexpr static const char* c_ConnectionStringTagEndpointSuffix = "EndpointSuffix";
constexpr static const char* c_ConnectionStringTagDefaultEndpointsProtocol
= "DefaultEndpointsProtocol";
constexpr static const char* c_DfsEndpointIdentifier = "dfs";
}}} // namespace Azure::Storage::Details

View File

@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#pragma once
namespace Azure { namespace Storage { namespace Details {
constexpr static const char* c_HttpQuerySnapshot = "snapshot";
constexpr static const char* c_HttpQueryVersionId = "versionid";
}}} // namespace Azure::Storage::Details

View File

@ -3,6 +3,7 @@
#include "blobs/append_blob_client.hpp"
#include "common/constants.hpp"
#include "common/storage_common.hpp"
namespace Azure { namespace Storage { namespace Blobs {
@ -48,11 +49,11 @@ namespace Azure { namespace Storage { namespace Blobs {
AppendBlobClient newClient(*this);
if (snapshot.empty())
{
newClient.m_blobUrl.RemoveQuery("snapshot");
newClient.m_blobUrl.RemoveQuery(Details::c_HttpQuerySnapshot);
}
else
{
newClient.m_blobUrl.AppendQuery("snapshot", snapshot);
newClient.m_blobUrl.AppendQuery(Details::c_HttpQuerySnapshot, snapshot);
}
return newClient;
}
@ -62,10 +63,11 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobRestClient::AppendBlob::CreateOptions protocolLayerOptions;
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::AppendBlob::Create(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -77,13 +79,13 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobRestClient::AppendBlob::AppendBlockOptions protocolLayerOptions;
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.MaxSize = options.MaxSize;
protocolLayerOptions.AppendPosition = options.AppendPosition;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.MaxSize = options.Conditions.MaxSize;
protocolLayerOptions.AppendPosition = options.Conditions.AppendPosition;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::AppendBlob::AppendBlock(
options.Context, *m_pipeline, m_blobUrl.ToString(), content, protocolLayerOptions);
}
@ -109,13 +111,13 @@ namespace Azure { namespace Storage { namespace Blobs {
}
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.MaxSize = options.MaxSize;
protocolLayerOptions.AppendPosition = options.AppendPosition;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.MaxSize = options.Conditions.MaxSize;
protocolLayerOptions.AppendPosition = options.Conditions.AppendPosition;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::AppendBlob::AppendBlockFromUri(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}

View File

@ -8,6 +8,7 @@
#include "blobs/page_blob_client.hpp"
#include "common/common_headers_request_policy.hpp"
#include "common/concurrent_transfer.hpp"
#include "common/constants.hpp"
#include "common/file_io.hpp"
#include "common/shared_key_policy.hpp"
#include "common/storage_common.hpp"
@ -113,11 +114,11 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobClient newClient(*this);
if (snapshot.empty())
{
newClient.m_blobUrl.RemoveQuery("snapshot");
newClient.m_blobUrl.RemoveQuery(Details::c_HttpQuerySnapshot);
}
else
{
newClient.m_blobUrl.AppendQuery("snapshot", snapshot);
newClient.m_blobUrl.AppendQuery(Details::c_HttpQuerySnapshot, snapshot);
}
return newClient;
}
@ -136,10 +137,11 @@ namespace Azure { namespace Storage { namespace Blobs {
options.Offset.GetValue(),
std::numeric_limits<std::remove_reference_t<decltype(options.Offset.GetValue())>>::max());
}
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::Download(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
@ -402,10 +404,11 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobProperties BlobClient::GetProperties(const GetBlobPropertiesOptions& options) const
{
BlobRestClient::Blob::GetPropertiesOptions protocolLayerOptions;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::GetProperties(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -416,10 +419,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Blob::SetHttpHeadersOptions protocolLayerOptions;
protocolLayerOptions.HttpHeaders = std::move(httpHeaders);
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::SetHttpHeaders(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -430,10 +434,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Blob::SetMetadataOptions protocolLayerOptions;
protocolLayerOptions.Metadata = std::move(metadata);
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::SetMetadata(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -456,18 +461,18 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobRestClient::Blob::StartCopyFromUriOptions protocolLayerOptions;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.SourceUri = sourceUri;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.SourceLeaseId = options.SourceLeaseId;
protocolLayerOptions.Tier = options.Tier;
protocolLayerOptions.RehydratePriority = options.RehydratePriority;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.SourceIfModifiedSince = options.SourceIfModifiedSince;
protocolLayerOptions.SourceIfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.SourceIfMatch = options.SourceIfMatch;
protocolLayerOptions.SourceIfNoneMatch = options.SourceIfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
protocolLayerOptions.SourceLeaseId = options.SourceConditions.LeaseId;
protocolLayerOptions.SourceIfModifiedSince = options.SourceConditions.IfModifiedSince;
protocolLayerOptions.SourceIfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.SourceIfMatch = options.SourceConditions.IfMatch;
protocolLayerOptions.SourceIfNoneMatch = options.SourceConditions.IfNoneMatch;
return BlobRestClient::Blob::StartCopyFromUri(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -478,7 +483,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Blob::AbortCopyFromUriOptions protocolLayerOptions;
protocolLayerOptions.CopyId = copyId;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
return BlobRestClient::Blob::AbortCopyFromUri(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -487,11 +492,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Blob::CreateSnapshotOptions protocolLayerOptions;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::CreateSnapshot(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -500,10 +505,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Blob::DeleteOptions protocolLayerOptions;
protocolLayerOptions.DeleteSnapshots = options.DeleteSnapshots;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::Blob::Delete(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}

View File

@ -136,8 +136,9 @@ namespace Azure { namespace Storage { namespace Blobs {
const DeleteBlobContainerOptions& options) const
{
BlobRestClient::Container::DeleteOptions protocolLayerOptions;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
return BlobRestClient::Container::Delete(
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
}
@ -145,8 +146,8 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobContainerProperties BlobContainerClient::GetProperties(
const GetBlobContainerPropertiesOptions& options) const
{
unused(options);
BlobRestClient::Container::GetPropertiesOptions protocolLayerOptions;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
return BlobRestClient::Container::GetProperties(
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
}
@ -157,7 +158,8 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::Container::SetMetadataOptions protocolLayerOptions;
protocolLayerOptions.Metadata = metadata;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
return BlobRestClient::Container::SetMetadata(
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
}

View File

@ -111,14 +111,7 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.Prefix = options.Prefix;
protocolLayerOptions.Marker = options.Marker;
protocolLayerOptions.MaxResults = options.MaxResults;
protocolLayerOptions.IncludeMetadata = ListBlobContainersIncludeOption::None;
for (auto i : options.Include)
{
if (i == ListBlobContainersIncludeOption::Metadata)
{
protocolLayerOptions.IncludeMetadata = i;
}
}
protocolLayerOptions.IncludeMetadata = options.Include;
return BlobRestClient::Service::ListBlobContainers(
options.Context, *m_pipeline, m_serviceUrl.ToString(), protocolLayerOptions);
}

View File

@ -4,6 +4,7 @@
#include "blobs/block_blob_client.hpp"
#include "common/concurrent_transfer.hpp"
#include "common/constants.hpp"
#include "common/crypt.hpp"
#include "common/file_io.hpp"
#include "common/storage_common.hpp"
@ -51,11 +52,11 @@ namespace Azure { namespace Storage { namespace Blobs {
BlockBlobClient newClient(*this);
if (snapshot.empty())
{
newClient.m_blobUrl.RemoveQuery("snapshot");
newClient.m_blobUrl.RemoveQuery(Details::c_HttpQuerySnapshot);
}
else
{
newClient.m_blobUrl.AppendQuery("snapshot", snapshot);
newClient.m_blobUrl.AppendQuery(Details::c_HttpQuerySnapshot, snapshot);
}
return newClient;
}
@ -70,10 +71,11 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.Tier = options.Tier;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::BlockBlob::Upload(
options.Context, *m_pipeline, m_blobUrl.ToString(), content, protocolLayerOptions);
}
@ -206,6 +208,7 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.BlockId = blockId;
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
return BlobRestClient::BlockBlob::StageBlock(
options.Context, *m_pipeline, m_blobUrl.ToString(), content, protocolLayerOptions);
}
@ -233,11 +236,11 @@ namespace Azure { namespace Storage { namespace Blobs {
}
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.SourceIfModifiedSince = options.SourceIfModifiedSince;
protocolLayerOptions.SourceIfUnmodifiedSince = options.SourceIfUnmodifiedSince;
protocolLayerOptions.SourceIfMatch = options.SourceIfMatch;
protocolLayerOptions.SourceIfNoneMatch = options.SourceIfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.SourceIfModifiedSince = options.SourceConditions.IfModifiedSince;
protocolLayerOptions.SourceIfUnmodifiedSince = options.SourceConditions.IfUnmodifiedSince;
protocolLayerOptions.SourceIfMatch = options.SourceConditions.IfMatch;
protocolLayerOptions.SourceIfNoneMatch = options.SourceConditions.IfNoneMatch;
return BlobRestClient::BlockBlob::StageBlockFromUri(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -251,10 +254,11 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.Tier = options.Tier;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::BlockBlob::CommitBlockList(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -263,10 +267,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::BlockBlob::GetBlockListOptions protocolLayerOptions;
protocolLayerOptions.ListType = options.ListType;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
return BlobRestClient::BlockBlob::GetBlockList(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}

View File

@ -3,6 +3,7 @@
#include "blobs/page_blob_client.hpp"
#include "common/constants.hpp"
#include "common/storage_common.hpp"
namespace Azure { namespace Storage { namespace Blobs {
@ -46,11 +47,11 @@ namespace Azure { namespace Storage { namespace Blobs {
PageBlobClient newClient(*this);
if (snapshot.empty())
{
newClient.m_blobUrl.RemoveQuery("snapshot");
newClient.m_blobUrl.RemoveQuery(Details::c_HttpQuerySnapshot);
}
else
{
newClient.m_blobUrl.AppendQuery("snapshot", snapshot);
newClient.m_blobUrl.AppendQuery(Details::c_HttpQuerySnapshot, snapshot);
}
return newClient;
}
@ -65,10 +66,11 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
protocolLayerOptions.Metadata = options.Metadata;
protocolLayerOptions.Tier = options.Tier;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::Create(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -82,11 +84,11 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.Range = std::make_pair(offset, offset + content.Length() - 1);
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::UploadPages(
options.Context, *m_pipeline, m_blobUrl.ToString(), content, protocolLayerOptions);
}
@ -106,11 +108,11 @@ namespace Azure { namespace Storage { namespace Blobs {
= std::make_pair(destinationoffset, destinationoffset + sourceLength - 1);
protocolLayerOptions.ContentMD5 = options.ContentMD5;
protocolLayerOptions.ContentCRC64 = options.ContentCRC64;
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::UploadPagesFromUri(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -122,11 +124,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::PageBlob::ClearPagesOptions protocolLayerOptions;
protocolLayerOptions.Range = std::make_pair(offset, offset + length - 1);
protocolLayerOptions.LeaseId = options.LeaseId;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::ClearPages(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -137,10 +139,11 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::PageBlob::ResizeOptions protocolLayerOptions;
protocolLayerOptions.BlobContentLength = blobContentLength;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::Resize(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}
@ -155,10 +158,11 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.Range = std::make_pair(
options.Offset.GetValue(), options.Offset.GetValue() + options.Length.GetValue() - 1);
}
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.LeaseId = options.Conditions.LeaseId;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
auto protocolLayerResponse = BlobRestClient::PageBlob::GetPageRanges(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
@ -187,10 +191,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
BlobRestClient::PageBlob::CopyIncrementalOptions protocolLayerOptions;
protocolLayerOptions.CopySource = sourceUri;
protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.IfMatch;
protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
protocolLayerOptions.IfModifiedSince = options.Conditions.IfModifiedSince;
protocolLayerOptions.IfUnmodifiedSince = options.Conditions.IfUnmodifiedSince;
protocolLayerOptions.IfMatch = options.Conditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.Conditions.IfNoneMatch;
return BlobRestClient::PageBlob::CopyIncremental(
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
}

View File

@ -12,9 +12,11 @@ namespace Azure { namespace Storage {
Core::Http::Request& request,
Core::Http::NextHttpPolicy nextHttpPolicy) const
{
const char* c_HttpHeaderDate = "Date";
const char* c_HttpHeaderXMsDate = "x-ms-date";
const auto& headers = request.GetHeaders();
if (headers.find("Date") == headers.end() && headers.find("x-ms-date") == headers.end())
if (headers.find(c_HttpHeaderDate) == headers.end())
{
// add x-ms-date header in RFC1123 format
// TODO: call helper function provided by Azure Core when they provide one.
@ -27,7 +29,7 @@ namespace Azure { namespace Storage {
#endif
char dateString[128];
strftime(dateString, sizeof(dateString), "%a, %d %b %Y %H:%M:%S GMT", &ct);
request.AddHeader("x-ms-date", dateString);
request.AddHeader(c_HttpHeaderXMsDate, dateString);
}
return nextHttpPolicy.Send(ctx, request);

View File

@ -21,7 +21,7 @@ namespace Azure { namespace Storage { namespace Test {
= std::make_shared<Azure::Storage::Blobs::AppendBlobClient>(std::move(appendBlobClient));
m_blobContent.resize(100);
RandomBuffer(reinterpret_cast<char*>(&m_blobContent[0]), m_blobContent.size());
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"KEY2", "Value2"}};
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"key2", "Value2"}};
m_blobUploadOptions.HttpHeaders.ContentType = "application/x-binary";
m_blobUploadOptions.HttpHeaders.ContentLanguage = "en-US";
m_blobUploadOptions.HttpHeaders.ContentDisposition = "attachment";
@ -57,19 +57,19 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(properties.ContentLength, static_cast<int64_t>(m_blobContent.size()));
Azure::Storage::Blobs::AppendBlockOptions options;
options.AppendPosition = 1_MB;
options.Conditions.AppendPosition = 1_MB;
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
EXPECT_THROW(appendBlobClient.AppendBlock(blockContent, options), std::runtime_error);
options.AppendPosition = properties.ContentLength;
options.Conditions.AppendPosition = properties.ContentLength;
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
appendBlobClient.AppendBlock(blockContent, options);
properties = appendBlobClient.GetProperties();
options = Azure::Storage::Blobs::AppendBlockOptions();
options.MaxSize = properties.ContentLength + m_blobContent.size() - 1;
options.Conditions.MaxSize = properties.ContentLength + m_blobContent.size() - 1;
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
EXPECT_THROW(appendBlobClient.AppendBlock(blockContent, options), std::runtime_error);
options.MaxSize = properties.ContentLength + m_blobContent.size();
options.Conditions.MaxSize = properties.ContentLength + m_blobContent.size();
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
appendBlobClient.AppendBlock(blockContent, options);

View File

@ -29,7 +29,7 @@ namespace Azure { namespace Storage { namespace Test {
Azure::Storage::Blobs::CreateBlobContainerOptions options;
std::map<std::string, std::string> metadata;
metadata["key1"] = "one";
metadata["KEY2"] = "TWO";
metadata["key2"] = "TWO";
options.Metadata = metadata;
auto res = container_client.Create(options);
EXPECT_FALSE(res.RequestId.empty());
@ -49,7 +49,7 @@ namespace Azure { namespace Storage { namespace Test {
{
std::map<std::string, std::string> metadata;
metadata["key1"] = "one";
metadata["KEY2"] = "TWO";
metadata["key2"] = "TWO";
auto res = m_blobContainerClient->SetMetadata(metadata);
EXPECT_FALSE(res.RequestId.empty());
EXPECT_FALSE(res.Date.empty());

View File

@ -19,8 +19,8 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(BlobServiceClientTest, ListContainers)
{
const std::string prefix1 = "prefix1-";
const std::string prefix2 = "prefix2-";
const std::string prefix1 = "prefix1-" + LowercaseRandomString() + "-";
const std::string prefix2 = "prefix2-" + LowercaseRandomString() + "-";
std::set<std::string> p1Containers;
std::set<std::string> p2Containers;

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace Test {
= std::make_shared<Azure::Storage::Blobs::BlockBlobClient>(std::move(blockBlobClient));
m_blobContent.resize(static_cast<std::size_t>(8_MB));
RandomBuffer(reinterpret_cast<char*>(&m_blobContent[0]), m_blobContent.size());
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"KEY2", "Value2"}};
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"key2", "Value2"}};
m_blobUploadOptions.HttpHeaders.ContentType = "application/x-binary";
m_blobUploadOptions.HttpHeaders.ContentLanguage = "en-US";
m_blobUploadOptions.HttpHeaders.ContentDisposition = "attachment";
@ -176,7 +176,7 @@ namespace Azure { namespace Storage { namespace Test {
std::runtime_error);
Azure::Storage::Blobs::CreateSnapshotOptions options;
options.Metadata = {{"snapshotkey1", "snapshotvalue1"}, {"snapshotKEY2", "SNAPSHOTVALUE2"}};
options.Metadata = {{"snapshotkey1", "snapshotvalue1"}, {"snapshotkey2", "SNAPSHOTVALUE2"}};
res = m_blockBlobClient->CreateSnapshot(options);
EXPECT_FALSE(res.Snapshot.empty());
snapshotClient = m_blockBlobClient->WithSnapshot(res.Snapshot);

View File

@ -21,7 +21,7 @@ namespace Azure { namespace Storage { namespace Test {
= std::make_shared<Azure::Storage::Blobs::PageBlobClient>(std::move(pageBlobClient));
m_blobContent.resize(static_cast<std::size_t>(1_KB));
RandomBuffer(reinterpret_cast<char*>(&m_blobContent[0]), m_blobContent.size());
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"KEY2", "Value2"}};
m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"key2", "Value2"}};
m_blobUploadOptions.HttpHeaders.ContentType = "application/x-binary";
m_blobUploadOptions.HttpHeaders.ContentLanguage = "en-US";
m_blobUploadOptions.HttpHeaders.ContentDisposition = "attachment";