Storage Queue Review Feedback (#2823)

* Remove CreateIfNotExists

* GetServicePropertiesResult/GetServiceStatisticsResult

* GetQueuePropertiesResult/GetQueueAccessPolicyResult

* CL
This commit is contained in:
JinmingHu 2021-09-03 09:49:24 +08:00 committed by GitHub
parent 2b3f03909e
commit 29659f9350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 431 additions and 402 deletions

View File

@ -12,7 +12,6 @@
- QueueServiceClient::CreateQueue
- QueueServiceClient::DeleteQueue
- QueueClient::Create
- QueueClient::CreateIfNotExists
- QueueClient::Delete
- QueueClient::GetProperties
- QueueClient::SetMetadata

View File

@ -266,6 +266,29 @@ 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.
*/
@ -281,7 +304,7 @@ namespace Azure { namespace Storage { namespace Queues {
/**
* Indicates if the queue was successfully created in this operation.
*/
bool Created = true;
bool Created = false;
}; // struct CreateQueueResult
struct DeleteMessageResult final
@ -296,7 +319,7 @@ namespace Azure { namespace Storage { namespace Queues {
/**
* Indicates if the queue was successfully deleted in this operation.
*/
bool Deleted = true;
bool Deleted = false;
}; // struct DeleteQueueResult
/**
@ -326,6 +349,52 @@ 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
{
/**
@ -374,56 +443,6 @@ namespace Azure { namespace Storage { namespace Queues {
std::vector<PeekedQueueMessage> Messages;
}; // struct PeekMessagesResult
/**
* @brief Access policy for a queue.
*/
struct QueueAccessPolicy final
{
/**
* A collection of signed identifiers.
*/
std::vector<SignedIdentifier> SignedIdentifiers;
}; // struct QueueAccessPolicy
/**
* @brief Properties of a queue.
*/
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 ReceiveMessagesResult final
{
/**
@ -432,17 +451,6 @@ namespace Azure { namespace Storage { namespace Queues {
std::vector<QueueMessage> Messages;
}; // struct ReceiveMessagesResult
/**
* @brief Statistics for the storage service.
*/
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.
*/
@ -593,7 +601,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetServicePropertiesOptions
static Azure::Response<QueueServiceProperties> GetProperties(
static Azure::Response<GetServicePropertiesResult> GetProperties(
Azure::Core::Http::_internal::HttpPipeline& pipeline,
const Azure::Core::Url& url,
const GetServicePropertiesOptions& options,
@ -610,7 +618,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
auto pHttpResponse = pipeline.Send(request, context);
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
QueueServiceProperties response;
GetServicePropertiesResult response;
auto http_status_code = httpResponse.GetStatusCode();
if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok)
{
@ -620,9 +628,9 @@ namespace Azure { namespace Storage { namespace Queues {
const auto& httpResponseBody = httpResponse.GetBody();
_internal::XmlReader reader(
reinterpret_cast<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = QueueServicePropertiesFromXml(reader);
response = GetServicePropertiesResultFromXml(reader);
}
return Azure::Response<QueueServiceProperties>(
return Azure::Response<GetServicePropertiesResult>(
std::move(response), std::move(pHttpResponse));
}
@ -675,7 +683,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetServiceStatisticsOptions
static Azure::Response<ServiceStatistics> GetStatistics(
static Azure::Response<GetServiceStatisticsResult> GetStatistics(
Azure::Core::Http::_internal::HttpPipeline& pipeline,
const Azure::Core::Url& url,
const GetServiceStatisticsOptions& options,
@ -692,7 +700,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
auto pHttpResponse = pipeline.Send(request, context);
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
ServiceStatistics response;
GetServiceStatisticsResult response;
auto http_status_code = httpResponse.GetStatusCode();
if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok)
{
@ -702,12 +710,121 @@ namespace Azure { namespace Storage { namespace Queues {
const auto& httpResponseBody = httpResponse.GetBody();
_internal::XmlReader reader(
reinterpret_cast<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = ServiceStatisticsFromXml(reader);
response = GetServiceStatisticsResultFromXml(reader);
}
return Azure::Response<ServiceStatistics>(std::move(response), std::move(pHttpResponse));
return Azure::Response<GetServiceStatisticsResult>(
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)
{
@ -799,12 +916,129 @@ 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,
@ -833,11 +1067,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
else if (node.Type == _internal::XmlNodeType::StartTag)
{
if (node.Name == "StorageServiceProperties")
{
path.emplace_back(XmlTagName::k_StorageServiceProperties);
}
else if (node.Name == "Logging")
if (node.Name == "Logging")
{
path.emplace_back(XmlTagName::k_Logging);
}
@ -861,29 +1091,24 @@ namespace Azure { namespace Storage { namespace Queues {
{
path.emplace_back(XmlTagName::k_Unknown);
}
if (path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties
&& path[1] == XmlTagName::k_Logging)
if (path.size() == 1 && path[0] == XmlTagName::k_Logging)
{
ret.Logging = AnalyticsLoggingFromXml(reader);
path.pop_back();
}
else if (
path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties
&& path[1] == XmlTagName::k_HourMetrics)
else if (path.size() == 1 && path[0] == XmlTagName::k_HourMetrics)
{
ret.HourMetrics = MetricsFromXml(reader);
path.pop_back();
}
else if (
path.size() == 2 && path[0] == XmlTagName::k_StorageServiceProperties
&& path[1] == XmlTagName::k_MinuteMetrics)
else if (path.size() == 1 && path[0] == XmlTagName::k_MinuteMetrics)
{
ret.MinuteMetrics = MetricsFromXml(reader);
path.pop_back();
}
else if (
path.size() == 3 && path[0] == XmlTagName::k_StorageServiceProperties
&& path[1] == XmlTagName::k_Cors && path[2] == XmlTagName::k_CorsRule)
path.size() == 2 && path[0] == XmlTagName::k_Cors
&& path[1] == XmlTagName::k_CorsRule)
{
ret.Cors.emplace_back(CorsRuleFromXml(reader));
path.pop_back();
@ -896,62 +1121,6 @@ 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;
@ -1123,16 +1292,11 @@ namespace Azure { namespace Storage { namespace Queues {
return ret;
}
static GeoReplication GeoReplicationFromXml(_internal::XmlReader& reader)
static Metadata MetadataFromXml(_internal::XmlReader& reader)
{
GeoReplication ret;
enum class XmlTagName
{
k_Status,
k_LastSyncTime,
k_Unknown,
};
std::vector<XmlTagName> path;
Metadata ret;
int depth = 0;
std::string key;
while (true)
{
auto node = reader.Read();
@ -1140,43 +1304,23 @@ 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 (path.size() > 0)
{
path.pop_back();
}
else
if (depth-- == 0)
{
break;
}
}
else if (node.Type == _internal::XmlNodeType::StartTag)
else if (depth == 1 && node.Type == _internal::XmlNodeType::Text)
{
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);
}
ret.emplace(std::move(key), node.Value);
}
}
return ret;
@ -1259,99 +1403,6 @@ 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;
@ -1572,9 +1623,9 @@ namespace Azure { namespace Storage { namespace Queues {
{
throw StorageException::CreateFromResponse(std::move(pHttpResponse));
}
if (http_status_code == Azure::Core::Http::HttpStatusCode::NoContent)
if (http_status_code == Azure::Core::Http::HttpStatusCode::Created)
{
response.Created = false;
response.Created = true;
}
return Azure::Response<CreateQueueResult>(std::move(response), std::move(pHttpResponse));
}
@ -1601,10 +1652,15 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
DeleteQueueResult response;
auto http_status_code = httpResponse.GetStatusCode();
if (http_status_code != Azure::Core::Http::HttpStatusCode::NoContent)
if (!(http_status_code == Azure::Core::Http::HttpStatusCode::NoContent
|| http_status_code == Azure::Core::Http::HttpStatusCode::NotFound))
{
throw StorageException::CreateFromResponse(std::move(pHttpResponse));
}
if (http_status_code == Azure::Core::Http::HttpStatusCode::NoContent)
{
response.Deleted = true;
}
return Azure::Response<DeleteQueueResult>(std::move(response), std::move(pHttpResponse));
}
@ -1650,7 +1706,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetQueuePropertiesOptions
static Azure::Response<QueueProperties> GetProperties(
static Azure::Response<GetQueuePropertiesResult> GetProperties(
Azure::Core::Http::_internal::HttpPipeline& pipeline,
const Azure::Core::Url& url,
const GetQueuePropertiesOptions& options,
@ -1666,7 +1722,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
auto pHttpResponse = pipeline.Send(request, context);
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
QueueProperties response;
GetQueuePropertiesResult response;
auto http_status_code = httpResponse.GetStatusCode();
if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok)
{
@ -1680,7 +1736,8 @@ namespace Azure { namespace Storage { namespace Queues {
}
response.ApproximateMessageCount
= std::stoll(httpResponse.GetHeaders().at("x-ms-approximate-messages-count"));
return Azure::Response<QueueProperties>(std::move(response), std::move(pHttpResponse));
return Azure::Response<GetQueuePropertiesResult>(
std::move(response), std::move(pHttpResponse));
}
struct GetQueueAccessPolicyOptions final
@ -1688,7 +1745,7 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Nullable<int32_t> Timeout;
}; // struct GetQueueAccessPolicyOptions
static Azure::Response<QueueAccessPolicy> GetAccessPolicy(
static Azure::Response<GetQueueAccessPolicyResult> GetAccessPolicy(
Azure::Core::Http::_internal::HttpPipeline& pipeline,
const Azure::Core::Url& url,
const GetQueueAccessPolicyOptions& options,
@ -1704,7 +1761,7 @@ namespace Azure { namespace Storage { namespace Queues {
request.GetUrl().AppendQueryParameter("comp", "acl");
auto pHttpResponse = pipeline.Send(request, context);
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
QueueAccessPolicy response;
GetQueueAccessPolicyResult response;
auto http_status_code = httpResponse.GetStatusCode();
if (http_status_code != Azure::Core::Http::HttpStatusCode::Ok)
{
@ -1714,9 +1771,10 @@ namespace Azure { namespace Storage { namespace Queues {
const auto& httpResponseBody = httpResponse.GetBody();
_internal::XmlReader reader(
reinterpret_cast<const char*>(httpResponseBody.data()), httpResponseBody.size());
response = QueueAccessPolicyFromXml(reader);
response = GetQueueAccessPolicyResultFromXml(reader);
}
return Azure::Response<QueueAccessPolicy>(std::move(response), std::move(pHttpResponse));
return Azure::Response<GetQueueAccessPolicyResult>(
std::move(response), std::move(pHttpResponse));
}
struct SetQueueAccessPolicyOptions final
@ -2179,6 +2237,63 @@ namespace Azure { namespace Storage { namespace Queues {
return ret;
}
static GetQueueAccessPolicyResult GetQueueAccessPolicyResultFromXml(
_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;
@ -2235,62 +2350,6 @@ namespace Azure { namespace Storage { namespace Queues {
return ret;
}
static QueueAccessPolicy QueueAccessPolicyFromXml(_internal::XmlReader& reader)
{
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 ReceiveMessagesResult ReceiveMessagesResultFromXml(_internal::XmlReader& reader)
{
ReceiveMessagesResult ret;

View File

@ -85,20 +85,6 @@ namespace Azure { namespace Storage { namespace Queues {
*/
std::string GetUrl() const { return m_queueUrl.GetAbsoluteUrl(); }
/**
* @brief Creates a new queue under the specified account. If the queue with the same name
* already exists and the metadata is identical to the one of the existing queue, the operation
* is successful and the value of CreateQueueResult.Created is false. If the metadata doesn't
* match the one of the existing queue, the operation fails.
*
* @param options Optional parameters to execute this function.
* @param context Context for cancelling long running operations.
* @return A CreateQueueResult describing the newly created blob container.
*/
Azure::Response<Models::CreateQueueResult> Create(
const CreateQueueOptions& options = CreateQueueOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;
/**
* @brief Creates a new queue under the specified account. If the queue with the same name
* already exists, it is not changed.
@ -108,7 +94,7 @@ namespace Azure { namespace Storage { namespace Queues {
* @return A CreateQueueResult describing the newly created queue if the queue doesn't exist.
* CreateQueueResult.Created is false if the queue already exists.
*/
Azure::Response<Models::CreateQueueResult> CreateIfNotExists(
Azure::Response<Models::CreateQueueResult> Create(
const CreateQueueOptions& options = CreateQueueOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;
@ -129,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 QueueProperties describing the queue and its properties.
* @return A GetQueuePropertiesResult describing the queue and its properties.
*/
Azure::Response<Models::QueueProperties> GetProperties(
Azure::Response<Models::GetQueuePropertiesResult> GetProperties(
const GetQueuePropertiesOptions& options = GetQueuePropertiesOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;
@ -154,9 +140,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 QueueAccessPolicy describing the queue's access policy.
* @return A GetQueueAccessPolicyResult describing the queue's access policy.
*/
Azure::Response<Models::QueueAccessPolicy> GetAccessPolicy(
Azure::Response<Models::GetQueueAccessPolicyResult> GetAccessPolicy(
const GetQueueAccessPolicyOptions& options = GetQueueAccessPolicyOptions(),
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 QueueServiceProperties describing the service properties.
* @return A GetServicePropertiesResult describing the service properties.
*/
Azure::Response<Models::QueueServiceProperties> GetProperties(
Azure::Response<Models::GetServicePropertiesResult> GetProperties(
const GetServicePropertiesOptions& options = GetServicePropertiesOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;
@ -136,9 +136,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 ServiceStatistics describing the service replication statistics.
* @return A GetServiceStatisticsResult describing the service replication statistics.
*/
Azure::Response<Models::ServiceStatistics> GetStatistics(
Azure::Response<Models::GetServiceStatisticsResult> GetStatistics(
const GetQueueServiceStatisticsOptions& options = GetQueueServiceStatisticsOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

View File

@ -16,7 +16,7 @@ void QueuesEncodeMessage()
std::string QueueName = "sample-queue";
auto queueClient = QueueClient::CreateFromConnectionString(GetConnectionString(), QueueName);
queueClient.CreateIfNotExists();
queueClient.Create();
// Binary message cannot be enqueued directly, we encode the message with Base64.
std::vector<uint8_t> binaryMessage{0x00, 0x01, 0x02, 0x03};

View File

@ -80,7 +80,7 @@ SAMPLE(QueuesGettingStarted, QueuesGettingStarted)
void QueuesGettingStarted()
{
auto queueClient = QueueClient::CreateFromConnectionString(GetConnectionString(), QueueName);
queueClient.CreateIfNotExists();
queueClient.Create();
ProducerFunc();
ConsumerFunc();

View File

@ -107,20 +107,13 @@ namespace Azure { namespace Storage { namespace Queues {
Azure::Response<Models::CreateQueueResult> QueueClient::Create(
const CreateQueueOptions& options,
const Azure::Core::Context& context) const
{
_detail::QueueRestClient::Queue::CreateQueueOptions protocolLayerOptions;
protocolLayerOptions.Metadata = options.Metadata;
return _detail::QueueRestClient::Queue::Create(
*m_pipeline, m_queueUrl, protocolLayerOptions, context);
}
Azure::Response<Models::CreateQueueResult> QueueClient::CreateIfNotExists(
const CreateQueueOptions& options,
const Azure::Core::Context& context) const
{
try
{
return Create(options, context);
_detail::QueueRestClient::Queue::CreateQueueOptions protocolLayerOptions;
protocolLayerOptions.Metadata = options.Metadata;
return _detail::QueueRestClient::Queue::Create(
*m_pipeline, m_queueUrl, protocolLayerOptions, context);
}
catch (StorageException& e)
{
@ -157,7 +150,7 @@ namespace Azure { namespace Storage { namespace Queues {
}
}
Azure::Response<Models::QueueProperties> QueueClient::GetProperties(
Azure::Response<Models::GetQueuePropertiesResult> QueueClient::GetProperties(
const GetQueuePropertiesOptions& options,
const Azure::Core::Context& context) const
{
@ -179,7 +172,7 @@ namespace Azure { namespace Storage { namespace Queues {
*m_pipeline, m_queueUrl, protocolLayerOptions, context);
}
Azure::Response<Models::QueueAccessPolicy> QueueClient::GetAccessPolicy(
Azure::Response<Models::GetQueueAccessPolicyResult> QueueClient::GetAccessPolicy(
const GetQueueAccessPolicyOptions& 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::QueueServiceProperties> QueueServiceClient::GetProperties(
Azure::Response<Models::GetServicePropertiesResult> 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::ServiceStatistics> QueueServiceClient::GetStatistics(
Azure::Response<Models::GetServiceStatisticsResult> QueueServiceClient::GetStatistics(
const GetQueueServiceStatisticsOptions& options,
const Azure::Core::Context& context) const
{

View File

@ -51,10 +51,10 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_FALSE(res.RawResponse->GetHeaders().at(_internal::HttpHeaderRequestId).empty());
EXPECT_FALSE(res.RawResponse->GetHeaders().at(_internal::HttpHeaderDate).empty());
EXPECT_FALSE(res.RawResponse->GetHeaders().at(_internal::HttpHeaderXMsVersion).empty());
EXPECT_NO_THROW(queueClient.Create(options));
EXPECT_THROW(queueClient.Create(), StorageException);
EXPECT_NO_THROW(queueClient.CreateIfNotExists());
EXPECT_NO_THROW(queueClient.CreateIfNotExists(options));
res = queueClient.Create(options);
EXPECT_FALSE(res.Value.Created);
res = queueClient.Create();
EXPECT_FALSE(res.Value.Created);
auto res2 = queueClient.Delete();
EXPECT_FALSE(res2.RawResponse->GetHeaders().at(_internal::HttpHeaderRequestId).empty());
@ -63,24 +63,16 @@ namespace Azure { namespace Storage { namespace Test {
queueClient = Azure::Storage::Queues::QueueClient::CreateFromConnectionString(
StandardStorageConnectionString(), LowercaseRandomString() + "UPPERCASE");
EXPECT_THROW(queueClient.CreateIfNotExists(), StorageException);
EXPECT_THROW(queueClient.Create(), StorageException);
queueClient = Azure::Storage::Queues::QueueClient::CreateFromConnectionString(
StandardStorageConnectionString(), LowercaseRandomString());
{
auto response = queueClient.Delete();
EXPECT_FALSE(response.Value.Deleted);
}
{
auto response = queueClient.CreateIfNotExists();
EXPECT_TRUE(response.Value.Created);
}
{
auto response = queueClient.CreateIfNotExists();
EXPECT_FALSE(response.Value.Created);
}
{
auto response = queueClient.Create();
EXPECT_FALSE(response.Value.Created);
EXPECT_TRUE(response.Value.Created);
}
{
auto response = queueClient.Delete();

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;
auto properties = ret.Value.Properties;
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.Logging;
properties.HourMetrics = getServicePropertiesResult.HourMetrics;
properties.MinuteMetrics = getServicePropertiesResult.MinuteMetrics;
properties.Cors = getServicePropertiesResult.Cors;
properties.Logging = getServicePropertiesResult.Properties.Logging;
properties.HourMetrics = getServicePropertiesResult.Properties.HourMetrics;
properties.MinuteMetrics = getServicePropertiesResult.Properties.MinuteMetrics;
properties.Cors = getServicePropertiesResult.Properties.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;
auto downloadedProperties = m_queueServiceClient.GetProperties().Value.Properties;
EXPECT_EQ(downloadedProperties.Logging.Version, properties.Logging.Version);
EXPECT_EQ(downloadedProperties.Logging.Delete, properties.Logging.Delete);
EXPECT_EQ(downloadedProperties.Logging.Read, properties.Logging.Read);