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 <ahkha@microsoft.com>

* f

* typo

* f

Co-authored-by: Ahson Khan <ahkha@microsoft.com>
This commit is contained in:
JinmingHu 2021-11-08 11:57:09 +08:00 committed by GitHub
parent 50d6885714
commit db85b15f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 394 additions and 437 deletions

View File

@ -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

View File

@ -266,29 +266,6 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<bool> 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<CorsRule> 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<SignedIdentifier> 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<PeekedQueueMessage> 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<SignedIdentifier> 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<CorsRule> Cors;
}; // struct QueueServiceProperties
struct ReceivedMessages final
{
/**
* A vector of received messages.
*/
std::vector<QueueMessage> 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<int32_t> Timeout;
}; // struct GetServicePropertiesOptions
static Azure::Response<GetServicePropertiesResult> GetProperties(
static Azure::Response<QueueServiceProperties> 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<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = GetServicePropertiesResultFromXml(reader);
response = QueueServicePropertiesFromXml(reader);
}
return Azure::Response<GetServicePropertiesResult>(
return Azure::Response<QueueServiceProperties>(
std::move(response), std::move(pHttpResponse));
}
@ -683,7 +675,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetServiceStatisticsOptions
static Azure::Response<GetServiceStatisticsResult> GetStatistics(
static Azure::Response<ServiceStatistics> 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<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = GetServiceStatisticsResultFromXml(reader);
response = ServiceStatisticsFromXml(reader);
}
return Azure::Response<GetServiceStatisticsResult>(
std::move(response), std::move(pHttpResponse));
return Azure::Response<ServiceStatistics>(std::move(response), std::move(pHttpResponse));
}
private:
static GetServicePropertiesResult GetServicePropertiesResultFromXml(
_internal::XmlReader& reader)
{
GetServicePropertiesResult ret;
enum class XmlTagName
{
k_StorageServiceProperties,
k_Unknown,
};
std::vector<XmlTagName> 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<XmlTagName> 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<XmlTagName> 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<XmlTagName> 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<XmlTagName> 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<XmlTagName> 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<XmlTagName> 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<int32_t> Timeout;
}; // struct GetQueuePropertiesOptions
static Azure::Response<GetQueuePropertiesResult> GetProperties(
static Azure::Response<QueueProperties> 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<GetQueuePropertiesResult>(
std::move(response), std::move(pHttpResponse));
return Azure::Response<QueueProperties>(std::move(response), std::move(pHttpResponse));
}
struct GetQueueAccessPolicyOptions final
@ -1745,7 +1693,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetQueueAccessPolicyOptions
static Azure::Response<GetQueueAccessPolicyResult> GetAccessPolicy(
static Azure::Response<QueueAccessPolicy> 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<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = GetQueueAccessPolicyResultFromXml(reader);
response = QueueAccessPolicyFromXml(reader);
}
return Azure::Response<GetQueueAccessPolicyResult>(
std::move(response), std::move(pHttpResponse));
return Azure::Response<QueueAccessPolicy>(std::move(response), std::move(pHttpResponse));
}
struct SetQueueAccessPolicyOptions final
@ -1887,7 +1834,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<std::chrono::seconds> VisibilityTimeout;
}; // struct ReceiveMessagesOptions
static Azure::Response<ReceiveMessagesResult> ReceiveMessages(
static Azure::Response<ReceivedMessages> 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<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = ReceiveMessagesResultFromXml(reader);
response = ReceivedMessagesFromXml(reader);
}
return Azure::Response<ReceiveMessagesResult>(
std::move(response), std::move(pHttpResponse));
return Azure::Response<ReceivedMessages>(std::move(response), std::move(pHttpResponse));
}
struct PeekMessagesOptions final
@ -1934,7 +1880,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int64_t> MaxMessages;
}; // struct PeekMessagesOptions
static Azure::Response<PeekMessagesResult> PeekMessages(
static Azure::Response<PeekedMessages> 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<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = PeekMessagesResultFromXml(reader);
response = PeekedMessagesFromXml(reader);
}
return Azure::Response<PeekMessagesResult>(std::move(response), std::move(pHttpResponse));
return Azure::Response<PeekedMessages>(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<XmlTagName> 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<XmlTagName> 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,

View File

@ -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<Models::GetQueuePropertiesResult> GetProperties(
Azure::Response<Models::QueueProperties> 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<Models::GetQueueAccessPolicyResult> GetAccessPolicy(
Azure::Response<Models::QueueAccessPolicy> 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<Models::SetQueueAccessPolicyResult> SetAccessPolicy(
std::vector<Models::SignedIdentifier> 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<Models::ReceiveMessagesResult> ReceiveMessages(
Azure::Response<Models::ReceivedMessages> 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<Models::PeekMessagesResult> PeekMessages(
Azure::Response<Models::PeekedMessages> PeekMessages(
const PeekMessagesOptions& options = PeekMessagesOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

View File

@ -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<Models::GetServicePropertiesResult> GetProperties(
Azure::Response<Models::QueueServiceProperties> 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<Models::GetServiceStatisticsResult> GetStatistics(
Azure::Response<Models::ServiceStatistics> GetStatistics(
const GetQueueServiceStatisticsOptions& options = GetQueueServiceStatisticsOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

View File

@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
}
Azure::Response<Models::GetQueuePropertiesResult> QueueClient::GetProperties(
Azure::Response<Models::QueueProperties> 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<Models::GetQueueAccessPolicyResult> QueueClient::GetAccessPolicy(
Azure::Response<Models::QueueAccessPolicy> QueueClient::GetAccessPolicy(
const GetQueueAccessPolicyOptions& options,
const Azure::Core::Context& context) const
{
@ -183,13 +183,13 @@ namespace Azure { namespace Storage { namespace Queues {
}
Azure::Response<Models::SetQueueAccessPolicyResult> QueueClient::SetAccessPolicy(
std::vector<Models::SignedIdentifier> 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<Models::ReceiveMessagesResult> QueueClient::ReceiveMessages(
Azure::Response<Models::ReceivedMessages> 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<Models::PeekMessagesResult> QueueClient::PeekMessages(
Azure::Response<Models::PeekedMessages> QueueClient::PeekMessages(
const PeekMessagesOptions& options,
const Azure::Core::Context& context) const
{

View File

@ -152,7 +152,7 @@ namespace Azure { namespace Storage { namespace Queues {
*m_pipeline, m_serviceUrl, protocolLayerOptions, context);
}
Azure::Response<Models::GetServicePropertiesResult> QueueServiceClient::GetProperties(
Azure::Response<Models::QueueServiceProperties> 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<Models::GetServiceStatisticsResult> QueueServiceClient::GetStatistics(
Azure::Response<Models::ServiceStatistics> QueueServiceClient::GetStatistics(
const GetQueueServiceStatisticsOptions& options,
const Azure::Core::Context& context) const
{

View File

@ -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);

View File

@ -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();

View File

@ -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);