7#include <smithy/client/AwsSmithyClientBase.h>
8#include <smithy/client/AwsSmithyClientAsyncRequestContext.h>
9#include <smithy/client/common/AwsSmithyRequestSigning.h>
10#include <smithy/identity/identity/AwsIdentity.h>
11#include <smithy/identity/auth/AuthSchemeOption.h>
12#include <smithy/identity/auth/AuthSchemeResolverBase.h>
13#include <smithy/tracing/TelemetryProvider.h>
15#include <aws/crt/Variant.h>
17#include <aws/core/client/ClientConfiguration.h>
18#include <aws/core/http/HttpResponse.h>
19#include <aws/core/utils/memory/stl/AWSMap.h>
20#include <aws/core/utils/FutureOutcome.h>
21#include <aws/core/utils/Outcome.h>
26 template<
const char* ServiceNameT,
27 typename ServiceClientConfigurationT,
28 typename ServiceAuthSchemeResolverT,
29 typename AuthSchemesVariantT,
30 typename EndpointProviderT,
37 const std::shared_ptr<Aws::Http::HttpClient>& httpClient,
38 const std::shared_ptr<Aws::Client::AWSErrorMarshaller>& errorMarshaller,
39 const std::shared_ptr<EndpointProviderT> endpointProvider,
40 const std::shared_ptr<ServiceAuthSchemeResolverT>& authSchemeResolver,
42 :
AwsSmithyClientBase(
Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller),
63 epCallback(resolveEndpointOutcome.
GetResult());
65 return resolveEndpointOutcome;
71 typename ServiceAuthSchemeResolverT::ServiceAuthSchemeParameters identityParams;
80 for (
const auto& epParam : epParams) {
82 if(epParam.GetStoredType() == ParameterType::STRING)
83 identityParams.additionalProperties.insert({epParam.GetName(), epParam.GetStrValueNoCheck()});
84 else if (epParam.GetStoredType() == ParameterType::BOOLEAN)
85 identityParams.additionalProperties.insert({epParam.GetName(), epParam.GetBoolValueNoCheck()});
87 assert(!
"Unknown endpoint parameter!");
89 const auto& serviceParams = ctx.m_pRequest->GetServiceSpecificParameters();
91 for (
const auto& serviceParam : serviceParams->parameterMap) {
92 identityParams.additionalProperties.insert({serviceParam.first, serviceParam.second});
98 auto authSchemeOptionIt = std::find_if(authSchemeOptions.begin(), authSchemeOptions.end(),
99 [
this](
const AuthSchemeOption& opt)
101 return m_authSchemes.find(opt.schemeId) != m_authSchemes.end();
103 assert(authSchemeOptionIt != authSchemeOptions.end());
105 if (authSchemeOptionIt != authSchemeOptions.end()) {
106 return SelectAuthSchemeOptionOutcome(*authSchemeOptionIt);
110 "Failed to select an auth scheme",
125 const char* requestName,
129 auto httpResponseOutcome = MakeRequestSync(request, requestName, method, std::move(endpointCallback));
130 return m_serializer->Deserialize(std::move(httpResponseOutcome), GetServiceClientName(), requestName);
135 std::shared_ptr<EndpointProviderT> m_endpointProvider{};
136 std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};
virtual EndpointParameters GetEndpointContextParams() const
const R & GetResult() const
static SigningOutcome SignRequest(std::shared_ptr< HttpRequest > HTTPRequest, const AuthSchemeOption &authSchemeOption, const Aws::UnorderedMap< Aws::String, AuthSchemesVariantT > &authSchemes)
static bool AdjustClockSkew(HttpResponseOutcome &outcome, const AuthSchemeOption &authSchemeOption, const Aws::UnorderedMap< Aws::String, AuthSchemesVariantT > &authSchemes)
Aws::String m_requestName
const Aws::AmazonWebServiceRequest * m_pRequest
Aws::UniquePtr< Aws::Client::ClientConfiguration > m_clientConfig
std::function< void(Aws::Endpoint::AWSEndpoint &)> EndpointUpdateCallback
Aws::String m_serviceName
ServiceClientConfigurationT & m_clientConfiguration
virtual ~AwsSmithyClientT()=default
SigningOutcome SignRequest(std::shared_ptr< HttpRequest > httpRequest, const AuthSchemeOption &targetAuthSchemeOption) const override
std::shared_ptr< EndpointProviderT > m_endpointProvider
SelectAuthSchemeOptionOutcome SelectAuthSchemeOption(const AwsSmithyClientAsyncRequestContext &ctx) const override
Aws::UniquePtr< SerializerT > m_serializer
bool AdjustClockSkew(HttpResponseOutcome &outcome, const AuthSchemeOption &authSchemeOption) const override
Aws::UnorderedMap< Aws::String, AuthSchemesVariantT > m_authSchemes
std::shared_ptr< ServiceAuthSchemeResolverT > m_authSchemeResolver
AwsSmithyClientT(const ServiceClientConfigurationT &clientConfig, const Aws::String &serviceName, const std::shared_ptr< Aws::Http::HttpClient > &httpClient, const std::shared_ptr< Aws::Client::AWSErrorMarshaller > &errorMarshaller, const std::shared_ptr< EndpointProviderT > endpointProvider, const std::shared_ptr< ServiceAuthSchemeResolverT > &authSchemeResolver, const Aws::UnorderedMap< Aws::String, AuthSchemesVariantT > &authSchemes)
const char * GetServiceClientName() const override
ResponseT MakeRequestDeserialize(Aws::AmazonWebServiceRequest const *const request, const char *requestName, Aws::Http::HttpMethod method, EndpointUpdateCallback &&endpointCallback) const
ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters &endpointParameters, EndpointUpdateCallback &&epCallback) const override
Aws::Vector< Aws::Endpoint::EndpointParameter > EndpointParameters
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::vector< T, Aws::Allocator< T > > Vector
std::unique_ptr< T, D > UniquePtr
std::unordered_map< K, V, std::hash< K >, std::equal_to< K >, Aws::Allocator< std::pair< const K, V > > > UnorderedMap
Aws::Client::AWSError< CoreErrors > AWSError