Client base options on Azure Core (#1734)

Add client options base class
construct pipeline from Core
This commit is contained in:
Victor Vazquez 2021-03-03 23:25:28 +00:00 committed by GitHub
parent a5ff474118
commit 78b9a87278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 319 additions and 138 deletions

View File

@ -65,7 +65,7 @@ The example below shows how to override the default HTTP transport adapter when
BlobClientOptions options;
// Setting the libcurl transport adapter as an example.
// Any HTTP transport adapter can be specified here.
options.TransportPolicyOptions.Transport = std::make_shared<Azure::Core::Http::CurlTransport>();
options.TransportOptions.Transport = std::make_shared<Azure::Core::Http::CurlTransport>();
auto storageClient = BlobServiceClient(url, credential, options);
```
@ -80,11 +80,11 @@ Note that the HTTP transport adapter is a `shared_ptr`. This is because you can
*/
auto curlTransportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>();
BlobClientOptions optionsA;
optionsA.TransportPolicyOptions.Transport = curlTransportAdapter;
optionsA.TransportOptions.Transport = curlTransportAdapter;
auto storageClientA = BlobServiceClient(url, credential, optionsA);
// The second client.
BlobClientOptions optionsB;
optionsB.TransportPolicyOptions.Transport = curlTransportAdapter;
optionsB.TransportOptions.Transport = curlTransportAdapter;
auto storageClientB = BlobServiceClient(url, credential, optionsB);
/*
@ -92,7 +92,7 @@ Note that the HTTP transport adapter is a `shared_ptr`. This is because you can
*/
auto curlTransportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>();
BlobClientOptions options;
options.TransportPolicyOptions.Transport = curlTransportAdapter;
options.TransportOptions.Transport = curlTransportAdapter;
auto storageClient = BlobServiceClient(url, credential, options);
// Create specific child client from the parent service client.
auto blobContainerClient = storageClient.GetBlobContainerClient(containerName)
@ -115,7 +115,7 @@ The libcurl and WinHTTP transport adapters can also be initialized with specific
auto curlTransportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlTransportOptions);
BlobClientOptions options;
options.TransportPolicyOptions.Transport = curlTransportAdapter;
options.TransportOptions.Transport = curlTransportAdapter;
auto storageClient = BlobServiceClient(url, credential, options);
```

View File

@ -2,6 +2,9 @@
## 1.0.0-beta.7 (Unreleased)
### New Features
- Added `HttpPolicyOrder` for adding custom Http policies to sdk clients.
### Breaking Changes
- Removed `Azure::Core::Http::HttpPipeline` by making it internal, used only within the SDK.
@ -14,6 +17,9 @@
- Moved `NullBodyStream` to internal usage only. It is not meant for public use.
- Removed `LimitBodyStream`.
- Introduced `Azure::Core::CaseInsensitiveMap` which is now used to store headers in `Azure::Core::Http::Request` and `Azure::Core::Http::RawResponse`.
- Renamed `TransportPolicyOptions` to `TransportOptions`.
- Renamed `TelemetryPolicyOptions` to `TelemetryOptions`.
- Renamed `ValuePolicyOptions` to `ValueOptions`.
- Removed `StartTry()` from `Azure::Core::Http::Request`.
### Bug Fixes

View File

@ -49,6 +49,7 @@ set(
inc/azure/core/http/http.hpp
inc/azure/core/http/policy.hpp
inc/azure/core/http/transport.hpp
inc/azure/core/internal/client_options.hpp
inc/azure/core/internal/contract.hpp
inc/azure/core/internal/hkeyholder.hpp
inc/azure/core/internal/http/pipeline.hpp

View File

@ -30,6 +30,24 @@ namespace Azure { namespace Core { namespace Http {
std::shared_ptr<HttpTransport> GetTransportAdapter();
}
/**
* @brief Define the order of execution of and Http policy when a request is sent to the server.
*
*/
enum class HttpPolicyOrder
{
/**
* @brief The policy would be invoked once per request invocation (service call).
*
*/
PerCall,
/**
* @brief The policy would be invoked every time the request is retried.
*
*/
PerRetry
};
class NextHttpPolicy;
/**
@ -114,7 +132,7 @@ namespace Azure { namespace Core { namespace Http {
* @brief The options for the #Azure::Core::Http::TransportPolicy.
*
*/
struct TransportPolicyOptions
struct TransportOptions
{
/**
* @brief Set the #Azure::Core::Http::HttpTransport that the transport policy will use to send
@ -136,15 +154,15 @@ namespace Azure { namespace Core { namespace Http {
*/
class TransportPolicy : public HttpPolicy {
private:
TransportPolicyOptions m_options;
TransportOptions m_options;
public:
/**
* @brief Construct an HTTP transport policy.
*
* @param options #Azure::Core::Http::TransportPolicyOptions.
* @param options #Azure::Core::Http::TransportOptions.
*/
explicit TransportPolicy(TransportPolicyOptions options = TransportPolicyOptions())
explicit TransportPolicy(TransportOptions options = TransportOptions())
: m_options(std::move(options))
{
}
@ -268,7 +286,7 @@ namespace Azure { namespace Core { namespace Http {
* @brief The options for the #Azure::Core::Http::TelemetryPolicy
*
*/
struct TelemetryPolicyOptions
struct TelemetryOptions
{
/**
* @brief The Application id is the last part of the user agent for telemetry.
@ -306,7 +324,7 @@ namespace Azure { namespace Core { namespace Http {
explicit TelemetryPolicy(
std::string const& componentName,
std::string const& componentVersion,
TelemetryPolicyOptions options = TelemetryPolicyOptions())
TelemetryOptions options = TelemetryOptions())
: m_telemetryId(BuildTelemetryId(componentName, componentVersion, options.ApplicationId))
{
}
@ -400,7 +418,7 @@ namespace Azure { namespace Core { namespace Http {
/**
* @brief #Azure::Core::Http::Internal::ValuePolicy options.
*/
struct ValuePolicyOptions
struct ValueOptions
{
CaseInsensitiveMap HeaderValues;
std::map<std::string, std::string> QueryValues;
@ -414,15 +432,15 @@ namespace Azure { namespace Core { namespace Http {
*/
class ValuePolicy : public HttpPolicy {
private:
ValuePolicyOptions m_options;
ValueOptions m_options;
public:
/**
* @brief Construct a #Azure::Core::Http::Internal::ValuePolicy with the
* #Azure::Core::Http::Internal::ValuePolicyOptions provided.
* @param options #Azure::Core::Http::Internal::ValuePolicyOptions.
* #Azure::Core::Http::Internal::ValueOptions provided.
* @param options #Azure::Core::Http::Internal::ValueOptions.
*/
explicit ValuePolicy(ValuePolicyOptions options) : m_options(std::move(options)) {}
explicit ValuePolicy(ValueOptions options) : m_options(std::move(options)) {}
std::unique_ptr<HttpPolicy> Clone() const override
{

View File

@ -0,0 +1,123 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Base type for all client option types, exposes various common client options like Retry
* and Transport.
*/
#pragma once
#include "azure/core/http/http.hpp"
#include "azure/core/http/policy.hpp"
#include <memory>
#include <vector>
namespace Azure { namespace Core { namespace Internal {
/**
* @brief Base type for all client option types, exposes various common client options like Retry
* and Transport.
*
*/
class ClientOptions {
private:
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> m_perOperationPolicies;
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> m_perRetryPolicies;
public:
/**
* @brief Move each policy from \p options into the new instance.
*
*/
explicit ClientOptions(ClientOptions&& options)
: m_perOperationPolicies(std::move(options.m_perOperationPolicies)),
m_perRetryPolicies(std::move(options.m_perRetryPolicies))
{
}
/**
* @brief Copy each policy to the new instance.
*
*/
explicit ClientOptions(ClientOptions const& options)
{
m_perOperationPolicies.reserve(options.m_perOperationPolicies.size());
for (auto& policy : options.m_perOperationPolicies)
{
m_perOperationPolicies.emplace_back(policy->Clone());
}
m_perRetryPolicies.reserve(options.m_perRetryPolicies.size());
for (auto& policy : options.m_perRetryPolicies)
{
m_perRetryPolicies.emplace_back(policy->Clone());
}
}
ClientOptions() = default;
/**
* @brief Specify the number of retries and other retry-related options.
*/
Azure::Core::Http::RetryOptions Retry;
/**
* @brief Customized HTTP client. We're going to use the default one if this is empty.
*/
Azure::Core::Http::TransportOptions Transport;
/**
* @brief Telemetry options.
*/
Azure::Core::Http::TelemetryOptions Telemetry;
/**
* @brief Adds a policy into the client.
*
* @remark The order of policy while sending the request is controlled by \p order.
* If you want the policy to execute once per client request use #HttpPolicyOrder::PerCall,
* otherwise use #HttpPolicyOrder::PerRetry to run the policy for every retry.
*
* @param policy The policy instance to be added to the pipeline.
* @param order The order to execute the policy.
*/
void AddPolicy(
std::unique_ptr<Azure::Core::Http::HttpPolicy> policy,
Azure::Core::Http::HttpPolicyOrder order)
{
switch (order)
{
case Azure::Core::Http::HttpPolicyOrder::PerCall:
m_perOperationPolicies.push_back(std::move(policy));
break;
case Azure::Core::Http::HttpPolicyOrder::PerRetry:
m_perRetryPolicies.push_back(std::move(policy));
break;
default:
throw std::invalid_argument("Invalid order parameter");
}
}
/**
* @brief Get the Per Call Policies.
*
*/
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> const& GetPerCallPolicies() const
{
return m_perOperationPolicies;
}
/**
* @brief Get the Per Retry Policies.
*
*/
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> const& GerPerRetryPolicies() const
{
return m_perRetryPolicies;
}
};
}}} // namespace Azure::Core::Internal

View File

@ -13,7 +13,9 @@
#include "azure/core/http/http.hpp"
#include "azure/core/http/policy.hpp"
#include "azure/core/http/transport.hpp"
#include "azure/core/internal/client_options.hpp"
#include <memory>
#include <vector>
namespace Azure { namespace Core { namespace Internal { namespace Http {
@ -49,12 +51,84 @@ namespace Azure { namespace Core { namespace Internal { namespace Http {
}
m_policies.reserve(policies.size());
for (auto&& policy : policies)
for (auto& policy : policies)
{
m_policies.emplace_back(policy->Clone());
}
}
/**
* @brief Construct a new Http Pipeline object from clientOptions.
*
* @remark The client options includes per retry and per call policies which are merged with the
* service-specific per retry policies.
*
* @param clientOptions The SDK client options.
* @param telemetryServiceName The name of the service for sending telemetry.
* @param telemetryServiceVersion The version of the service for sending telemetry.
* @param perRetryPolicies The service-specific per retry policies.
* @param perCallPolicies The service-specific per call policies.
*/
explicit HttpPipeline(
ClientOptions const& clientOptions,
std::string const& telemetryServiceName,
std::string const& telemetryServiceVersion,
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>>&& perRetryPolicies,
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>>&& perCallPolicies)
{
auto const& perCallClientPolicies = clientOptions.GetPerCallPolicies();
auto const& perRetryClientPolicies = clientOptions.GerPerRetryPolicies();
// Adding 5 for:
// - TelemetryPolicy
// - RequestIdPolicy
// - RetryPolicy
// - LoggingPolicy
// - TransportPolicy
auto pipelineSize = perCallClientPolicies.size() + perRetryClientPolicies.size()
+ perRetryPolicies.size() + perCallPolicies.size() + 5;
m_policies.reserve(pipelineSize);
// service-specific per call policies
for (auto& policy : perCallPolicies)
{
m_policies.emplace_back(policy->Clone());
}
// client-options per call policies.
for (auto& policy : perCallClientPolicies)
{
m_policies.emplace_back(policy->Clone());
}
// Request Id
m_policies.emplace_back(std::make_unique<Azure::Core::Http::RequestIdPolicy>());
// Telemetry
m_policies.emplace_back(std::make_unique<Azure::Core::Http::TelemetryPolicy>(
telemetryServiceName, telemetryServiceVersion, clientOptions.Telemetry));
// Retry policy
m_policies.emplace_back(
std::make_unique<Azure::Core::Http::RetryPolicy>(clientOptions.Retry));
// service-specific per retry policies.
for (auto& policy : perRetryPolicies)
{
m_policies.emplace_back(policy->Clone());
}
// client options per retry policies.
for (auto& policy : perRetryClientPolicies)
{
m_policies.emplace_back(policy->Clone());
}
// logging - won't update request
m_policies.emplace_back(std::make_unique<Azure::Core::Http::LoggingPolicy>());
// transport
m_policies.emplace_back(
std::make_unique<Azure::Core::Http::TransportPolicy>(clientOptions.Transport));
}
/**
* @brief Construct HTTP pipeline with the sequence of HTTP policies provided.
*
@ -83,7 +157,7 @@ namespace Azure { namespace Core { namespace Internal { namespace Http {
HttpPipeline(const HttpPipeline& other)
{
m_policies.reserve(other.m_policies.size());
for (auto&& policy : m_policies)
for (auto& policy : other.m_policies)
{
m_policies.emplace_back(policy->Clone());
}

View File

@ -32,7 +32,7 @@ namespace Azure { namespace Core { namespace Test {
curlOptions.Proxy = "136.228.165.138:8080";
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = transportAdapter;
auto transportPolicy = std::make_unique<Azure::Core::Http::TransportPolicy>(options);
@ -61,7 +61,7 @@ namespace Azure { namespace Core { namespace Test {
curlOptions.SSLOptions.EnableCertificateRevocationListCheck = true;
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = transportAdapter;
auto transportPolicy = std::make_unique<Azure::Core::Http::TransportPolicy>(options);
@ -179,7 +179,7 @@ namespace Azure { namespace Core { namespace Test {
curlOptions.CAInfo = "/";
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = transportAdapter;
auto transportPolicy = std::make_unique<Azure::Core::Http::TransportPolicy>(options);
@ -209,7 +209,7 @@ namespace Azure { namespace Core { namespace Test {
TEST(CurlTransportOptions, httpsDefault)
{
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>();
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = transportAdapter;
auto transportPolicy = std::make_unique<Azure::Core::Http::TransportPolicy>(options);
@ -242,7 +242,7 @@ namespace Azure { namespace Core { namespace Test {
curlOptions.HttpKeepAlive = false;
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = transportAdapter;
auto transportPolicy = std::make_unique<Azure::Core::Http::TransportPolicy>(options);

View File

@ -121,7 +121,7 @@ TEST(Policy, ValuePolicy)
using namespace Azure::Core::Http;
using namespace Azure::Core::Internal::Http;
Azure::Core::Http::Internal::ValuePolicyOptions options
Azure::Core::Http::Internal::ValueOptions options
= {{{"hdrkey1", "HdrVal1"}, {"hdrkey2", "HdrVal2"}},
{{"QryKey1", "QryVal1"}, {"QryKey2", "QryVal2"}}};

View File

@ -43,21 +43,21 @@ TEST(TelemetryPolicy, telemetryString)
HttpPipeline pipeline1(policy1);
std::string const expected2 = "AzCopy/10.0.4-Preview azsdk-cpp-storage-blob/11.0.0 (";
Azure::Core::Http::TelemetryPolicyOptions options2;
Azure::Core::Http::TelemetryOptions options2;
options2.ApplicationId = "AzCopy/10.0.4-Preview";
policy2.emplace_back(std::make_unique<TelemetryPolicy>("storage-blob", "11.0.0", options2));
policy2.emplace_back(std::make_unique<NoOpPolicy>());
HttpPipeline pipeline2(policy2);
std::string const expected3 = "AzCopy / 10.0.4-Preview azsdk-cpp-storage-blob/11.0.0 (";
Azure::Core::Http::TelemetryPolicyOptions options3;
Azure::Core::Http::TelemetryOptions options3;
options3.ApplicationId = " AzCopy / 10.0.4-Preview ";
policy3.emplace_back(std::make_unique<TelemetryPolicy>("storage-blob", "11.0.0", options3));
policy3.emplace_back(std::make_unique<NoOpPolicy>());
HttpPipeline pipeline3(policy3);
std::string const expected4 = "01234567890123456789abcd azsdk-cpp-storage-blob/11.0.0 (";
Azure::Core::Http::TelemetryPolicyOptions options4;
Azure::Core::Http::TelemetryOptions options4;
options4.ApplicationId = " 01234567890123456789abcde ";
policy4.emplace_back(std::make_unique<TelemetryPolicy>("storage-blob", "11.0.0", options4));
policy4.emplace_back(std::make_unique<NoOpPolicy>());

View File

@ -22,11 +22,9 @@ namespace Azure { namespace Core { namespace Test {
struct TransportAdaptersTestParameter
{
std::string Suffix;
Azure::Core::Http::TransportPolicyOptions TransportAdapter;
Azure::Core::Http::TransportOptions TransportAdapter;
TransportAdaptersTestParameter(
std::string suffix,
Azure::Core::Http::TransportPolicyOptions options)
TransportAdaptersTestParameter(std::string suffix, Azure::Core::Http::TransportOptions options)
: Suffix(std::move(suffix)), TransportAdapter(std::move(options))
{
}

View File

@ -28,7 +28,7 @@ namespace Azure { namespace Core { namespace Test {
std::string suffix,
std::shared_ptr<Azure::Core::Http::HttpTransport> adapter)
{
Azure::Core::Http::TransportPolicyOptions options;
Azure::Core::Http::TransportOptions options;
options.Transport = adapter;
return TransportAdaptersTestParameter(std::move(suffix), options);
}

View File

@ -2,6 +2,9 @@
## 1.0.0-beta.4 (Unreleased)
### Breaking Changes
- Removed `TransportPolicyOptions` from `ClientSecretCredentialOptions`. Updated the options to derive from ClientOptions.
## 1.0.0-beta.3 (2021-02-02)

View File

@ -12,6 +12,7 @@
#include <azure/core/credentials.hpp>
#include <azure/core/http/policy.hpp>
#include <azure/core/internal/client_options.hpp>
#include <string>
#include <utility>
@ -24,7 +25,7 @@ namespace Azure { namespace Identity {
/**
* @brief Defines options for token authentication.
*/
struct ClientSecretCredentialOptions
struct ClientSecretCredentialOptions : public Azure::Core::Internal::ClientOptions
{
public:
/**
@ -37,11 +38,6 @@ namespace Azure { namespace Identity {
* https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud.
*/
std::string AuthorityHost = Details::g_aadGlobalAuthority;
/**
* @brief #Azure::Core::Http::TransportPolicyOptions for authentication HTTP pipeline.
*/
Azure::Core::Http::TransportPolicyOptions TransportPolicyOptions;
};
/**

View File

@ -57,17 +57,7 @@ Azure::Core::AccessToken ClientSecretCredential::GetToken(
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Content-Length", std::to_string(bodyString.size()));
std::vector<std::unique_ptr<HttpPolicy>> policies;
policies.emplace_back(std::make_unique<RequestIdPolicy>());
{
RetryOptions retryOptions;
policies.emplace_back(std::make_unique<RetryPolicy>(retryOptions));
}
policies.emplace_back(std::make_unique<TransportPolicy>(m_options.TransportPolicyOptions));
HttpPipeline httpPipeline(policies);
HttpPipeline httpPipeline(m_options, "Identity-client-secret-credential", "", {}, {});
std::shared_ptr<RawResponse> response = httpPipeline.Send(context, request);

View File

@ -71,13 +71,14 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Common { n
* @brief Construct a new Key Vault Pipeline.
*
* @param vaultUrl The url address for the Key Vault.
* @param policies The policies to use for building the KeyVaultPipeline.
* @param apiVersion The service Api version.
* @param pipeline The Http pipeline for sending requests with.
*/
explicit KeyVaultPipeline(
Azure::Core::Http::Url vaultUrl,
std::string apiVersion,
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> const& policies)
: m_vaultUrl(std::move(vaultUrl)), m_pipeline(policies), m_apiVersion(std::move(apiVersion))
Azure::Core::Internal::Http::HttpPipeline&& pipeline)
: m_vaultUrl(std::move(vaultUrl)), m_pipeline(pipeline), m_apiVersion(std::move(apiVersion))
{
}

View File

@ -5,6 +5,7 @@
#include <azure/core/http/http.hpp>
#include <azure/core/http/policy.hpp>
#include <azure/core/internal/client_options.hpp>
#include <azure/keyvault/common/internal/keyvault_pipeline.hpp>
#include <memory>
@ -16,5 +17,8 @@ TEST(KeyVaultPipeline, initPipeline)
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
policies.emplace_back(std::make_unique<Azure::Core::Http::TransportPolicy>());
Azure::Core::Http::Url url("urlTest");
EXPECT_NO_THROW(KeyVaultPipeline p(url, "version", policies));
Azure::Core::Internal::ClientOptions options;
Azure::Core::Internal::Http::HttpPipeline pipeline(
options, "service-name", "service-version", std::move(policies), {});
EXPECT_NO_THROW(KeyVaultPipeline p(url, "version", std::move(pipeline)));
}

View File

@ -10,6 +10,7 @@
#pragma once
#include <azure/core/http/http.hpp>
#include <azure/core/internal/client_options.hpp>
#include <azure/core/response.hpp>
#include "azure/keyvault/keys/key_vault_key.hpp"
@ -31,7 +32,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @brief Define the options to create an SDK Keys client.
*
*/
struct KeyClientOptions
struct KeyClientOptions : public Azure::Core::Internal::ClientOptions
{
/**
* @brief The service version. All request are created with this version.
@ -39,34 +40,17 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*/
ServiceVersion Version;
/**
* @brief Define the options to retry the Http requests.
*
*/
Azure::Core::Http::RetryOptions RetryOptions;
/**
* @brief Define the Http client options.
*
* @remark Use this options to set an specific Http client.
*
*/
Azure::Core::Http::TransportPolicyOptions TransportPolicyOptions;
/**
* @brief Define the information to be used for reporting telemetry data.
*
*/
Azure::Core::Http::TelemetryPolicyOptions TelemetryPolicyOptions;
/**
* @brief Construct a new Key Client Options object.
*
* @param version Optional version for the client.
*/
KeyClientOptions(ServiceVersion version = ServiceVersion::V7_2) : Version(version) {}
KeyClientOptions(ServiceVersion version = ServiceVersion::V7_2)
: ClientOptions(), Version(version)
{
}
std::string GetVersionString()
std::string GetVersionString() const
{
switch (Version)
{

View File

@ -23,28 +23,20 @@ KeyClient::KeyClient(
{
auto apiVersion = options.GetVersionString();
// Base Pipeline
std::vector<std::unique_ptr<HttpPolicy>> policies;
policies.emplace_back(
std::make_unique<TelemetryPolicy>("KeyVault", apiVersion, options.TelemetryPolicyOptions));
policies.emplace_back(std::make_unique<RequestIdPolicy>());
policies.emplace_back(std::make_unique<RetryPolicy>(options.RetryOptions));
std::vector<std::unique_ptr<HttpPolicy>> perRetrypolicies;
{
Azure::Core::Http::TokenRequestOptions const tokenOptions
= {{"https://vault.azure.net/.default"}};
policies.emplace_back(
perRetrypolicies.emplace_back(
std::make_unique<BearerTokenAuthenticationPolicy>(credential, tokenOptions));
}
policies.emplace_back(std::make_unique<LoggingPolicy>());
policies.emplace_back(
std::make_unique<Azure::Core::Http::TransportPolicy>(options.TransportPolicyOptions));
Azure::Core::Http::Url url(vaultUrl);
m_pipeline = std::make_shared<Azure::Security::KeyVault::Common::Internal::KeyVaultPipeline>(
url, apiVersion, std::move(policies));
Azure::Core::Http::Url(vaultUrl),
apiVersion,
Azure::Core::Internal::Http::HttpPipeline(
options, "KeyVault", apiVersion, std::move(perRetrypolicies), {}));
}
Azure::Core::Response<KeyVaultKey> KeyClient::GetKey(

View File

@ -20,7 +20,7 @@ TEST(KeyClient, initClient)
}
{
KeyClientOptions options;
options.RetryOptions.MaxRetries = 10;
options.Retry.MaxRetries = 10;
EXPECT_NO_THROW(KeyClient keyClient("vaultUrl", credential));
}
}

View File

@ -58,24 +58,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
public:
explicit KeyClientWithNoAuthenticationPolicy(
std::string const& vaultUrl,
KeyClientOptions options = KeyClientOptions())
KeyClientOptions const& options = KeyClientOptions())
: KeyClient(vaultUrl, nullptr, options)
{
auto apiVersion = options.GetVersionString();
// Base Pipeline
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
policies.emplace_back(std::make_unique<Azure::Core::Http::TelemetryPolicy>(
"KeyVault", apiVersion, options.TelemetryPolicyOptions));
policies.emplace_back(std::make_unique<Azure::Core::Http::RequestIdPolicy>());
policies.emplace_back(std::make_unique<Azure::Core::Http::RetryPolicy>(options.RetryOptions));
policies.emplace_back(std::make_unique<Azure::Core::Http::LoggingPolicy>());
policies.emplace_back(
std::make_unique<Azure::Core::Http::TransportPolicy>(options.TransportPolicyOptions));
Azure::Core::Http::Url url(vaultUrl);
m_pipeline = std::make_unique<Azure::Security::KeyVault::Common::Internal::KeyVaultPipeline>(
url, apiVersion, std::move(policies));
Azure::Core::Http::Url(vaultUrl),
apiVersion,
Azure::Core::Internal::Http::HttpPipeline(options, "test", "version", {}, {}));
}
};
@ -87,7 +78,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
// Create
virtual void SetUp() override
{
m_clientOptions.TransportPolicyOptions.Transport = std::make_shared<MockedTransportAdapter>();
m_clientOptions.Transport.Transport = std::make_shared<MockedTransportAdapter>();
}
};
}}}}} // namespace Azure::Security::KeyVault::Keys::Test

View File

@ -19,7 +19,7 @@ using namespace Azure::Security::KeyVault::Keys::Test;
TEST_F(MockedTransportAdapterTest, keyvaultTelemetryId)
{
std::string applicationId("ourApplicationId");
m_clientOptions.TelemetryPolicyOptions.ApplicationId = applicationId;
m_clientOptions.Telemetry.ApplicationId = applicationId;
m_client = std::make_unique<
Azure::Security::KeyVault::Keys::Test::KeyClientWithNoAuthenticationPolicy>(
"url", m_clientOptions);

View File

@ -154,7 +154,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Customized HTTP client. We're going to use the default one if this is empty.
*/
Azure::Core::Http::TransportPolicyOptions TransportPolicyOptions;
Azure::Core::Http::TransportOptions TransportOptions;
/**
* @brief The last part of the user agent for telemetry.

View File

@ -45,7 +45,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: BlobClient(blobUrl, options)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -63,7 +63,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: BlobClient(blobUrl, options)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -82,7 +82,7 @@ namespace Azure { namespace Storage { namespace Blobs {
: m_blobUrl(blobUrl), m_customerProvidedKey(options.CustomerProvidedKey),
m_encryptionScope(options.EncryptionScope)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: BlobContainerClient(blobContainerUrl, options)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -59,7 +59,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: BlobContainerClient(blobContainerUrl, options)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -80,7 +80,7 @@ namespace Azure { namespace Storage { namespace Blobs {
: m_blobContainerUrl(blobContainerUrl), m_customerProvidedKey(options.CustomerProvidedKey),
m_encryptionScope(options.EncryptionScope)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -36,7 +36,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -54,7 +54,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -74,7 +74,7 @@ namespace Azure { namespace Storage { namespace Blobs {
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -80,7 +80,7 @@ namespace Azure { namespace Storage {
{
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
{
Azure::Core::Http::Internal::ValuePolicyOptions options;
Azure::Core::Http::Internal::ValueOptions options;
options.HeaderValues[Details::HttpHeaderXMsVersion] = clientOptions.ApiVersion;
policies.emplace_back(std::make_unique<Azure::Core::Http::Internal::ValuePolicy>(options));
}
@ -105,7 +105,7 @@ namespace Azure { namespace Storage {
policies.emplace_back(std::move(authenticationPolicy));
}
policies.emplace_back(std::make_unique<Azure::Core::Http::TransportPolicy>(
std::forward<T>(clientOptions).TransportPolicyOptions));
std::forward<T>(clientOptions).TransportOptions));
return policies;
}

View File

@ -46,7 +46,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
/**
* @brief Customized HTTP client. We're going to use the default one if this is empty.
*/
Azure::Core::Http::TransportPolicyOptions TransportPolicyOptions;
Azure::Core::Http::TransportOptions TransportOptions;
/**
* @brief The last part of the user agent for telemetry.

View File

@ -48,7 +48,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -69,7 +69,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -91,7 +91,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
Details::GetBlobUrlFromUrl(fileSystemUrl),
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -86,7 +86,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -107,7 +107,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -128,7 +128,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
: m_pathUrl(pathUrl),
m_blobClient(Details::GetBlobUrlFromUrl(pathUrl), Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -89,7 +89,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -110,7 +110,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
credential,
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
Azure::Core::Http::TokenRequestOptions tokenOptions;
tokenOptions.Scopes.emplace_back(Storage::Details::StorageScope);
@ -132,7 +132,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
Details::GetBlobUrlFromUrl(serviceUrl),
Details::GetBlobClientOptions(options))
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -87,7 +87,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
blobOptions.RetryOptions = options.RetryOptions;
blobOptions.RetryOptions.SecondaryHostForRetryReads
= Details::GetBlobUrlFromUrl(options.RetryOptions.SecondaryHostForRetryReads);
blobOptions.TransportPolicyOptions = options.TransportPolicyOptions;
blobOptions.TransportOptions = options.TransportOptions;
blobOptions.ApplicationId = options.ApplicationId;
blobOptions.ApiVersion = options.ApiVersion;
return blobOptions;

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief Customized HTTP client. We're going to use the default one if this is empty.
*/
Azure::Core::Http::TransportPolicyOptions TransportPolicyOptions;
Azure::Core::Http::TransportOptions TransportOptions;
/**
* @brief The last part of the user agent for telemetry.

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_shareUrl(shareUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -56,7 +56,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareClient::ShareClient(const std::string& shareUrl, const ShareClientOptions& options)
: m_shareUrl(shareUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -43,7 +43,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_shareDirectoryUrl(shareDirectoryUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -60,7 +60,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_shareDirectoryUrl(shareDirectoryUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -47,7 +47,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_shareFileUrl(shareFileUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -64,7 +64,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_shareFileUrl(shareFileUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(

View File

@ -38,7 +38,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_serviceUrl(serviceUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(
@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options)
: m_serviceUrl(serviceUrl)
{
Azure::Core::Http::TelemetryPolicyOptions telemetryPolicyOptions;
Azure::Core::Http::TelemetryOptions telemetryPolicyOptions;
telemetryPolicyOptions.ApplicationId = options.ApplicationId;
m_pipeline = std::make_shared<Azure::Core::Internal::Http::HttpPipeline>(
Storage::Details::ConstructPolicies(