/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace Aws { namespace Utils { namespace RateLimits { class RateLimiterInterface; } } namespace Http { class HttpClient; } namespace Client { class AWSErrorMarshaller; class RetryStrategy; } namespace Utils { namespace Threading { class Executor; } } class AmazonWebServiceRequest; } namespace Aws { namespace Endpoint { class AWSEndpoint; } } namespace smithy { namespace client { class AwsSmithyClientAsyncRequestContext; /* Non-template base client class that contains main Aws Client Request pipeline logic */ class SMITHY_API AwsSmithyClientBase { public: using HttpRequest = Aws::Http::HttpRequest; using HttpResponse = Aws::Http::HttpResponse; using CoreErrors = Aws::Client::CoreErrors; using AWSError = Aws::Client::AWSError; using ClientError = AWSError; using SigningError = AWSError; using SigningOutcome = Aws::Utils::FutureOutcome, SigningError>; using EndpointUpdateCallback = std::function; using HttpResponseOutcome = Aws::Utils::Outcome, AWSError>; using ResponseHandlerFunc = std::function; using SelectAuthSchemeOptionOutcome = Aws::Utils::Outcome; using ResolveEndpointOutcome = Aws::Utils::Outcome; AwsSmithyClientBase(Aws::UniquePtr&& clientConfig, Aws::String serviceName, std::shared_ptr httpClient, std::shared_ptr errorMarshaller) : m_clientConfig(std::move(clientConfig)), m_serviceName(std::move(serviceName)), m_userAgent(), m_httpClient(std::move(httpClient)), m_errorMarshaller(std::move(errorMarshaller)), m_interceptors{Aws::MakeShared("AwsSmithyClientBase")} { if (!m_clientConfig->retryStrategy) { assert(m_clientConfig->configFactories.retryStrategyCreateFn); m_clientConfig->retryStrategy = m_clientConfig->configFactories.retryStrategyCreateFn(); } if (!m_clientConfig->executor) { assert(m_clientConfig->configFactories.executorCreateFn); m_clientConfig->executor = m_clientConfig->configFactories.executorCreateFn(); } if (!m_clientConfig->writeRateLimiter) { assert(m_clientConfig->configFactories.writeRateLimiterCreateFn); m_clientConfig->writeRateLimiter = m_clientConfig->configFactories.writeRateLimiterCreateFn(); } if (!m_clientConfig->readRateLimiter) { assert(m_clientConfig->configFactories.readRateLimiterCreateFn); m_clientConfig->readRateLimiter = m_clientConfig->configFactories.readRateLimiterCreateFn(); } if (!m_clientConfig->telemetryProvider) { assert(m_clientConfig->configFactories.telemetryProviderCreateFn); m_clientConfig->telemetryProvider = m_clientConfig->configFactories.telemetryProviderCreateFn(); } m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get()); } AwsSmithyClientBase(const AwsSmithyClientBase&) = delete; AwsSmithyClientBase(AwsSmithyClientBase&&) = delete; AwsSmithyClientBase& operator=(const AwsSmithyClientBase&) = delete; AwsSmithyClientBase& operator=(AwsSmithyClientBase&&) = delete; virtual ~AwsSmithyClientBase() = default; void MakeRequestAsync(Aws::AmazonWebServiceRequest const * const request, const char* requestName, Aws::Http::HttpMethod method, EndpointUpdateCallback&& endpointCallback, ResponseHandlerFunc&& responseHandler, std::shared_ptr pExecutor) const; HttpResponseOutcome MakeRequestSync(Aws::AmazonWebServiceRequest const * const request, const char* requestName, Aws::Http::HttpMethod method, EndpointUpdateCallback&& endpointCallback) const; protected: /** * Transforms the AmazonWebServicesResult object into an HttpRequest. */ std::shared_ptr BuildHttpRequest(const std::shared_ptr& pRequestCtx, const Aws::Http::URI& uri, Aws::Http::HttpMethod method) const; virtual void AttemptOneRequestAsync(std::shared_ptr pRequestCtx) const; virtual void HandleAsyncReply(std::shared_ptr pRequestCtx, std::shared_ptr httpResponse) const; inline virtual const char* GetServiceClientName() const { return m_serviceName.c_str(); } inline virtual const std::shared_ptr& GetHttpClient() { return m_httpClient; } virtual void DisableRequestProcessing(); virtual ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters, EndpointUpdateCallback&& epCallback) const = 0; virtual SelectAuthSchemeOptionOutcome SelectAuthSchemeOption(const AwsSmithyClientAsyncRequestContext& ctx) const = 0; virtual SigningOutcome SignRequest(std::shared_ptr httpRequest, const AuthSchemeOption& targetAuthSchemeOption) const = 0; virtual bool AdjustClockSkew(HttpResponseOutcome& outcome, const AuthSchemeOption& authSchemeOption) const = 0; protected: Aws::UniquePtr m_clientConfig; Aws::String m_serviceName; Aws::String m_userAgent; std::shared_ptr m_httpClient; std::shared_ptr m_errorMarshaller; Aws::Vector> m_interceptors{}; }; } // namespace client } // namespace smithy