AccessType and ListType should be non-nullable (#1408)

* access type and block list type is not nullable

* access type is optional in protocol layer

* changelog
This commit is contained in:
JinmingHu 2021-01-20 14:29:13 +08:00 committed by GitHub
parent 3f67c21ba8
commit 4c322f3b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 19 deletions

View File

@ -9,6 +9,8 @@
### Breaking Changes
- `UserDelegationKey` was changed to a member of `GetUserDelegationKeyResult` rather than a typedef like before.
- `AccessType` in `CreateBlobContainerOptions` was changed to non-nullable.
- `ListType` in `GetBlockListOptions` was changed to non-nullable.
## 12.0.0-beta.6 (2020-01-14)

View File

@ -286,7 +286,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* @brief Specifies whether data in the container may be accessed publicly and the level
* of access.
*/
Azure::Core::Nullable<Models::PublicAccessType> AccessType;
Models::PublicAccessType AccessType = Models::PublicAccessType::Private;
/**
* @brief Name-value pairs to associate with the container as metadata.
@ -438,7 +438,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* @brief Specifies whether data in the container may be accessed publicly and the level
* of access.
*/
Azure::Core::Nullable<Models::PublicAccessType> AccessType;
Models::PublicAccessType AccessType = Models::PublicAccessType::Private;
/**
* @brief Stored access policies that you can use to provide fine grained control over
@ -1080,7 +1080,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* @brief Specifies whether to return the list of committed blocks, the list of uncommitted
* blocks, or both lists together.
*/
Azure::Core::Nullable<Models::BlockListTypeOption> ListType;
Models::BlockListTypeOption ListType = Models::BlockListTypeOption::Committed;
/**
* @brief Optional conditions that must be met to perform this operation.

View File

@ -3055,7 +3055,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct CreateBlobContainerOptions
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<PublicAccessType> AccessType;
PublicAccessType AccessType = PublicAccessType::Private;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> DefaultEncryptionScope;
Azure::Core::Nullable<bool> PreventEncryptionScopeOverride;
@ -3081,9 +3081,9 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
if (options.AccessType.HasValue())
if (!options.AccessType.Get().empty())
{
request.AddHeader("x-ms-blob-public-access", options.AccessType.GetValue().Get());
request.AddHeader("x-ms-blob-public-access", options.AccessType.Get());
}
if (options.DefaultEncryptionScope.HasValue())
{
@ -3529,8 +3529,12 @@ namespace Azure { namespace Storage { namespace Blobs {
response.LastModified = Azure::Core::DateTime::Parse(
httpResponse.GetHeaders().at("last-modified"),
Azure::Core::DateTime::DateFormat::Rfc1123);
response.AccessType
= PublicAccessType(httpResponse.GetHeaders().at("x-ms-blob-public-access"));
auto x_ms_blob_public_access__iterator
= httpResponse.GetHeaders().find("x-ms-blob-public-access");
if (x_ms_blob_public_access__iterator != httpResponse.GetHeaders().end())
{
response.AccessType = PublicAccessType(x_ms_blob_public_access__iterator->second);
}
return Azure::Core::Response<GetBlobContainerAccessPolicyResult>(
std::move(response), std::move(pHttpResponse));
}
@ -3538,7 +3542,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct SetBlobContainerAccessPolicyOptions
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<PublicAccessType> AccessType;
PublicAccessType AccessType = PublicAccessType::Private;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<Azure::Core::DateTime> IfModifiedSince;
Azure::Core::Nullable<Azure::Core::DateTime> IfUnmodifiedSince;
@ -3572,9 +3576,9 @@ namespace Azure { namespace Storage { namespace Blobs {
}
request.GetUrl().AppendQueryParameter("restype", "container");
request.GetUrl().AppendQueryParameter("comp", "acl");
if (options.AccessType.HasValue())
if (!options.AccessType.Get().empty())
{
request.AddHeader("x-ms-blob-public-access", options.AccessType.GetValue().Get());
request.AddHeader("x-ms-blob-public-access", options.AccessType.Get());
}
if (options.LeaseId.HasValue())
{
@ -7491,7 +7495,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct GetBlockListOptions
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<BlockListTypeOption> ListType;
BlockListTypeOption ListType = BlockListTypeOption::Committed;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfTags;
}; // struct GetBlockListOptions
@ -7505,12 +7509,8 @@ namespace Azure { namespace Storage { namespace Blobs {
unused(options);
auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Get, url);
request.GetUrl().AppendQueryParameter("comp", "blocklist");
if (options.ListType.HasValue())
{
request.GetUrl().AppendQueryParameter(
"blocklisttype",
Storage::Details::UrlEncodeQueryParameter(options.ListType.GetValue().Get()));
}
request.GetUrl().AppendQueryParameter(
"blocklisttype", Storage::Details::UrlEncodeQueryParameter(options.ListType.Get()));
request.AddHeader("x-ms-version", "2020-02-10");
if (options.Timeout.HasValue())
{

View File

@ -406,7 +406,7 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_FALSE(ret2->RequestId.empty());
EXPECT_EQ(ret2->ETag, ret->ETag);
EXPECT_EQ(ret2->LastModified, ret->LastModified);
EXPECT_EQ(ret2->AccessType, options.AccessType.GetValue());
EXPECT_EQ(ret2->AccessType, options.AccessType);
EXPECT_EQ(ret2->SignedIdentifiers, options.SignedIdentifiers);
container_client.Delete();