diff --git a/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h b/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h index ad8f418f60a..fc7e5752a6c 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h +++ b/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace Aws { @@ -42,7 +43,8 @@ namespace DynamoDB Aws::Crt::Variant, DynamoDBEndpointProviderBase, smithy::client::JsonOutcomeSerializer, - smithy::client::JsonOutcome>, + smithy::client::JsonOutcome, + Aws::Client::DynamoDBErrorMarshaller>, Aws::Client::ClientWithAsyncTemplateMethods { public: @@ -2286,7 +2288,6 @@ namespace DynamoDB std::shared_ptr& accessEndpointProvider(); private: friend class Aws::Client::ClientWithAsyncTemplateMethods; - void init(const DynamoDBClientConfiguration& clientConfiguration); void OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint, const Aws::String& operationName, diff --git a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp index 9f90e7058f9..da4cef3baa5 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp +++ b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp @@ -116,9 +116,7 @@ DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clie { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region}}, }) -{ - init(m_clientConfiguration); -} +{} DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, std::shared_ptr endpointProvider, @@ -132,9 +130,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, }) -{ - init(m_clientConfiguration); -} +{} DynamoDBClient::DynamoDBClient(const std::shared_ptr& credentialsProvider, std::shared_ptr endpointProvider, @@ -148,9 +144,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{ Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} }) -{ - init(m_clientConfiguration); -} +{} /* Legacy constructors due deprecation */ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) : @@ -163,9 +157,7 @@ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfigur { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}} }) -{ - init(m_clientConfiguration); -} +{} DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : @@ -178,9 +170,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}} }) -{ - init(m_clientConfiguration); -} +{} DynamoDBClient::DynamoDBClient(const std::shared_ptr& credentialsProvider, const Client::ClientConfiguration& clientConfiguration) : @@ -193,9 +183,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} }) -{ - init(m_clientConfiguration); -} +{} /* End of legacy constructors due deprecation */ DynamoDBClient::~DynamoDBClient() @@ -208,20 +196,6 @@ std::shared_ptr& DynamoDBClient::accessEndpointPro return m_endpointProvider; } -void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config) -{ - if (!m_clientConfiguration.executor) { - if (!m_clientConfiguration.configFactories.executorCreateFn()) { - AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn"); - m_isInitialized = false; - return; - } - m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn(); - } - AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); - m_endpointProvider->InitBuiltInParameters(config); -} - void DynamoDBClient::OverrideEndpoint(const Aws::String& endpoint) { AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); diff --git a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h index 32e22e30e85..b643ee7ac91 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h @@ -29,10 +29,13 @@ namespace client typename AuthSchemesVariantT, typename EndpointProviderT, typename SerializerT, - typename ResponseT> + typename ResponseT, + typename ErrorMarshallerT> class AwsSmithyClientT : public AwsSmithyClientBase { public: + static_assert(std::is_base_of::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller"); + explicit AwsSmithyClientT(const ServiceClientConfigurationT& clientConfig, const Aws::String& serviceName, const std::shared_ptr& httpClient, const std::shared_ptr& errorMarshaller, @@ -44,14 +47,57 @@ namespace client m_endpointProvider(endpointProvider), m_authSchemeResolver(authSchemeResolver), m_authSchemes(authSchemes), - m_serializer(Aws::MakeUnique(ServiceNameT, m_clientConfiguration.telemetryProvider)) + m_serializer(Aws::MakeShared(ServiceNameT, m_clientConfiguration.telemetryProvider)) + { + m_serviceName = ServiceNameT; + initClient(); + } + + AwsSmithyClientT(const AwsSmithyClientT& other): + AwsSmithyClientBase(other, + Aws::MakeUnique(ServiceNameT, other.m_clientConfiguration), + ServiceNameT, + Aws::Http::CreateHttpClient(other.m_clientConfiguration), + Aws::MakeShared(ServiceNameT)), + m_clientConfiguration{*static_cast(m_clientConfig.get())}, + m_endpointProvider{other.m_endpointProvider}, + m_authSchemeResolver{Aws::MakeShared(ServiceNameT)}, + m_authSchemes{other.m_authSchemes}, + m_serializer{Aws::MakeShared(ServiceNameT, m_clientConfiguration.telemetryProvider)} { - m_serviceName = ServiceNameT; + initClient(); } + AwsSmithyClientT& operator=(const AwsSmithyClientT& other) + { + if(this != &other) + { + AwsSmithyClientBase::deepCopy(Aws::MakeUnique(ServiceNameT, other.m_clientConfiguration), + ServiceNameT, + Aws::Http::CreateHttpClient(other.m_clientConfiguration), + Aws::MakeShared(ServiceNameT)); + m_clientConfiguration = *static_cast(m_clientConfig.get()); + m_endpointProvider = other.m_endpointProvider; + m_authSchemeResolver = Aws::MakeShared(ServiceNameT); + m_authSchemes = other.m_authSchemes; + m_serializer = Aws::MakeShared(ServiceNameT, m_clientConfiguration.telemetryProvider); + m_errorMarshaller = Aws::MakeShared(ServiceNameT); + initClient(); + } + return *this; + } + + AwsSmithyClientT (AwsSmithyClientT&&) = default; + + AwsSmithyClientT& operator=(AwsSmithyClientT&&) = default; + virtual ~AwsSmithyClientT() = default; protected: + void initClient() { + m_endpointProvider->InitBuiltInParameters(m_clientConfiguration); + } + inline const char* GetServiceClientName() const override { return m_serviceName.c_str(); } ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters, EndpointUpdateCallback&& epCallback) const override @@ -130,12 +176,11 @@ namespace client return m_serializer->Deserialize(std::move(httpResponseOutcome), GetServiceClientName(), requestName); } - protected: ServiceClientConfigurationT& m_clientConfiguration; std::shared_ptr m_endpointProvider{}; std::shared_ptr m_authSchemeResolver{}; Aws::UnorderedMap m_authSchemes{}; - Aws::UniquePtr m_serializer{}; + std::shared_ptr m_serializer{}; }; } // namespace client diff --git a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h index 045c9ce7d43..34554c0b52e 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h @@ -17,6 +17,10 @@ #include #include #include +#include +#include + +#include namespace Aws { @@ -90,39 +94,29 @@ namespace client 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()); + baseInit(); } - AwsSmithyClientBase(const AwsSmithyClientBase&) = delete; - AwsSmithyClientBase(AwsSmithyClientBase&&) = delete; - AwsSmithyClientBase& operator=(const AwsSmithyClientBase&) = delete; - AwsSmithyClientBase& operator=(AwsSmithyClientBase&&) = delete; + AwsSmithyClientBase(const AwsSmithyClientBase& other, + 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")} + { + AWS_UNREFERENCED_PARAM(other); + baseCopyInit(); + } + + AwsSmithyClientBase(AwsSmithyClientBase& target) = delete; + AwsSmithyClientBase& operator=(AwsSmithyClientBase& target) = delete; + AwsSmithyClientBase(AwsSmithyClientBase&& target) = default; + AwsSmithyClientBase& operator=(AwsSmithyClientBase&& target) = default; virtual ~AwsSmithyClientBase() = default; @@ -139,6 +133,32 @@ namespace client EndpointUpdateCallback&& endpointCallback) const; protected: + void deepCopy(Aws::UniquePtr&& clientConfig, + const Aws::String& serviceName, + std::shared_ptr httpClient, + std::shared_ptr errorMarshaller) + { + m_clientConfig = std::move(clientConfig); + m_serviceName = serviceName; + m_httpClient = std::move(httpClient); + m_errorMarshaller = std::move(errorMarshaller); + m_interceptors = Aws::Vector>{Aws::MakeShared("AwsSmithyClientBase")}; + baseCopyInit(); + } + + /** + * Initialize client configuration with their factory method, unless the user has explicitly set the + * configuration, and it is to be shallow copied between different clients, in which case, delete the + * factory method. + */ + void baseInit(); + + /** + * Initialize client configuration on copy, if there is a factory use it, otherwise use the already present + * shared configuration. + */ + void baseCopyInit(); + /** * Transforms the AmazonWebServicesResult object into an HttpRequest. */ @@ -159,8 +179,7 @@ namespace client 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; + std::shared_ptr m_clientConfig; Aws::String m_serviceName; Aws::String m_userAgent; diff --git a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp index 27f0304a6bf..c09d2144748 100644 --- a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp +++ b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp @@ -24,14 +24,50 @@ using namespace smithy::components::tracing; static const char AWS_SMITHY_CLIENT_LOG[] = "AwsSmithyClient"; - +namespace { void AddHeadersToRequest(const std::shared_ptr& httpRequest, const Aws::Http::HeaderValueCollection& headerValues) { - for (auto const& headerValue : headerValues) - { - httpRequest->SetHeaderValue(headerValue.first, headerValue.second); - } + for (auto const& headerValue : headerValues) + { + httpRequest->SetHeaderValue(headerValue.first, headerValue.second); + } +} + +template +void createFromFactories(T& entity, std::function& factory) { + if (!entity) { + assert(factory); + entity = factory(); + } else { + factory = nullptr; + } +} + +template +void createFromFactoriesIfPresent(T& entity, std::function& factory) { + if (entity && factory) { + entity = factory(); + } +} +} // namespace + +void AwsSmithyClientBase::baseInit() { + createFromFactories(m_clientConfig->retryStrategy, m_clientConfig->configFactories.retryStrategyCreateFn); + createFromFactories(m_clientConfig->executor, m_clientConfig->configFactories.executorCreateFn); + createFromFactories(m_clientConfig->writeRateLimiter, m_clientConfig->configFactories.writeRateLimiterCreateFn); + createFromFactories(m_clientConfig->readRateLimiter, m_clientConfig->configFactories.readRateLimiterCreateFn); + createFromFactories(m_clientConfig->telemetryProvider, m_clientConfig->configFactories.telemetryProviderCreateFn); + m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get()); +} + +void AwsSmithyClientBase::baseCopyInit() { + createFromFactoriesIfPresent(m_clientConfig->retryStrategy, m_clientConfig->configFactories.retryStrategyCreateFn); + createFromFactoriesIfPresent(m_clientConfig->executor, m_clientConfig->configFactories.executorCreateFn); + createFromFactoriesIfPresent(m_clientConfig->writeRateLimiter, m_clientConfig->configFactories.writeRateLimiterCreateFn); + createFromFactoriesIfPresent(m_clientConfig->readRateLimiter, m_clientConfig->configFactories.readRateLimiterCreateFn); + createFromFactoriesIfPresent(m_clientConfig->telemetryProvider, m_clientConfig->configFactories.telemetryProviderCreateFn); + m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get()); } std::shared_ptr diff --git a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp index daf888c8c3e..94296efb44a 100644 --- a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp @@ -1,36 +1,50 @@ /** -* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -#include -#include -#include -#include - -#include -#include +#include +#include #include - -#include -#include -#include - #include -#include #include -#include #include +#include +#include +#include +#include +#include #include +#include #include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include static const char ALLOC_TAG[] = "SmithyClientTest"; -class TestEndPointProvider : public Aws::Endpoint::EndpointProviderBase<> +struct TestEndPointProvider : public Aws::Endpoint::EndpointProviderBase<> { +public: + void InitBuiltInParameters(const Aws::Client::GenericClientConfiguration& config) override { AWS_UNREFERENCED_PARAM(config); } + + void OverrideEndpoint(const Aws::String& endpoint) override { AWS_UNREFERENCED_PARAM(endpoint); } + + ClientContextParameters& AccessClientContextParameters() override { return m_clientContext; } + + const ClientContextParameters& GetClientContextParameters() const override { return m_clientContext; } + + Aws::Endpoint::ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters) const override { + AWS_UNREFERENCED_PARAM(endpointParameters); + return Aws::Endpoint::AWSEndpoint{}; + } + + ~TestEndPointProvider() override = default; +private: + ClientContextParameters m_clientContext; }; @@ -101,6 +115,7 @@ class SmithyClientTest : public Aws::Testing::AwsCppSdkGTestSuite { httpClient = Aws::MakeShared(ALLOCATION_TAG); errorMarshaller = Aws::MakeShared(ALLOCATION_TAG); credsProviderChain = Aws::MakeShared(ALLOCATION_TAG); + endPointProvider = Aws::MakeShared(ALLOCATION_TAG); //add mock credentials provider for the test to the credentials provider chain AddCredentialsProvider(Aws::MakeShared("TestCredentialsProviderChain")); @@ -155,7 +170,8 @@ using MySmithyClient = smithy::client::AwsSmithyClientT; + Aws::String, + Aws::Client::XmlErrorMarshaller>; class TestClient : public MySmithyClient { @@ -348,4 +364,66 @@ TEST_F(SmithyClientTest, bearer) EXPECT_EQ(res2.GetResult()->GetHeaderValue("authorization"), "Bearer testBearerToken"); +} + +struct SampleConfiguration: public Aws::Client::ClientConfiguration { + Aws::String localToService{"whatever"}; +}; + +struct SampleConfigurationAuthSchemeOption { + static smithy::AuthSchemeOption schemeOption; +}; + +struct SampleEndpointProvider : public Aws::Endpoint::EndpointProviderBase<> +{ +public: + void InitBuiltInParameters(const Aws::Client::GenericClientConfiguration& config) override { AWS_UNREFERENCED_PARAM(config); } + + void OverrideEndpoint(const Aws::String& endpoint) override { AWS_UNREFERENCED_PARAM(endpoint); } + + ClientContextParameters& AccessClientContextParameters() override { return m_clientContext; } + + const ClientContextParameters& GetClientContextParameters() const override { return m_clientContext; } + + Aws::Endpoint::ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters) const override { + AWS_UNREFERENCED_PARAM(endpointParameters); + return Aws::Endpoint::AWSEndpoint{}; + } + + ~SampleEndpointProvider() override = default; +private: + ClientContextParameters m_clientContext; +}; + +static constexpr char SampleServiceName[] = "SampleService"; +class SampleClient: public smithy::client::AwsSmithyClientT, + Aws::Crt::Variant, + SampleEndpointProvider, + smithy::client::JsonOutcomeSerializer, + smithy::client::JsonOutcome, + Aws::Client::JsonErrorMarshaller> +{ +public: + SampleClient(): AwsSmithyClientT(SampleConfiguration{}, + SampleServiceName, + Aws::MakeShared(SampleServiceName), + Aws::MakeShared(SampleServiceName), + Aws::MakeShared(SampleServiceName), + Aws::MakeShared>(SampleServiceName), + {}) + {} +}; + +TEST_F(SmithyClientTest, SmithyClientShouldCopyAssignAndMove) { + SampleClient client{}; + SampleClient copy{client}; + AWS_UNREFERENCED_PARAM(copy); + SampleClient assign = client; + AWS_UNREFERENCED_PARAM(assign); + SampleClient move{client}; + AWS_UNREFERENCED_PARAM(copy); + SampleClient moveAssign = std::move(client); + AWS_UNREFERENCED_PARAM(assign); } \ No newline at end of file diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm index 27d3ebf1478..3260b29122b 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm @@ -21,6 +21,7 @@ \#include \#include \#include +\#include namespace ${rootNamespace} { @@ -42,7 +43,8 @@ namespace ${serviceNamespace} ${rootNamespace}::Crt::Variant<${AuthSchemeVariants}>, ${metadata.classNamePrefix}EndpointProviderBase, smithy::client::$serializer, - smithy::client::$serializerOutcome>, + smithy::client::$serializerOutcome, + Aws::Client::${metadata.classNamePrefix}ErrorMarshaller>, Aws::Client::ClientWithAsyncTemplateMethods<${className}> { public: @@ -58,7 +60,6 @@ namespace ${serviceNamespace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase>& accessEndpointProvider(); private: friend class ${rootNamespace}::Client::ClientWithAsyncTemplateMethods<${className}>; - void init(const ${metadata.classNamePrefix}ClientConfiguration& clientConfiguration); #if($metadata.hasEndpointDiscoveryTrait) void OptionallyUpdateDescribeEndpointsCache(${rootNamespace}::Endpoint::AWSEndpoint& resolvedEndpoint, diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm index 35fc81ecdc4..439256ea5ce 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm @@ -12,9 +12,7 @@ ${className}::${className}(const ${clientConfiguration}& clientConfiguration, {${entry}{GetServiceName(), clientConfiguration.region}}, #end }) -{ - init(m_clientConfiguration); -} +{} ${className}::${className}(const AWSCredentials& credentials, std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider, @@ -30,9 +28,7 @@ ${className}::${className}(const AWSCredentials& credentials, {${entry}{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, #end }) -{ - init(m_clientConfiguration); -} +{} ${className}::${className}(const std::shared_ptr& credentialsProvider, std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider, @@ -48,9 +44,7 @@ ${className}::${className}(const std::shared_ptr& creden {${entry}{ Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} #end }) -{ - init(m_clientConfiguration); -} +{} /* Legacy constructors due deprecation */ ${className}::${className}(const Client::ClientConfiguration& clientConfiguration) : @@ -65,9 +59,7 @@ ${className}::${className}(const Client::ClientConfiguration& clientConfiguratio {$entry{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}} #end }) -{ - init(m_clientConfiguration); -} +{} ${className}::${className}(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : @@ -82,9 +74,7 @@ ${className}::${className}(const AWSCredentials& credentials, {$entry{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}} #end }) -{ - init(m_clientConfiguration); -} +{} ${className}::${className}(const std::shared_ptr& credentialsProvider, const Client::ClientConfiguration& clientConfiguration) : @@ -99,9 +89,7 @@ ${className}::${className}(const std::shared_ptr& creden {$entry{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} #end }) -{ - init(m_clientConfiguration); -} +{} /* End of legacy constructors due deprecation */ ${className}::~${className}() @@ -114,23 +102,6 @@ std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase>& ${className}:: return m_endpointProvider; } -void ${className}::init(const ${clientConfiguration}& config) -{ - if (!m_clientConfiguration.executor) { - if (!m_clientConfiguration.configFactories.executorCreateFn()) { - AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn"); - m_isInitialized = false; - return; - } - m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn(); - } - AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); - m_endpointProvider->InitBuiltInParameters(config); -#if($AdditionalServiceSpecificConfigLoadString) - ${AdditionalServiceSpecificConfigLoadString} -#end##if($AdditionalServiceSpecificConfigLoadString) -} - void ${className}::OverrideEndpoint(const Aws::String& endpoint) { AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);