From c2d26ddb352a701ded204237ff4938a67020886a Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Tue, 19 Jan 2021 10:54:38 +0800 Subject: [PATCH] add request id in return types (#1395) * add request id in return types * changelog * fix bug --- sdk/storage/azure-storage-blobs/CHANGELOG.md | 7 + .../azure/storage/blobs/blob_responses.hpp | 2 - .../blobs/protocol/blob_rest_client.hpp | 328 +++++++++++++----- .../src/append_blob_client.cpp | 1 + .../azure-storage-blobs/src/blob_client.cpp | 1 + .../src/blob_container_client.cpp | 2 + .../src/page_blob_client.cpp | 1 + .../test/append_blob_client_test.cpp | 12 +- .../test/blob_container_client_test.cpp | 18 + .../test/blob_sas_test.cpp | 2 +- .../test/blob_service_client_test.cpp | 33 +- .../test/block_blob_client_test.cpp | 7 +- .../test/page_blob_client_test.cpp | 8 + .../test/datalake_sas_test.cpp | 2 +- 14 files changed, 327 insertions(+), 97 deletions(-) diff --git a/sdk/storage/azure-storage-blobs/CHANGELOG.md b/sdk/storage/azure-storage-blobs/CHANGELOG.md index b1d6bd791..57d8099e6 100644 --- a/sdk/storage/azure-storage-blobs/CHANGELOG.md +++ b/sdk/storage/azure-storage-blobs/CHANGELOG.md @@ -2,6 +2,13 @@ ## 12.0.0-beta.7 (Unreleased) +### New Features + +- Added `RequestId` in API return types. + +### Breaking Changes + +- `UserDelegationKey` was changed to a member of `GetUserDelegationKeyResult` rather than a typedef like before. ## 12.0.0-beta.6 (2020-01-14) diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp index 7032e9ed9..4c23a097d 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp @@ -11,8 +11,6 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Models { - using UserDelegationKey = GetUserDelegationKeyResult; - struct DownloadBlobToResult { std::string ETag; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp index 7b464912b..81d917b9c 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct AbortCopyBlobFromUriResult { + std::string RequestId; }; // struct AbortCopyBlobFromUriResult class AccessTier { @@ -83,6 +85,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct AcquireBlobContainerLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -90,6 +93,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct AcquireBlobLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -247,6 +251,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct BreakBlobContainerLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; int32_t LeaseTime = 0; @@ -254,6 +259,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct BreakBlobLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; int32_t LeaseTime = 0; @@ -261,6 +267,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ChangeBlobContainerLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -268,6 +275,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ChangeBlobLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -275,6 +283,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ClearPageBlobPagesResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; int64_t SequenceNumber = 0; @@ -296,6 +305,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct CreateAppendBlobResult { + std::string RequestId; bool Created = true; std::string ETag; Azure::Core::DateTime LastModified; @@ -307,6 +317,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct CreateBlobContainerResult { + std::string RequestId; bool Created = true; std::string ETag; Azure::Core::DateTime LastModified; @@ -314,6 +325,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct CreateBlobSnapshotResult { + std::string RequestId; std::string Snapshot; std::string ETag; Azure::Core::DateTime LastModified; @@ -325,6 +337,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct CreatePageBlobResult { + std::string RequestId; bool Created = true; std::string ETag; Azure::Core::DateTime LastModified; @@ -337,11 +350,13 @@ namespace Azure { namespace Storage { namespace Blobs { struct DeleteBlobContainerResult { + std::string RequestId; bool Deleted = true; }; // struct DeleteBlobContainerResult struct DeleteBlobResult { + std::string RequestId; bool Deleted = true; }; // struct DeleteBlobResult @@ -384,11 +399,13 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetBlobTagsResult { + std::string RequestId; std::map Tags; }; // struct GetBlobTagsResult struct GetPageBlobPageRangesResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; int64_t BlobContentLength = 0; @@ -396,17 +413,6 @@ namespace Azure { namespace Storage { namespace Blobs { std::vector ClearRanges; }; // struct GetPageBlobPageRangesResult - struct GetUserDelegationKeyResult - { - std::string SignedObjectId; - std::string SignedTenantId; - Azure::Core::DateTime SignedStartsOn; - Azure::Core::DateTime SignedExpiresOn; - std::string SignedService; - std::string SignedVersion; - std::string Value; - }; // struct GetUserDelegationKeyResult - enum class ListBlobContainersIncludeItem { None = 0, @@ -531,12 +537,14 @@ namespace Azure { namespace Storage { namespace Blobs { struct ReleaseBlobContainerLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; }; // struct ReleaseBlobContainerLeaseResult struct ReleaseBlobLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable SequenceNumber; @@ -544,6 +552,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct RenewBlobContainerLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -551,6 +560,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct RenewBlobLeaseResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string LeaseId; @@ -558,6 +568,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ResizePageBlobResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; int64_t SequenceNumber = 0; @@ -584,6 +595,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct SealAppendBlobResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; bool IsSealed = true; @@ -591,26 +603,31 @@ namespace Azure { namespace Storage { namespace Blobs { struct SetBlobAccessTierResult { + std::string RequestId; }; // struct SetBlobAccessTierResult struct SetBlobContainerAccessPolicyResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; }; // struct SetBlobContainerAccessPolicyResult struct SetBlobContainerMetadataResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; }; // struct SetBlobContainerMetadataResult struct SetBlobExpiryResult { + std::string RequestId; }; // struct SetBlobExpiryResult struct SetBlobHttpHeadersResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable SequenceNumber; @@ -618,6 +635,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct SetBlobMetadataResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable SequenceNumber; @@ -625,10 +643,12 @@ namespace Azure { namespace Storage { namespace Blobs { struct SetBlobTagsResult { + std::string RequestId; }; // struct SetBlobTagsResult struct SetServicePropertiesResult { + std::string RequestId; }; // struct SetServicePropertiesResult class SkuName { @@ -653,17 +673,31 @@ namespace Azure { namespace Storage { namespace Blobs { struct SubmitBlobBatchResultInternal { + std::string RequestId; std::string ContentType; }; // struct SubmitBlobBatchResultInternal struct UndeleteBlobContainerResult { + std::string RequestId; }; // struct UndeleteBlobContainerResult struct UndeleteBlobResult { + std::string RequestId; }; // struct UndeleteBlobResult + struct UserDelegationKey + { + std::string SignedObjectId; + std::string SignedTenantId; + Azure::Core::DateTime SignedStartsOn; + Azure::Core::DateTime SignedExpiresOn; + std::string SignedService; + std::string SignedVersion; + std::string Value; + }; // struct UserDelegationKey + struct BlobAnalyticsLogging { std::string Version; @@ -709,6 +743,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct FindBlobsByTagsSinglePageResult { + std::string RequestId; std::string ServiceEndpoint; std::string Where; Azure::Core::Nullable ContinuationToken; @@ -717,6 +752,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetAccountInfoResult { + std::string RequestId; Models::SkuName SkuName; Models::AccountKind AccountKind; bool IsHierarchicalNamespaceEnabled = false; @@ -724,6 +760,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetBlobContainerAccessPolicyResult { + std::string RequestId; PublicAccessType AccessType = PublicAccessType::Private; std::string ETag; Azure::Core::DateTime LastModified; @@ -732,6 +769,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetBlobContainerPropertiesResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Storage::Metadata Metadata; @@ -747,6 +785,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetBlockListResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string ContentType; @@ -755,6 +794,12 @@ namespace Azure { namespace Storage { namespace Blobs { std::vector UncommittedBlocks; }; // struct GetBlockListResult + struct GetUserDelegationKeyResult + { + std::string RequestId; + UserDelegationKey Key; + }; // struct GetUserDelegationKeyResult + struct ObjectReplicationRule { std::string RuleId; @@ -763,6 +808,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct StartCopyBlobFromUriResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string CopyId; @@ -772,6 +818,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct StartCopyPageBlobIncrementalResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; std::string CopyId; @@ -781,6 +828,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct AppendBlockFromUriResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable TransactionalContentHash; @@ -793,6 +841,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct AppendBlockResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable TransactionalContentHash; @@ -826,6 +875,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct CommitBlockListResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable VersionId; @@ -837,6 +887,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetServicePropertiesResult { + std::string RequestId; BlobAnalyticsLogging Logging; BlobMetrics HourMetrics; BlobMetrics MinuteMetrics; @@ -848,11 +899,13 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetServiceStatisticsResult { + std::string RequestId; BlobGeoReplication GeoReplication; }; // struct GetServiceStatisticsResult struct ListBlobContainersSinglePageResult { + std::string RequestId; std::string ServiceEndpoint; std::string Prefix; Azure::Core::Nullable PreviousContinuationToken; @@ -868,6 +921,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct StageBlockFromUriResult { + std::string RequestId; Azure::Core::Nullable TransactionalContentHash; bool IsServerEncrypted = false; Azure::Core::Nullable> EncryptionKeySha256; @@ -876,6 +930,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct StageBlockResult { + std::string RequestId; Azure::Core::Nullable TransactionalContentHash; bool IsServerEncrypted = false; Azure::Core::Nullable> EncryptionKeySha256; @@ -884,6 +939,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct UploadBlockBlobResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable VersionId; @@ -895,6 +951,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct UploadPageBlobPagesFromUriResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable TransactionalContentHash; @@ -906,6 +963,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct UploadPageBlobPagesResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::Nullable TransactionalContentHash; @@ -947,6 +1005,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct DownloadBlobResult { + std::string RequestId; std::unique_ptr BodyStream; std::string ETag; Azure::Core::DateTime LastModified; @@ -977,6 +1036,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct GetBlobPropertiesResult { + std::string RequestId; std::string ETag; Azure::Core::DateTime LastModified; Azure::Core::DateTime CreatedOn; @@ -1013,6 +1073,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ListBlobsByHierarchySinglePageResult { + std::string RequestId; std::string ServiceEndpoint; std::string BlobContainerName; std::string Prefix; @@ -1025,6 +1086,7 @@ namespace Azure { namespace Storage { namespace Blobs { struct ListBlobsSinglePageResult { + std::string RequestId; std::string ServiceEndpoint; std::string BlobContainerName; std::string Prefix; @@ -1167,6 +1229,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = ListBlobContainersSinglePageResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1221,6 +1284,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetUserDelegationKeyResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1262,6 +1326,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetServicePropertiesResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1309,6 +1374,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1344,6 +1410,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.SkuName = SkuName(httpResponse.GetHeaders().at("x-ms-sku-name")); response.AccountKind = AccountKind(httpResponse.GetHeaders().at("x-ms-account-kind")); response.IsHierarchicalNamespaceEnabled @@ -1389,6 +1456,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetServiceStatisticsResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1445,6 +1513,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = FindBlobsByTagsSinglePageResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -1737,13 +1806,6 @@ namespace Azure { namespace Storage { namespace Blobs { enum class XmlTagName { k_UserDelegationKey, - k_SignedOid, - k_SignedTid, - k_SignedStart, - k_SignedExpiry, - k_SignedService, - k_SignedVersion, - k_Value, k_Unknown, }; std::vector path; @@ -1771,84 +1833,18 @@ namespace Azure { namespace Storage { namespace Blobs { { path.emplace_back(XmlTagName::k_UserDelegationKey); } - else if (std::strcmp(node.Name, "SignedOid") == 0) - { - path.emplace_back(XmlTagName::k_SignedOid); - } - else if (std::strcmp(node.Name, "SignedTid") == 0) - { - path.emplace_back(XmlTagName::k_SignedTid); - } - else if (std::strcmp(node.Name, "SignedStart") == 0) - { - path.emplace_back(XmlTagName::k_SignedStart); - } - else if (std::strcmp(node.Name, "SignedExpiry") == 0) - { - path.emplace_back(XmlTagName::k_SignedExpiry); - } - else if (std::strcmp(node.Name, "SignedService") == 0) - { - path.emplace_back(XmlTagName::k_SignedService); - } - else if (std::strcmp(node.Name, "SignedVersion") == 0) - { - path.emplace_back(XmlTagName::k_SignedVersion); - } - else if (std::strcmp(node.Name, "Value") == 0) - { - path.emplace_back(XmlTagName::k_Value); - } else { path.emplace_back(XmlTagName::k_Unknown); } + if (path.size() == 1 && path[0] == XmlTagName::k_UserDelegationKey) + { + ret.Key = UserDelegationKeyFromXml(reader); + path.pop_back(); + } } else if (node.Type == Storage::Details::XmlNodeType::Text) { - if (path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedOid) - { - ret.SignedObjectId = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedTid) - { - ret.SignedTenantId = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedStart) - { - ret.SignedStartsOn = Azure::Core::DateTime::Parse( - node.Value, Azure::Core::DateTime::DateFormat::Rfc3339); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedExpiry) - { - ret.SignedExpiresOn = Azure::Core::DateTime::Parse( - node.Value, Azure::Core::DateTime::DateFormat::Rfc3339); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedService) - { - ret.SignedService = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_SignedVersion) - { - ret.SignedVersion = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::k_UserDelegationKey - && path[1] == XmlTagName::k_Value) - { - ret.Value = node.Value; - } } } return ret; @@ -2680,6 +2676,111 @@ namespace Azure { namespace Storage { namespace Blobs { return ret; } + static UserDelegationKey UserDelegationKeyFromXml(Storage::Details::XmlReader& reader) + { + UserDelegationKey ret; + enum class XmlTagName + { + k_SignedOid, + k_SignedTid, + k_SignedStart, + k_SignedExpiry, + k_SignedService, + k_SignedVersion, + k_Value, + k_Unknown, + }; + std::vector path; + while (true) + { + auto node = reader.Read(); + if (node.Type == Storage::Details::XmlNodeType::End) + { + break; + } + else if (node.Type == Storage::Details::XmlNodeType::EndTag) + { + if (path.size() > 0) + { + path.pop_back(); + } + else + { + break; + } + } + else if (node.Type == Storage::Details::XmlNodeType::StartTag) + { + if (std::strcmp(node.Name, "SignedOid") == 0) + { + path.emplace_back(XmlTagName::k_SignedOid); + } + else if (std::strcmp(node.Name, "SignedTid") == 0) + { + path.emplace_back(XmlTagName::k_SignedTid); + } + else if (std::strcmp(node.Name, "SignedStart") == 0) + { + path.emplace_back(XmlTagName::k_SignedStart); + } + else if (std::strcmp(node.Name, "SignedExpiry") == 0) + { + path.emplace_back(XmlTagName::k_SignedExpiry); + } + else if (std::strcmp(node.Name, "SignedService") == 0) + { + path.emplace_back(XmlTagName::k_SignedService); + } + else if (std::strcmp(node.Name, "SignedVersion") == 0) + { + path.emplace_back(XmlTagName::k_SignedVersion); + } + else if (std::strcmp(node.Name, "Value") == 0) + { + path.emplace_back(XmlTagName::k_Value); + } + else + { + path.emplace_back(XmlTagName::k_Unknown); + } + } + else if (node.Type == Storage::Details::XmlNodeType::Text) + { + if (path.size() == 1 && path[0] == XmlTagName::k_SignedOid) + { + ret.SignedObjectId = node.Value; + } + else if (path.size() == 1 && path[0] == XmlTagName::k_SignedTid) + { + ret.SignedTenantId = node.Value; + } + else if (path.size() == 1 && path[0] == XmlTagName::k_SignedStart) + { + ret.SignedStartsOn = Azure::Core::DateTime::Parse( + node.Value, Azure::Core::DateTime::DateFormat::Rfc3339); + } + else if (path.size() == 1 && path[0] == XmlTagName::k_SignedExpiry) + { + ret.SignedExpiresOn = Azure::Core::DateTime::Parse( + node.Value, Azure::Core::DateTime::DateFormat::Rfc3339); + } + else if (path.size() == 1 && path[0] == XmlTagName::k_SignedService) + { + ret.SignedService = node.Value; + } + else if (path.size() == 1 && path[0] == XmlTagName::k_SignedVersion) + { + ret.SignedVersion = node.Value; + } + else if (path.size() == 1 && path[0] == XmlTagName::k_Value) + { + ret.Value = node.Value; + } + } + } + return ret; + } + static Metadata MetadataFromXml(Storage::Details::XmlReader& reader) { Metadata ret; @@ -3005,6 +3106,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3064,6 +3166,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -3104,6 +3207,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -3143,6 +3247,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3228,6 +3333,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3299,6 +3405,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = ListBlobsSinglePageResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -3374,6 +3481,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = ListBlobsByHierarchySinglePageResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -3416,6 +3524,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetBlobContainerAccessPolicyResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3495,6 +3604,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3559,6 +3669,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3619,6 +3730,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3681,6 +3793,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3741,6 +3854,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -3804,6 +3918,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -4842,6 +4957,7 @@ namespace Azure { namespace Storage { namespace Blobs { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } response.BodyStream = httpResponse.GetBodyStream(); + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -5124,6 +5240,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -5177,6 +5294,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -5212,6 +5330,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -5299,6 +5418,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -5607,6 +5727,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -5716,6 +5837,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -5773,6 +5895,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -5914,6 +6037,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -5969,6 +6093,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -6068,6 +6193,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6138,6 +6264,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetBlobTagsResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -6190,6 +6317,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); } @@ -6264,6 +6392,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6338,6 +6467,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6414,6 +6544,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6488,6 +6619,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6571,6 +6703,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6862,6 +6995,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -6989,6 +7123,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); { const auto& headers = httpResponse.GetHeaders(); auto content_md5_iterator = headers.find("Content-MD5"); @@ -7146,6 +7281,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); { const auto& headers = httpResponse.GetHeaders(); auto content_md5_iterator = headers.find("Content-MD5"); @@ -7323,6 +7459,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -7404,6 +7541,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetBlockListResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -7701,6 +7839,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -7869,6 +8008,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8063,6 +8203,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8229,6 +8370,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8352,6 +8494,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8458,6 +8601,7 @@ namespace Azure { namespace Storage { namespace Blobs { reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); response = GetPageBlobPageRangesResultFromXml(reader); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8532,6 +8676,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -8854,6 +8999,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -9002,6 +9148,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -9181,6 +9328,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -9300,6 +9448,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ETag = httpResponse.GetHeaders().at("etag"); response.LastModified = Azure::Core::DateTime::Parse( httpResponse.GetHeaders().at("last-modified"), @@ -9348,6 +9497,7 @@ namespace Azure { namespace Storage { namespace Blobs { { throw StorageException::CreateFromResponse(std::move(pHttpResponse)); } + response.RequestId = httpResponse.GetHeaders().at("x-ms-request-id"); response.ContentType = httpResponse.GetHeaders().at("content-type"); return Azure::Core::Response( std::move(response), std::move(pHttpResponse)); diff --git a/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp index 56af513a5..812f1e594 100644 --- a/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp @@ -111,6 +111,7 @@ namespace Azure { namespace Storage { namespace Blobs { && e.ErrorCode == "BlobAlreadyExists") { Models::CreateAppendBlobResult ret; + ret.RequestId = e.RequestId; ret.Created = false; return Azure::Core::Response(std::move(ret), std::move(e.RawResponse)); } diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index 4d10e1b22..55048a664 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -633,6 +633,7 @@ namespace Azure { namespace Storage { namespace Blobs { && (e.ErrorCode == "BlobNotFound" || e.ErrorCode == "ContainerNotFound")) { Models::DeleteBlobResult ret; + ret.RequestId = e.RequestId; ret.Deleted = false; return Azure::Core::Response(std::move(ret), std::move(e.RawResponse)); } diff --git a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp index 29032cb45..04729c535 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp @@ -164,6 +164,7 @@ namespace Azure { namespace Storage { namespace Blobs { && e.ErrorCode == "ContainerAlreadyExists") { Models::CreateBlobContainerResult ret; + ret.RequestId = e.RequestId; ret.Created = false; return Azure::Core::Response( std::move(ret), std::move(e.RawResponse)); @@ -196,6 +197,7 @@ namespace Azure { namespace Storage { namespace Blobs { && e.ErrorCode == "ContainerNotFound") { Models::DeleteBlobContainerResult ret; + ret.RequestId = e.RequestId; ret.Deleted = false; return Azure::Core::Response( std::move(ret), std::move(e.RawResponse)); diff --git a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp index 7e3146e6b..05461f0ac 100644 --- a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp @@ -118,6 +118,7 @@ namespace Azure { namespace Storage { namespace Blobs { && e.ErrorCode == "BlobAlreadyExists") { Models::CreatePageBlobResult ret; + ret.RequestId = e.RequestId; ret.Created = false; return Azure::Core::Response( std::move(ret), std::move(e.RawResponse)); diff --git a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp index 9a6549123..20a8ecf2d 100644 --- a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp @@ -43,6 +43,7 @@ namespace Azure { namespace Storage { namespace Test { auto appendBlobClient = Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString( StandardStorageConnectionString(), m_containerName, RandomString()); auto blobContentInfo = appendBlobClient.Create(m_blobUploadOptions); + EXPECT_FALSE(blobContentInfo->RequestId.empty()); EXPECT_FALSE(blobContentInfo->ETag.empty()); EXPECT_TRUE(IsValidTime(blobContentInfo->LastModified)); EXPECT_TRUE(blobContentInfo->VersionId.HasValue()); @@ -51,13 +52,15 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_FALSE(blobContentInfo->EncryptionKeySha256.HasValue()); auto properties = *appendBlobClient.GetProperties(); + EXPECT_FALSE(properties.RequestId.empty()); EXPECT_TRUE(properties.CommittedBlockCount.HasValue()); EXPECT_EQ(properties.CommittedBlockCount.GetValue(), 0); EXPECT_EQ(properties.ContentLength, 0); auto blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size()); - appendBlobClient.AppendBlock(&blockContent); + auto appendResponse = appendBlobClient.AppendBlock(&blockContent); + EXPECT_FALSE(appendResponse->RequestId.empty()); properties = *appendBlobClient.GetProperties(); EXPECT_EQ(properties.CommittedBlockCount.GetValue(), 1); EXPECT_EQ(properties.ContentLength, static_cast(m_blobContent.size())); @@ -88,7 +91,9 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ( properties.ContentLength, static_cast(originalLength + m_blobContent.size())); - appendBlobClient.Delete(); + auto deleteResponse = appendBlobClient.Delete(); + EXPECT_TRUE(deleteResponse->Deleted); + EXPECT_FALSE(deleteResponse->RequestId.empty()); EXPECT_THROW(appendBlobClient.Delete(), StorageException); } @@ -284,6 +289,7 @@ namespace Azure { namespace Storage { namespace Test { sealOptions.AccessConditions.IfAppendPositionEqual = m_blobContent.size(); auto sealResult = blobClient.Seal(sealOptions); + EXPECT_FALSE(sealResult->RequestId.empty()); EXPECT_FALSE(sealResult->ETag.empty()); EXPECT_TRUE(IsValidTime(sealResult->LastModified)); EXPECT_TRUE(sealResult->IsSealed); @@ -340,6 +346,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_THROW(blobClientWithoutAuth.CreateIfNotExists(), StorageException); { auto response = blobClient.CreateIfNotExists(); + EXPECT_FALSE(response->RequestId.empty()); EXPECT_TRUE(response->Created); } auto blobContent @@ -347,6 +354,7 @@ namespace Azure { namespace Storage { namespace Test { blobClient.AppendBlock(&blobContent); { auto response = blobClient.CreateIfNotExists(); + EXPECT_FALSE(response->RequestId.empty()); EXPECT_FALSE(response->Created); } auto downloadStream = std::move(blobClient.Download()->BodyStream); diff --git a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp index 205ea8cc5..d918f4519 100644 --- a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp @@ -60,7 +60,9 @@ namespace Azure { namespace Storage { namespace Test { metadata["key2"] = "TWO"; options.Metadata = metadata; auto res = container_client.Create(options); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); + EXPECT_EQ(res->RequestId, res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId)); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); EXPECT_FALSE(res->ETag.empty()); @@ -68,7 +70,9 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_THROW(container_client.Create(), StorageException); auto res2 = container_client.Delete(); + EXPECT_FALSE(res2->RequestId.empty()); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); + EXPECT_EQ(res2->RequestId, res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId)); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -80,10 +84,12 @@ namespace Azure { namespace Storage { namespace Test { { auto response = container_client.DeleteIfExists(); EXPECT_FALSE(response->Deleted); + EXPECT_FALSE(response->RequestId.empty()); } { auto response = container_client.CreateIfNotExists(); EXPECT_TRUE(response->Created); + EXPECT_FALSE(response->RequestId.empty()); } { auto response = container_client.CreateIfNotExists(); @@ -101,6 +107,7 @@ namespace Azure { namespace Storage { namespace Test { metadata["key1"] = "one"; metadata["key2"] = "TWO"; auto res = m_blobContainerClient->SetMetadata(metadata); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -108,6 +115,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(IsValidTime(res->LastModified)); auto res2 = m_blobContainerClient->GetProperties(); + EXPECT_FALSE(res2->RequestId.empty()); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -164,6 +172,7 @@ namespace Azure { namespace Storage { namespace Test { do { auto res = m_blobContainerClient->ListBlobsSinglePage(options); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -251,6 +260,7 @@ namespace Azure { namespace Storage { namespace Test { while (true) { auto res = m_blobContainerClient->ListBlobsByHierarchySinglePage(delimiter, options); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_EQ(res->Delimiter, delimiter); EXPECT_EQ(res->Prefix, options.Prefix.GetValue()); EXPECT_TRUE(res->Items.empty()); @@ -324,6 +334,7 @@ namespace Azure { namespace Storage { namespace Test { do { auto res = m_blobContainerClient->ListBlobsSinglePage(options); + EXPECT_FALSE(res->RequestId.empty()); options.ContinuationToken = res->ContinuationToken; for (const auto& blob : res->Items) { @@ -387,10 +398,12 @@ namespace Azure { namespace Storage { namespace Test { options.SignedIdentifiers.emplace_back(identifier); auto ret = container_client.SetAccessPolicy(options); + EXPECT_FALSE(ret->RequestId.empty()); EXPECT_FALSE(ret->ETag.empty()); EXPECT_TRUE(IsValidTime(ret->LastModified)); auto ret2 = container_client.GetAccessPolicy(); + EXPECT_FALSE(ret2->RequestId.empty()); EXPECT_EQ(ret2->ETag, ret->ETag); EXPECT_EQ(ret2->LastModified, ret->LastModified); EXPECT_EQ(ret2->AccessType, options.AccessType.GetValue()); @@ -404,10 +417,12 @@ namespace Azure { namespace Storage { namespace Test { std::string leaseId1 = CreateUniqueLeaseId(); int32_t leaseDuration = 20; auto aLease = *m_blobContainerClient->AcquireLease(leaseId1, leaseDuration); + EXPECT_FALSE(aLease.RequestId.empty()); EXPECT_FALSE(aLease.ETag.empty()); EXPECT_TRUE(IsValidTime(aLease.LastModified)); EXPECT_EQ(aLease.LeaseId, leaseId1); aLease = *m_blobContainerClient->AcquireLease(leaseId1, leaseDuration); + EXPECT_FALSE(aLease.RequestId.empty()); EXPECT_FALSE(aLease.ETag.empty()); EXPECT_TRUE(IsValidTime(aLease.LastModified)); EXPECT_EQ(aLease.LeaseId, leaseId1); @@ -418,6 +433,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_FALSE(properties.LeaseDuration.GetValue().empty()); auto rLease = *m_blobContainerClient->RenewLease(leaseId1); + EXPECT_FALSE(rLease.RequestId.empty()); EXPECT_FALSE(rLease.ETag.empty()); EXPECT_TRUE(IsValidTime(rLease.LastModified)); EXPECT_EQ(rLease.LeaseId, leaseId1); @@ -425,11 +441,13 @@ namespace Azure { namespace Storage { namespace Test { std::string leaseId2 = CreateUniqueLeaseId(); EXPECT_NE(leaseId1, leaseId2); auto cLease = *m_blobContainerClient->ChangeLease(leaseId1, leaseId2); + EXPECT_FALSE(cLease.RequestId.empty()); EXPECT_FALSE(cLease.ETag.empty()); EXPECT_TRUE(IsValidTime(cLease.LastModified)); EXPECT_EQ(cLease.LeaseId, leaseId2); auto containerInfo = *m_blobContainerClient->ReleaseLease(leaseId2); + EXPECT_FALSE(containerInfo.RequestId.empty()); EXPECT_FALSE(containerInfo.ETag.empty()); EXPECT_TRUE(IsValidTime(containerInfo.LastModified)); diff --git a/sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp b/sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp index eb432d25a..5fb4c785a 100644 --- a/sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp @@ -52,7 +52,7 @@ namespace Azure { namespace Storage { namespace Test { serviceUrl, std::make_shared( AadTenantId(), AadClientId(), AadClientSecret())); - auto userDelegationKey = *blobServiceClient1.GetUserDelegationKey(sasStartsOn, sasExpiresOn); + auto userDelegationKey = blobServiceClient1.GetUserDelegationKey(sasStartsOn, sasExpiresOn)->Key; auto verify_blob_read = [&](const std::string& sas) { EXPECT_NO_THROW(blobClient0.Create()); diff --git a/sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp b/sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp index e55c3caee..4ff575345 100644 --- a/sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp @@ -3,6 +3,7 @@ #include +#include #include #include "test_base.hpp" @@ -112,6 +113,7 @@ namespace Azure { namespace Storage { namespace Test { do { auto res = m_blobServiceClient.ListBlobContainersSinglePage(options); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -167,6 +169,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlobServiceClientTest, GetProperties) { auto ret = m_blobServiceClient.GetProperties(); + EXPECT_FALSE(ret->RequestId.empty()); auto properties = *ret; auto logging = properties.Logging; EXPECT_FALSE(logging.Version.empty()); @@ -312,12 +315,14 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(downloadedProperties.DeleteRetentionPolicy, properties.DeleteRetentionPolicy); - m_blobServiceClient.SetProperties(originalProperties); + auto res = m_blobServiceClient.SetProperties(originalProperties); + EXPECT_FALSE(res->RequestId.empty()); } TEST_F(BlobServiceClientTest, AccountInfo) { auto accountInfo = *m_blobServiceClient.GetAccountInfo(); + EXPECT_FALSE(accountInfo.RequestId.empty()); EXPECT_FALSE(accountInfo.SkuName.Get().empty()); EXPECT_FALSE(accountInfo.AccountKind.Get().empty()); EXPECT_FALSE(accountInfo.IsHierarchicalNamespaceEnabled); @@ -337,6 +342,7 @@ namespace Azure { namespace Storage { namespace Test { auto secondaryServiceClient = Blobs::BlobServiceClient(InferSecondaryUrl(m_blobServiceClient.GetUrl()), keyCredential); auto serviceStatistics = *secondaryServiceClient.GetStatistics(); + EXPECT_FALSE(serviceStatistics.RequestId.empty()); EXPECT_FALSE(serviceStatistics.GeoReplication.Status.Get().empty()); if (serviceStatistics.GeoReplication.LastSyncedOn.HasValue()) { @@ -417,4 +423,29 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_NO_THROW(containerClient2.GetProperties()); } + TEST_F(BlobServiceClientTest, UserDelegationKey) + { + auto sasStartsOn = std::chrono::system_clock::now() - std::chrono::minutes(5); + auto sasExpiresOn = std::chrono::system_clock::now() + std::chrono::minutes(60); + + auto blobServiceClient1 = Blobs::BlobServiceClient( + m_blobServiceClient.GetUrl(), + std::make_shared( + AadTenantId(), AadClientId(), AadClientSecret())); + + auto getUserDelegationKeyResult + = blobServiceClient1.GetUserDelegationKey(sasStartsOn, sasExpiresOn); + + EXPECT_FALSE(getUserDelegationKeyResult->RequestId.empty()); + + auto userDelegationKey = getUserDelegationKeyResult->Key; + EXPECT_FALSE(userDelegationKey.SignedObjectId.empty()); + EXPECT_FALSE(userDelegationKey.SignedTenantId.empty()); + EXPECT_TRUE(IsValidTime(userDelegationKey.SignedStartsOn)); + EXPECT_TRUE(IsValidTime(userDelegationKey.SignedExpiresOn)); + EXPECT_FALSE(userDelegationKey.SignedService.empty()); + EXPECT_FALSE(userDelegationKey.SignedVersion.empty()); + EXPECT_FALSE(userDelegationKey.Value.empty()); + } + }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp index c82b7e02d..8fe270fa6 100644 --- a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp @@ -65,6 +65,7 @@ namespace Azure { namespace Storage { namespace Test { auto blobContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size()); auto blobContentInfo = blockBlobClient.Upload(&blobContent, m_blobUploadOptions); + EXPECT_FALSE(blobContentInfo->RequestId.empty()); EXPECT_FALSE(blobContentInfo->ETag.empty()); EXPECT_TRUE(IsValidTime(blobContentInfo->LastModified)); EXPECT_TRUE(blobContentInfo->VersionId.HasValue()); @@ -79,6 +80,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlockBlobClientTest, UploadDownload) { auto res = m_blockBlobClient->Download(); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_EQ(res->BlobSize, static_cast(m_blobContent.size())); EXPECT_EQ(res->ContentRange.Offset, 0); EXPECT_EQ(res->ContentRange.Length.GetValue(), static_cast(m_blobContent.size())); @@ -176,7 +178,7 @@ namespace Azure { namespace Storage { namespace Test { { auto blobClient = m_blobContainerClient->GetBlobClient(RandomString()); auto res = blobClient.StartCopyFromUri(m_blockBlobClient->GetUrl()); - + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -204,6 +206,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlockBlobClientTest, SnapShotVersions) { auto res = m_blockBlobClient->CreateSnapshot(); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -258,6 +261,7 @@ namespace Azure { namespace Storage { namespace Test { blockBlobClient.SetHttpHeaders(m_blobUploadOptions.HttpHeaders); auto res = blockBlobClient.GetProperties(); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); @@ -293,6 +297,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(blobContentInfo->VersionId.HasValue()); EXPECT_FALSE(blobContentInfo->VersionId.GetValue().empty()); auto res = blockBlobClient.GetBlockList(); + EXPECT_FALSE(res->RequestId.empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderRequestId).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderDate).empty()); EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::HttpHeaderXMsVersion).empty()); diff --git a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp index 160ab716f..d69b08a4b 100644 --- a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp @@ -49,6 +49,7 @@ namespace Azure { namespace Storage { namespace Test { auto pageBlobClient = Azure::Storage::Blobs::PageBlobClient::CreateFromConnectionString( StandardStorageConnectionString(), m_containerName, RandomString()); auto blobContentInfo = pageBlobClient.Create(0, m_blobUploadOptions); + EXPECT_FALSE(blobContentInfo->RequestId.empty()); EXPECT_FALSE(blobContentInfo->ETag.empty()); EXPECT_TRUE(IsValidTime(blobContentInfo->LastModified)); EXPECT_TRUE(blobContentInfo->VersionId.HasValue()); @@ -98,6 +99,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(ReadBodyStream(downloadContent->BodyStream), blobContent); auto pageRanges = *pageBlobClient.GetPageRanges(); + EXPECT_FALSE(pageRanges.RequestId.empty()); EXPECT_TRUE(pageRanges.ClearRanges.empty()); ASSERT_FALSE(pageRanges.PageRanges.empty()); EXPECT_EQ(static_cast(pageRanges.PageRanges[0].Offset), 3_KB); @@ -147,6 +149,7 @@ namespace Azure { namespace Storage { namespace Test { Azure::Core::Http::Url sourceUri(m_pageBlobClient->WithSnapshot(snapshot).GetUrl()); sourceUri.AppendQueryParameters(GetSas()); auto copyInfo = pageBlobClient.StartCopyIncremental(sourceUri.GetAbsoluteUrl()); + EXPECT_FALSE(copyInfo->RequestId.empty()); EXPECT_FALSE(copyInfo->ETag.empty()); EXPECT_TRUE(IsValidTime(copyInfo->LastModified)); EXPECT_FALSE(copyInfo->CopyId.empty()); @@ -160,6 +163,7 @@ namespace Azure { namespace Storage { namespace Test { std::string leaseId1 = CreateUniqueLeaseId(); int32_t leaseDuration = 20; auto aLease = *m_pageBlobClient->AcquireLease(leaseId1, leaseDuration); + EXPECT_FALSE(aLease.RequestId.empty()); EXPECT_FALSE(aLease.ETag.empty()); EXPECT_TRUE(IsValidTime(aLease.LastModified)); EXPECT_EQ(aLease.LeaseId, leaseId1); @@ -174,6 +178,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_FALSE(properties.LeaseDuration.GetValue().empty()); auto rLease = *m_pageBlobClient->RenewLease(leaseId1); + EXPECT_FALSE(rLease.RequestId.empty()); EXPECT_FALSE(rLease.ETag.empty()); EXPECT_TRUE(IsValidTime(rLease.LastModified)); EXPECT_EQ(rLease.LeaseId, leaseId1); @@ -181,11 +186,13 @@ namespace Azure { namespace Storage { namespace Test { std::string leaseId2 = CreateUniqueLeaseId(); EXPECT_NE(leaseId1, leaseId2); auto cLease = *m_pageBlobClient->ChangeLease(leaseId1, leaseId2); + EXPECT_FALSE(cLease.RequestId.empty()); EXPECT_FALSE(cLease.ETag.empty()); EXPECT_TRUE(IsValidTime(cLease.LastModified)); EXPECT_EQ(cLease.LeaseId, leaseId2); auto blobInfo = *m_pageBlobClient->ReleaseLease(leaseId2); + EXPECT_FALSE(blobInfo.RequestId.empty()); EXPECT_FALSE(blobInfo.ETag.empty()); EXPECT_TRUE(IsValidTime(blobInfo.LastModified)); @@ -264,6 +271,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_THROW(blobClientWithoutAuth.CreateIfNotExists(m_blobContent.size()), StorageException); { auto response = blobClient.CreateIfNotExists(m_blobContent.size()); + EXPECT_FALSE(response->RequestId.empty()); EXPECT_TRUE(response->Created); } diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_sas_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_sas_test.cpp index f6dbe7c51..aa79eb330 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_sas_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_sas_test.cpp @@ -62,7 +62,7 @@ namespace Azure { namespace Storage { namespace Test { serviceUri, std::make_shared( AadTenantId(), AadClientId(), AadClientSecret())); - auto userDelegationKey = *serviceClient1.GetUserDelegationKey(sasStartsOn, sasExpiresOn); + auto userDelegationKey = serviceClient1.GetUserDelegationKey(sasStartsOn, sasExpiresOn)->Key; auto verify_file_read = [&](const std::string& sas) { EXPECT_NO_THROW(fileClient0.Create());