From db85b15f6a1a71ac6b3aa748c9c76aaecbb9b560 Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Mon, 8 Nov 2021 11:57:09 +0800 Subject: [PATCH] Rename some model types for Queue service (#3028) * QueueServiceProperties * QueueProperties * more * clangformat * CL * Update sdk/storage/azure-storage-queues/CHANGELOG.md Co-authored-by: Ahson Khan * f * typo * f Co-authored-by: Ahson Khan --- sdk/storage/azure-storage-queues/CHANGELOG.md | 8 + .../queues/protocol/queue_rest_client.hpp | 759 ++++++++---------- .../inc/azure/storage/queues/queue_client.hpp | 22 +- .../storage/queues/queue_service_client.hpp | 6 +- .../azure-storage-queues/src/queue_client.cpp | 12 +- .../src/queue_service_client.cpp | 4 +- .../test/ut/queue_client_test.cpp | 4 +- .../test/ut/queue_sas_test.cpp | 4 +- .../test/ut/queue_service_client_test.cpp | 12 +- 9 files changed, 394 insertions(+), 437 deletions(-) diff --git a/sdk/storage/azure-storage-queues/CHANGELOG.md b/sdk/storage/azure-storage-queues/CHANGELOG.md index 986135cf5..a8889d36a 100644 --- a/sdk/storage/azure-storage-queues/CHANGELOG.md +++ b/sdk/storage/azure-storage-queues/CHANGELOG.md @@ -6,6 +6,14 @@ ### Breaking Changes +- Renamed `GetServicePropertiesResult` to `QueueServiceProperties`. +- Renamed `GetServiceStatisticsResult` to `ServiceStatistics`. +- Renamed `GetQueuePropertiesResult` to `QueueProperties`. +- Renamed `GetQueueAccessPolicyResult` to `QueueAccessPolicy`. +- Wrapped the first parameter of `QueueClient::SetAccessPolicy`, a vector of signed identifiers into a struct `QueueAccessPolicy`. +- Renamed `ReceiveMessagesResult` to `ReceivedMessages`. +- Renamed `PeekMessagesResult` to `PeekedMessages`. + ### Bugs Fixed ### Other Changes diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/protocol/queue_rest_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/protocol/queue_rest_client.hpp index bc807f0a8..339b680e9 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/protocol/queue_rest_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/protocol/queue_rest_client.hpp @@ -266,29 +266,6 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable IncludeApis; }; // struct Metrics - /** - * @brief Properties of queue service. - */ - struct QueueServiceProperties final - { - /** - * Azure analytics logging settings. - */ - AnalyticsLogging Logging; - /** - * Summary of request statistics grouped by API in hour aggregates for queues. - */ - Metrics HourMetrics; - /** - * Summary of request statistics grouped by API in minute aggregates for queues. - */ - Metrics MinuteMetrics; - /** - * CORS rules set. - */ - std::vector Cors; - }; // struct QueueServiceProperties - /** * @brief Response type for #Azure::Storage::Queues::QueueClient::ClearMessages. */ @@ -349,52 +326,6 @@ namespace Azure { namespace Storage { namespace Queues { Azure::DateTime NextVisibleOn; }; // struct EnqueueMessageResult - /** - * @brief Response type for #Azure::Storage::Queues::QueueClient::GetAccessPolicy. - */ - struct GetQueueAccessPolicyResult final - { - /** - * A collection of signed identifiers. - */ - std::vector SignedIdentifiers; - }; // struct GetQueueAccessPolicyResult - - /** - * @brief Response type for #Azure::Storage::Queues::QueueClient::GetProperties. - */ - struct GetQueuePropertiesResult final - { - /** - * A set of name-value pairs associated with a queue as user-defined metadata. - */ - Storage::Metadata Metadata; - /** - * The approximate number of messages in the queue. This number is not lower than the actual - * number of messages in the queue, but could be higher. - */ - int64_t ApproximateMessageCount = 0; - }; // struct GetQueuePropertiesResult - - /** - * @brief Response type for #Azure::Storage::Queues::QueueServiceClient::GetProperties. - */ - struct GetServicePropertiesResult final - { - QueueServiceProperties Properties; - }; // struct GetServicePropertiesResult - - /** - * @brief Response tyoe for #Azure::Storage::Queues::QueueServiceClient::GetStatistics. - */ - struct GetServiceStatisticsResult final - { - /** - * Geo-replication information for the secondary storage endpoint. - */ - Models::GeoReplication GeoReplication; - }; // struct GetServiceStatisticsResult - enum class ListQueuesIncludeFlags { /** @@ -435,21 +366,82 @@ namespace Azure { namespace Storage { namespace Queues { return lhs; } - struct PeekMessagesResult final + struct PeekedMessages final { /** * A vector of peeked messages. */ std::vector Messages; - }; // struct PeekMessagesResult + }; // struct PeekedMessages - struct ReceiveMessagesResult final + /** + * @brief Response type for #Azure::Storage::Queues::QueueClient::GetAccessPolicy. + */ + struct QueueAccessPolicy final + { + /** + * A collection of signed identifiers. + */ + std::vector SignedIdentifiers; + }; // struct QueueAccessPolicy + + /** + * @brief Response type for #Azure::Storage::Queues::QueueClient::GetProperties. + */ + struct QueueProperties final + { + /** + * A set of name-value pairs associated with a queue as user-defined metadata. + */ + Storage::Metadata Metadata; + /** + * The approximate number of messages in the queue. This number is not lower than the actual + * number of messages in the queue, but could be higher. + */ + int64_t ApproximateMessageCount = 0; + }; // struct QueueProperties + + /** + * @brief Properties of queue service. + */ + struct QueueServiceProperties final + { + /** + * Azure analytics logging settings. + */ + AnalyticsLogging Logging; + /** + * Summary of request statistics grouped by API in hour aggregates for queues. + */ + Metrics HourMetrics; + /** + * Summary of request statistics grouped by API in minute aggregates for queues. + */ + Metrics MinuteMetrics; + /** + * CORS rules set. + */ + std::vector Cors; + }; // struct QueueServiceProperties + + struct ReceivedMessages final { /** * A vector of received messages. */ std::vector Messages; - }; // struct ReceiveMessagesResult + }; // struct ReceivedMessages + + /** + * @brief Response type for #Azure::Storage::Queues::QueueServiceClient::GetStatistics. + */ + struct ServiceStatistics final + { + /** + * Geo-replication information for the secondary storage endpoint. + */ + Models::GeoReplication GeoReplication; + }; // struct ServiceStatistics /** * @brief Response type for #Azure::Storage::Queues::QueueClient::SetAccessPolicy. @@ -601,7 +593,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable Timeout; }; // struct GetServicePropertiesOptions - static Azure::Response GetProperties( + static Azure::Response GetProperties( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const GetServicePropertiesOptions& options, @@ -618,7 +610,7 @@ namespace Azure { namespace Storage { namespace Queues { } auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - GetServicePropertiesResult response; + QueueServiceProperties response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -628,9 +620,9 @@ namespace Azure { namespace Storage { namespace Queues { const auto& httpResponseBody = httpResponse.GetBody(); _internal::XmlReader reader( reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); - response = GetServicePropertiesResultFromXml(reader); + response = QueueServicePropertiesFromXml(reader); } - return Azure::Response( + return Azure::Response( std::move(response), std::move(pHttpResponse)); } @@ -683,7 +675,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable Timeout; }; // struct GetServiceStatisticsOptions - static Azure::Response GetStatistics( + static Azure::Response GetStatistics( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const GetServiceStatisticsOptions& options, @@ -700,7 +692,7 @@ namespace Azure { namespace Storage { namespace Queues { } auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - GetServiceStatisticsResult response; + ServiceStatistics response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -710,121 +702,12 @@ namespace Azure { namespace Storage { namespace Queues { const auto& httpResponseBody = httpResponse.GetBody(); _internal::XmlReader reader( reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); - response = GetServiceStatisticsResultFromXml(reader); + response = ServiceStatisticsFromXml(reader); } - return Azure::Response( - std::move(response), std::move(pHttpResponse)); + return Azure::Response(std::move(response), std::move(pHttpResponse)); } private: - static GetServicePropertiesResult GetServicePropertiesResultFromXml( - _internal::XmlReader& reader) - { - GetServicePropertiesResult ret; - enum class XmlTagName - { - k_StorageServiceProperties, - k_Unknown, - }; - std::vector path; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (node.Name == "StorageServiceProperties") - { - path.emplace_back(XmlTagName::k_StorageServiceProperties); - } - else - { - path.emplace_back(XmlTagName::k_Unknown); - } - if (path.size() == 1 && path[0] == XmlTagName::k_StorageServiceProperties) - { - ret.Properties = QueueServicePropertiesFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return ret; - } - - static GetServiceStatisticsResult GetServiceStatisticsResultFromXml( - _internal::XmlReader& reader) - { - GetServiceStatisticsResult ret; - enum class XmlTagName - { - k_StorageServiceStats, - k_GeoReplication, - k_Unknown, - }; - std::vector path; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (node.Name == "StorageServiceStats") - { - path.emplace_back(XmlTagName::k_StorageServiceStats); - } - else if (node.Name == "GeoReplication") - { - path.emplace_back(XmlTagName::k_GeoReplication); - } - else - { - path.emplace_back(XmlTagName::k_Unknown); - } - if (path.size() == 2 && path[0] == XmlTagName::k_StorageServiceStats - && path[1] == XmlTagName::k_GeoReplication) - { - ret.GeoReplication = GeoReplicationFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return ret; - } - static Models::_detail::ListQueuesResult ListQueuesResultInternalFromXml( _internal::XmlReader& reader) { @@ -916,129 +799,12 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } - static GeoReplication GeoReplicationFromXml(_internal::XmlReader& reader) - { - GeoReplication ret; - enum class XmlTagName - { - k_Status, - k_LastSyncTime, - k_Unknown, - }; - std::vector path; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (node.Name == "Status") - { - path.emplace_back(XmlTagName::k_Status); - } - else if (node.Name == "LastSyncTime") - { - path.emplace_back(XmlTagName::k_LastSyncTime); - } - else - { - path.emplace_back(XmlTagName::k_Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::k_Status) - { - ret.Status = GeoReplicationStatus(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::k_LastSyncTime) - { - ret.LastSyncedOn - = Azure::DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - } - } - return ret; - } - - static QueueItem QueueItemFromXml(_internal::XmlReader& reader) - { - QueueItem ret; - enum class XmlTagName - { - k_Name, - k_Metadata, - k_Unknown, - }; - std::vector path; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (node.Name == "Name") - { - path.emplace_back(XmlTagName::k_Name); - } - else if (node.Name == "Metadata") - { - path.emplace_back(XmlTagName::k_Metadata); - } - else - { - path.emplace_back(XmlTagName::k_Unknown); - } - if (path.size() == 1 && path[0] == XmlTagName::k_Metadata) - { - ret.Metadata = MetadataFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::k_Name) - { - ret.Name = node.Value; - } - } - } - return ret; - } - static QueueServiceProperties QueueServicePropertiesFromXml(_internal::XmlReader& reader) { QueueServiceProperties ret; enum class XmlTagName { + k_StorageServiceProperties, k_Logging, k_HourMetrics, k_MinuteMetrics, @@ -1067,7 +833,11 @@ namespace Azure { namespace Storage { namespace Queues { } else if (node.Type == _internal::XmlNodeType::StartTag) { - if (node.Name == "Logging") + if (node.Name == "StorageServiceProperties") + { + path.emplace_back(XmlTagName::k_StorageServiceProperties); + } + else if (node.Name == "Logging") { path.emplace_back(XmlTagName::k_Logging); } @@ -1091,24 +861,29 @@ namespace Azure { namespace Storage { namespace Queues { { path.emplace_back(XmlTagName::k_Unknown); } - if (path.size() == 1 && path[0] == XmlTagName::k_Logging) + if (path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties + && path[1] == XmlTagName::k_Logging) { ret.Logging = AnalyticsLoggingFromXml(reader); path.pop_back(); } - else if (path.size() == 1 && path[0] == XmlTagName::k_HourMetrics) + else if ( + path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties + && path[1] == XmlTagName::k_HourMetrics) { ret.HourMetrics = MetricsFromXml(reader); path.pop_back(); } - else if (path.size() == 1 && path[0] == XmlTagName::k_MinuteMetrics) + else if ( + path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties + && path[1] == XmlTagName::k_MinuteMetrics) { ret.MinuteMetrics = MetricsFromXml(reader); path.pop_back(); } else if ( - path.size() == 2 && path[0] == XmlTagName::k_Cors - && path[1] == XmlTagName::k_CorsRule) + path.size() == 3 && path[0] == XmlTagName::k_StorageServiceProperties + && path[1] == XmlTagName::k_Cors && path[2] == XmlTagName::k_CorsRule) { ret.Cors.emplace_back(CorsRuleFromXml(reader)); path.pop_back(); @@ -1121,6 +896,62 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } + static ServiceStatistics ServiceStatisticsFromXml(_internal::XmlReader& reader) + { + ServiceStatistics ret; + enum class XmlTagName + { + k_StorageServiceStats, + k_GeoReplication, + k_Unknown, + }; + std::vector path; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (path.size() > 0) + { + path.pop_back(); + } + else + { + break; + } + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + if (node.Name == "StorageServiceStats") + { + path.emplace_back(XmlTagName::k_StorageServiceStats); + } + else if (node.Name == "GeoReplication") + { + path.emplace_back(XmlTagName::k_GeoReplication); + } + else + { + path.emplace_back(XmlTagName::k_Unknown); + } + if (path.size() == 2 && path[0] == XmlTagName::k_StorageServiceStats + && path[1] == XmlTagName::k_GeoReplication) + { + ret.GeoReplication = GeoReplicationFromXml(reader); + path.pop_back(); + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + } + } + return ret; + } + static AnalyticsLogging AnalyticsLoggingFromXml(_internal::XmlReader& reader) { AnalyticsLogging ret; @@ -1292,11 +1123,16 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } - static Metadata MetadataFromXml(_internal::XmlReader& reader) + static GeoReplication GeoReplicationFromXml(_internal::XmlReader& reader) { - Metadata ret; - int depth = 0; - std::string key; + GeoReplication ret; + enum class XmlTagName + { + k_Status, + k_LastSyncTime, + k_Unknown, + }; + std::vector path; while (true) { auto node = reader.Read(); @@ -1304,23 +1140,43 @@ namespace Azure { namespace Storage { namespace Queues { { break; } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (depth++ == 0) - { - key = node.Name; - } - } else if (node.Type == _internal::XmlNodeType::EndTag) { - if (depth-- == 0) + if (path.size() > 0) + { + path.pop_back(); + } + else { break; } } - else if (depth == 1 && node.Type == _internal::XmlNodeType::Text) + else if (node.Type == _internal::XmlNodeType::StartTag) { - ret.emplace(std::move(key), node.Value); + if (node.Name == "Status") + { + path.emplace_back(XmlTagName::k_Status); + } + else if (node.Name == "LastSyncTime") + { + path.emplace_back(XmlTagName::k_LastSyncTime); + } + else + { + path.emplace_back(XmlTagName::k_Unknown); + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (path.size() == 1 && path[0] == XmlTagName::k_Status) + { + ret.Status = GeoReplicationStatus(node.Value); + } + else if (path.size() == 1 && path[0] == XmlTagName::k_LastSyncTime) + { + ret.LastSyncedOn + = Azure::DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } } } return ret; @@ -1403,6 +1259,99 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } + static QueueItem QueueItemFromXml(_internal::XmlReader& reader) + { + QueueItem ret; + enum class XmlTagName + { + k_Name, + k_Metadata, + k_Unknown, + }; + std::vector path; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (path.size() > 0) + { + path.pop_back(); + } + else + { + break; + } + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + if (node.Name == "Name") + { + path.emplace_back(XmlTagName::k_Name); + } + else if (node.Name == "Metadata") + { + path.emplace_back(XmlTagName::k_Metadata); + } + else + { + path.emplace_back(XmlTagName::k_Unknown); + } + if (path.size() == 1 && path[0] == XmlTagName::k_Metadata) + { + ret.Metadata = MetadataFromXml(reader); + path.pop_back(); + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (path.size() == 1 && path[0] == XmlTagName::k_Name) + { + ret.Name = node.Value; + } + } + } + return ret; + } + + static Metadata MetadataFromXml(_internal::XmlReader& reader) + { + Metadata ret; + int depth = 0; + std::string key; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + if (depth++ == 0) + { + key = node.Name; + } + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (depth-- == 0) + { + break; + } + } + else if (depth == 1 && node.Type == _internal::XmlNodeType::Text) + { + ret.emplace(std::move(key), node.Value); + } + } + return ret; + } + static RetentionPolicy RetentionPolicyFromXml(_internal::XmlReader& reader) { RetentionPolicy ret; @@ -1706,7 +1655,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable Timeout; }; // struct GetQueuePropertiesOptions - static Azure::Response GetProperties( + static Azure::Response GetProperties( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const GetQueuePropertiesOptions& options, @@ -1722,7 +1671,7 @@ namespace Azure { namespace Storage { namespace Queues { } auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - GetQueuePropertiesResult response; + QueueProperties response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -1736,8 +1685,7 @@ namespace Azure { namespace Storage { namespace Queues { } response.ApproximateMessageCount = std::stoll(httpResponse.GetHeaders().at("x-ms-approximate-messages-count")); - return Azure::Response( - std::move(response), std::move(pHttpResponse)); + return Azure::Response(std::move(response), std::move(pHttpResponse)); } struct GetQueueAccessPolicyOptions final @@ -1745,7 +1693,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable Timeout; }; // struct GetQueueAccessPolicyOptions - static Azure::Response GetAccessPolicy( + static Azure::Response GetAccessPolicy( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const GetQueueAccessPolicyOptions& options, @@ -1761,7 +1709,7 @@ namespace Azure { namespace Storage { namespace Queues { request.GetUrl().AppendQueryParameter("comp", "acl"); auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - GetQueueAccessPolicyResult response; + QueueAccessPolicy response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -1771,10 +1719,9 @@ namespace Azure { namespace Storage { namespace Queues { const auto& httpResponseBody = httpResponse.GetBody(); _internal::XmlReader reader( reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); - response = GetQueueAccessPolicyResultFromXml(reader); + response = QueueAccessPolicyFromXml(reader); } - return Azure::Response( - std::move(response), std::move(pHttpResponse)); + return Azure::Response(std::move(response), std::move(pHttpResponse)); } struct SetQueueAccessPolicyOptions final @@ -1887,7 +1834,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable VisibilityTimeout; }; // struct ReceiveMessagesOptions - static Azure::Response ReceiveMessages( + static Azure::Response ReceiveMessages( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const ReceiveMessagesOptions& options, @@ -1912,7 +1859,7 @@ namespace Azure { namespace Storage { namespace Queues { } auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - ReceiveMessagesResult response; + ReceivedMessages response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -1922,10 +1869,9 @@ namespace Azure { namespace Storage { namespace Queues { const auto& httpResponseBody = httpResponse.GetBody(); _internal::XmlReader reader( reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); - response = ReceiveMessagesResultFromXml(reader); + response = ReceivedMessagesFromXml(reader); } - return Azure::Response( - std::move(response), std::move(pHttpResponse)); + return Azure::Response(std::move(response), std::move(pHttpResponse)); } struct PeekMessagesOptions final @@ -1934,7 +1880,7 @@ namespace Azure { namespace Storage { namespace Queues { Azure::Nullable MaxMessages; }; // struct PeekMessagesOptions - static Azure::Response PeekMessages( + static Azure::Response PeekMessages( Azure::Core::Http::_internal::HttpPipeline& pipeline, const Azure::Core::Url& url, const PeekMessagesOptions& options, @@ -1955,7 +1901,7 @@ namespace Azure { namespace Storage { namespace Queues { } auto pHttpResponse = pipeline.Send(request, context); Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse; - PeekMessagesResult response; + PeekedMessages response; auto http_status_code = httpResponse.GetStatusCode(); if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok) { @@ -1965,9 +1911,9 @@ namespace Azure { namespace Storage { namespace Queues { const auto& httpResponseBody = httpResponse.GetBody(); _internal::XmlReader reader( reinterpret_cast(httpResponseBody.data()), httpResponseBody.size()); - response = PeekMessagesResultFromXml(reader); + response = PeekedMessagesFromXml(reader); } - return Azure::Response(std::move(response), std::move(pHttpResponse)); + return Azure::Response(std::move(response), std::move(pHttpResponse)); } struct DeleteMessageOptions final @@ -2237,66 +2183,9 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } - static GetQueueAccessPolicyResult GetQueueAccessPolicyResultFromXml( - _internal::XmlReader& reader) + static PeekedMessages PeekedMessagesFromXml(_internal::XmlReader& reader) { - GetQueueAccessPolicyResult ret; - enum class XmlTagName - { - k_SignedIdentifiers, - k_SignedIdentifier, - k_Unknown, - }; - std::vector path; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (node.Name == "SignedIdentifiers") - { - path.emplace_back(XmlTagName::k_SignedIdentifiers); - } - else if (node.Name == "SignedIdentifier") - { - path.emplace_back(XmlTagName::k_SignedIdentifier); - } - else - { - path.emplace_back(XmlTagName::k_Unknown); - } - if (path.size() == 2 && path[0] == XmlTagName::k_SignedIdentifiers - && path[1] == XmlTagName::k_SignedIdentifier) - { - ret.SignedIdentifiers.emplace_back(SignedIdentifierFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return ret; - } - - static PeekMessagesResult PeekMessagesResultFromXml(_internal::XmlReader& reader) - { - PeekMessagesResult ret; + PeekedMessages ret; enum class XmlTagName { k_QueueMessagesList, @@ -2350,9 +2239,65 @@ namespace Azure { namespace Storage { namespace Queues { return ret; } - static ReceiveMessagesResult ReceiveMessagesResultFromXml(_internal::XmlReader& reader) + static QueueAccessPolicy QueueAccessPolicyFromXml(_internal::XmlReader& reader) { - ReceiveMessagesResult ret; + QueueAccessPolicy ret; + enum class XmlTagName + { + k_SignedIdentifiers, + k_SignedIdentifier, + k_Unknown, + }; + std::vector path; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (path.size() > 0) + { + path.pop_back(); + } + else + { + break; + } + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + if (node.Name == "SignedIdentifiers") + { + path.emplace_back(XmlTagName::k_SignedIdentifiers); + } + else if (node.Name == "SignedIdentifier") + { + path.emplace_back(XmlTagName::k_SignedIdentifier); + } + else + { + path.emplace_back(XmlTagName::k_Unknown); + } + if (path.size() == 2 && path[0] == XmlTagName::k_SignedIdentifiers + && path[1] == XmlTagName::k_SignedIdentifier) + { + ret.SignedIdentifiers.emplace_back(SignedIdentifierFromXml(reader)); + path.pop_back(); + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + } + } + return ret; + } + + static ReceivedMessages ReceivedMessagesFromXml(_internal::XmlReader& reader) + { + ReceivedMessages ret; enum class XmlTagName { k_QueueMessagesList, diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp index 676691bc6..2670e6681 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp @@ -115,9 +115,9 @@ namespace Azure { namespace Storage { namespace Queues { * * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. - * @return A GetQueuePropertiesResult describing the queue and its properties. + * @return A QueueProperties describing the queue and its properties. */ - Azure::Response GetProperties( + Azure::Response GetProperties( const GetQueuePropertiesOptions& options = GetQueuePropertiesOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -140,23 +140,23 @@ namespace Azure { namespace Storage { namespace Queues { * * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. - * @return A GetQueueAccessPolicyResult describing the queue's access policy. + * @return A QueueAccessPolicy describing the queue's access policy. */ - Azure::Response GetAccessPolicy( + Azure::Response GetAccessPolicy( const GetQueueAccessPolicyOptions& options = GetQueueAccessPolicyOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; /** * @brief Sets stored access policies for the queue that may be used with SAS. * - * @param signedIdentifiers Stored access policies that can be used to provide fine grained - * control over queue permissions. + * @param accessPolicy Stored access policies that can be used to provide fine grained control + * over queue permissions. * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. * @return A SetQueueAccessPolicyResult describing the updated queue. */ Azure::Response SetAccessPolicy( - std::vector signedIdentifiers, + const Models::QueueAccessPolicy& accessPolicy, const SetQueueAccessPolicyOptions& options = SetQueueAccessPolicyOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -180,9 +180,9 @@ namespace Azure { namespace Storage { namespace Queues { * * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. - * @return A ReceiveMessagesResult that contains a vector of queue messages. + * @return A ReceivedMessages that contains a vector of queue messages. */ - Azure::Response ReceiveMessages( + Azure::Response ReceiveMessages( const ReceiveMessagesOptions& options = ReceiveMessagesOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -192,9 +192,9 @@ namespace Azure { namespace Storage { namespace Queues { * * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. - * @return A PeekMessagesResult that contains a vector of queue messages. + * @return A PeekedMessages that contains a vector of queue messages. */ - Azure::Response PeekMessages( + Azure::Response PeekMessages( const PeekMessagesOptions& options = PeekMessagesOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp index ccf102e03..8c9685b3e 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp @@ -123,9 +123,9 @@ namespace Azure { namespace Storage { namespace Queues { * * @param options Optional parameters to execute this function. * @param context Context for cancelling long running operations. - * @return A GetServicePropertiesResult describing the service properties. + * @return A QueueServiceProperties describing the service properties. */ - Azure::Response GetProperties( + Azure::Response GetProperties( const GetServicePropertiesOptions& options = GetServicePropertiesOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -138,7 +138,7 @@ namespace Azure { namespace Storage { namespace Queues { * @param context Context for cancelling long running operations. * @return A GetServiceStatisticsResult describing the service replication statistics. */ - Azure::Response GetStatistics( + Azure::Response GetStatistics( const GetQueueServiceStatisticsOptions& options = GetQueueServiceStatisticsOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; diff --git a/sdk/storage/azure-storage-queues/src/queue_client.cpp b/sdk/storage/azure-storage-queues/src/queue_client.cpp index c243b0b7a..1d1f3f785 100644 --- a/sdk/storage/azure-storage-queues/src/queue_client.cpp +++ b/sdk/storage/azure-storage-queues/src/queue_client.cpp @@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Queues { } } - Azure::Response QueueClient::GetProperties( + Azure::Response QueueClient::GetProperties( const GetQueuePropertiesOptions& options, const Azure::Core::Context& context) const { @@ -172,7 +172,7 @@ namespace Azure { namespace Storage { namespace Queues { *m_pipeline, m_queueUrl, protocolLayerOptions, context); } - Azure::Response QueueClient::GetAccessPolicy( + Azure::Response QueueClient::GetAccessPolicy( const GetQueueAccessPolicyOptions& options, const Azure::Core::Context& context) const { @@ -183,13 +183,13 @@ namespace Azure { namespace Storage { namespace Queues { } Azure::Response QueueClient::SetAccessPolicy( - std::vector signedIdentifiers, + const Models::QueueAccessPolicy& accessPolicy, const SetQueueAccessPolicyOptions& options, const Azure::Core::Context& context) const { (void)options; _detail::QueueRestClient::Queue::SetQueueAccessPolicyOptions protocolLayerOptions; - protocolLayerOptions.SignedIdentifiers = std::move(signedIdentifiers); + protocolLayerOptions.SignedIdentifiers = accessPolicy.SignedIdentifiers; return _detail::QueueRestClient::Queue::SetAccessPolicy( *m_pipeline, m_queueUrl, protocolLayerOptions, context); } @@ -209,7 +209,7 @@ namespace Azure { namespace Storage { namespace Queues { *m_pipeline, messagesUrl, protocolLayerOptions, context); } - Azure::Response QueueClient::ReceiveMessages( + Azure::Response QueueClient::ReceiveMessages( const ReceiveMessagesOptions& options, const Azure::Core::Context& context) const { @@ -222,7 +222,7 @@ namespace Azure { namespace Storage { namespace Queues { *m_pipeline, messagesUrl, protocolLayerOptions, context); } - Azure::Response QueueClient::PeekMessages( + Azure::Response QueueClient::PeekMessages( const PeekMessagesOptions& options, const Azure::Core::Context& context) const { diff --git a/sdk/storage/azure-storage-queues/src/queue_service_client.cpp b/sdk/storage/azure-storage-queues/src/queue_service_client.cpp index 0852fddb1..ca3b25350 100644 --- a/sdk/storage/azure-storage-queues/src/queue_service_client.cpp +++ b/sdk/storage/azure-storage-queues/src/queue_service_client.cpp @@ -152,7 +152,7 @@ namespace Azure { namespace Storage { namespace Queues { *m_pipeline, m_serviceUrl, protocolLayerOptions, context); } - Azure::Response QueueServiceClient::GetProperties( + Azure::Response QueueServiceClient::GetProperties( const GetServicePropertiesOptions& options, const Azure::Core::Context& context) const { @@ -162,7 +162,7 @@ namespace Azure { namespace Storage { namespace Queues { *m_pipeline, m_serviceUrl, protocolLayerOptions, _internal::WithReplicaStatus(context)); } - Azure::Response QueueServiceClient::GetStatistics( + Azure::Response QueueServiceClient::GetStatistics( const GetQueueServiceStatisticsOptions& options, const Azure::Core::Context& context) const { diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_client_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_client_test.cpp index b91cb6e2f..9cfc01699 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_client_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_client_test.cpp @@ -156,7 +156,9 @@ namespace Azure { namespace Storage { namespace Test { signedIdentifiers.emplace_back(identifier); } - EXPECT_NO_THROW(queueClient.SetAccessPolicy(signedIdentifiers)); + Queues::Models::QueueAccessPolicy accessPolicy; + accessPolicy.SignedIdentifiers = signedIdentifiers; + EXPECT_NO_THROW(queueClient.SetAccessPolicy(accessPolicy)); auto ret = queueClient.GetAccessPolicy(); EXPECT_EQ(ret.Value.SignedIdentifiers, signedIdentifiers); diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp index 29fce5f70..2dc69f9c6 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp @@ -210,7 +210,9 @@ namespace Azure { namespace Storage { namespace Test { identifier.StartsOn = sasStartsOn; identifier.ExpiresOn = sasExpiresOn; identifier.Permissions = "r"; - queueClient0.SetAccessPolicy({identifier}); + Queues::Models::QueueAccessPolicy accessPolicy; + accessPolicy.SignedIdentifiers.push_back(identifier); + queueClient0.SetAccessPolicy(accessPolicy); Sas::QueueSasBuilder builder2 = queueSasBuilder; builder2.StartsOn.Reset(); diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp index 4838e1a21..4bbcade2a 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp @@ -124,7 +124,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(QueueServiceClientTest, GetProperties) { auto ret = m_queueServiceClient.GetProperties(); - auto properties = ret.Value.Properties; + auto properties = ret.Value; auto logging = properties.Logging; EXPECT_FALSE(logging.Version.empty()); if (logging.RetentionPolicy.IsEnabled) @@ -155,10 +155,10 @@ namespace Azure { namespace Storage { namespace Test { { auto getServicePropertiesResult = m_queueServiceClient.GetProperties().Value; Queues::Models::QueueServiceProperties properties; - properties.Logging = getServicePropertiesResult.Properties.Logging; - properties.HourMetrics = getServicePropertiesResult.Properties.HourMetrics; - properties.MinuteMetrics = getServicePropertiesResult.Properties.MinuteMetrics; - properties.Cors = getServicePropertiesResult.Properties.Cors; + properties.Logging = getServicePropertiesResult.Logging; + properties.HourMetrics = getServicePropertiesResult.HourMetrics; + properties.MinuteMetrics = getServicePropertiesResult.MinuteMetrics; + properties.Cors = getServicePropertiesResult.Cors; auto originalProperties = properties; @@ -198,7 +198,7 @@ namespace Azure { namespace Storage { namespace Test { // It takes some time before the new properties comes into effect. using namespace std::chrono_literals; std::this_thread::sleep_for(10s); - auto downloadedProperties = m_queueServiceClient.GetProperties().Value.Properties; + auto downloadedProperties = m_queueServiceClient.GetProperties().Value; EXPECT_EQ(downloadedProperties.Logging.Version, properties.Logging.Version); EXPECT_EQ(downloadedProperties.Logging.Delete, properties.Logging.Delete); EXPECT_EQ(downloadedProperties.Logging.Read, properties.Logging.Read);