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 c2790cb3795..b26e5ba44c2 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 @@ -51,34 +51,6 @@ namespace DynamoDB static const char* GetServiceName(); static const char* GetAllocationTag(); inline const char* GetServiceClientName() const override { return "DynamoDB"; } - - DynamoDBClient(const DynamoDBClient& other); - - DynamoDBClient(DynamoDBClient&& other); - - DynamoDBClient& operator=(const DynamoDBClient& other) - { - if(this == &other) - { - return *this; - } - AwsSmithyClientT::operator=(other); - Aws::Client::ClientWithAsyncTemplateMethods::operator=(other); - init(m_clientConfiguration); - return *this; - } - - DynamoDBClient& operator=(DynamoDBClient&& other) - { - if(this == &other) - { - return *this; - } - AwsSmithyClientT::operator=(std::move(other)); - Aws::Client::ClientWithAsyncTemplateMethods::operator=(std::move(other)); - init(m_clientConfiguration); - return *this; - } typedef DynamoDBClientConfiguration ClientConfigurationType; typedef DynamoDBEndpointProvider EndpointProviderType; @@ -2313,7 +2285,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 9f1a0884390..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,47 +196,12 @@ 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); m_endpointProvider->OverrideEndpoint(endpoint); } -DynamoDBClient::DynamoDBClient(const DynamoDBClient& other): - AwsSmithyClientT( - *other.m_clientConfig, - GetServiceName(), - Aws::Http::CreateHttpClient(other.m_clientConfiguration), - Aws::MakeShared(ALLOCATION_TAG), - other.m_endpointProvider, - Aws::MakeShared>(ALLOCATION_TAG), - other.m_authSchemes), - Aws::Client::ClientWithAsyncTemplateMethods(other) -{ - init(m_clientConfiguration); -} - -DynamoDBClient::DynamoDBClient(DynamoDBClient&& other): - AwsSmithyClientT(std::move(other)), - Aws::Client::ClientWithAsyncTemplateMethods(std::move(other)) -{ - init(m_clientConfiguration); -} - BatchExecuteStatementOutcome DynamoDBClient::BatchExecuteStatement(const BatchExecuteStatementRequest& request) const { AWS_OPERATION_GUARD(BatchExecuteStatement); 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 e4cfe9c2bb3..93a16b566ba 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h @@ -30,13 +30,11 @@ namespace client typename EndpointProviderT, typename SerializerT, typename ResponseT, - typename MarshallerT> + typename ErrorMarshallerT> class AwsSmithyClientT : public AwsSmithyClientBase { - private: - public: - static_assert(std::is_base_of::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller"); + 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, @@ -44,40 +42,47 @@ namespace client const std::shared_ptr endpointProvider, const std::shared_ptr& authSchemeResolver, const Aws::UnorderedMap& authSchemes) - : AwsSmithyClientBase(Aws::MakeShared(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller), + : AwsSmithyClientBase(Aws::MakeUnique(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller), m_clientConfiguration(*static_cast(AwsSmithyClientBase::m_clientConfig.get())), m_endpointProvider(endpointProvider), m_authSchemeResolver(authSchemeResolver), m_authSchemes(authSchemes), m_serializer(Aws::MakeShared(ServiceNameT, m_clientConfiguration.telemetryProvider)) { - m_serviceName = ServiceNameT; + m_serviceName = ServiceNameT; + initClient(); } AwsSmithyClientT(const AwsSmithyClientT& other): - AwsSmithyClientBase(Aws::MakeShared(ServiceNameT, other.m_clientConfig), other.m_serviceName, Aws::Http::CreateHttpClient(*other.m_clientConfig), Aws::MakeShared(other.m_serviceName.c_str())), - m_clientConfiguration{*static_cast(AwsSmithyClientBase::m_clientConfig.get())}, - m_endpointProvider{other.m_endpointProvider}, - m_authSchemeResolver{other.m_authSchemeResolver}, + AwsSmithyClientBase(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{Aws::MakeShared(ServiceNameT)}, + m_authSchemeResolver{Aws::MakeShared(ServiceNameT)}, m_authSchemes{other.m_authSchemes}, m_serializer{Aws::MakeShared(ServiceNameT, m_clientConfiguration.telemetryProvider)} { + initClient(); } - AwsSmithyClientT& operator=(const AwsSmithyClientT& other) { if(this != &other) { - AwsSmithyClientBase::operator=(other); - m_clientConfiguration = *static_cast(AwsSmithyClientBase::m_clientConfig.get()); - m_endpointProvider = other.m_endpointProvider; - m_authSchemeResolver = other.m_authSchemeResolver; + AwsSmithyClientBase::deepCopy(Aws::MakeUnique(ServiceNameT, other.m_clientConfiguration), + ServiceNameT, + Aws::Http::CreateHttpClient(other.m_clientConfiguration), + Aws::MakeShared(other.m_serviceName.c_str())); + m_clientConfiguration = *static_cast(m_clientConfig.get()); + m_endpointProvider = Aws::MakeShared(other.m_serviceName); + m_authSchemeResolver = Aws::MakeShared(other.m_serviceName); m_authSchemes = other.m_authSchemes; m_serializer = Aws::MakeShared(other.m_serviceName.c_str(), m_clientConfiguration.telemetryProvider); - m_errorMarshaller = Aws::MakeShared(other.m_serviceName.c_str()); + m_errorMarshaller = Aws::MakeShared(other.m_serviceName.c_str()); + initClient(); } - return *this; } @@ -88,6 +93,10 @@ namespace client 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 @@ -166,7 +175,6 @@ 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{}; 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 fdf9effba07..479025b97f0 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h @@ -20,6 +20,8 @@ #include #include +#include + namespace Aws { namespace Utils @@ -67,33 +69,6 @@ namespace client /* Non-template base client class that contains main Aws Client Request pipeline logic */ class SMITHY_API AwsSmithyClientBase { - private: - const char* ALLOC_TAG{"AwsSmithyClientBase"}; - - - void deepCopyClientConfiguration(const AwsSmithyClientBase& target) - { - //first create copy from target - m_clientConfig = Aws::MakeShared(target.m_serviceName.c_str(), *target.m_clientConfig); - - //then reinitialize appropriate fields unconditionally - assert(m_clientConfig->configFactories.retryStrategyCreateFn); - m_clientConfig->retryStrategy = m_clientConfig->configFactories.retryStrategyCreateFn(); - - assert(m_clientConfig->configFactories.executorCreateFn); - m_clientConfig->executor = m_clientConfig->configFactories.executorCreateFn(); - - assert(m_clientConfig->configFactories.writeRateLimiterCreateFn); - m_clientConfig->writeRateLimiter = m_clientConfig->configFactories.writeRateLimiterCreateFn(); - - assert(m_clientConfig->configFactories.readRateLimiterCreateFn); - m_clientConfig->readRateLimiter = m_clientConfig->configFactories.readRateLimiterCreateFn(); - - assert(m_clientConfig->configFactories.telemetryProviderCreateFn); - m_clientConfig->telemetryProvider = m_clientConfig->configFactories.telemetryProviderCreateFn(); - - } - public: using HttpRequest = Aws::Http::HttpRequest; using HttpResponse = Aws::Http::HttpResponse; @@ -108,7 +83,7 @@ namespace client using SelectAuthSchemeOptionOutcome = Aws::Utils::Outcome; using ResolveEndpointOutcome = Aws::Utils::Outcome; - AwsSmithyClientBase(std::shared_ptr&& clientConfig, + AwsSmithyClientBase(Aws::UniquePtr&& clientConfig, Aws::String serviceName, std::shared_ptr httpClient, std::shared_ptr errorMarshaller) : @@ -119,61 +94,12 @@ 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()); - } - - - AwsSmithyClientBase& operator=(const AwsSmithyClientBase& target) - { - if (this != &target) - { - deepCopyClientConfiguration(target); - m_serviceName = target.m_serviceName; - m_userAgent = target.m_userAgent; - m_httpClient = Aws::Http::CreateHttpClient(*target.m_clientConfig); - m_interceptors = {Aws::MakeShared(ALLOC_TAG)}; - m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get()); - } - return *this; - } - - AwsSmithyClientBase(const AwsSmithyClientBase& target): - m_serviceName{target.m_serviceName}, - m_userAgent{target.m_userAgent}, - m_httpClient{Aws::Http::CreateHttpClient(*target.m_clientConfig)}, - m_interceptors{Aws::MakeShared(ALLOC_TAG)} - { - deepCopyClientConfiguration(target); + init(); } + AwsSmithyClientBase(AwsSmithyClientBase& target) = delete; + AwsSmithyClientBase& operator=(AwsSmithyClientBase& target) = delete; AwsSmithyClientBase(AwsSmithyClientBase&& target) = default; - AwsSmithyClientBase& operator=(AwsSmithyClientBase&& target) = default; virtual ~AwsSmithyClientBase() = default; @@ -191,6 +117,50 @@ 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")}; + init(); + } + + void init() { + 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()); + } + /** * Transforms the AmazonWebServicesResult object into an HttpRequest. */ 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 2200612c1b7..58c40861f39 100644 --- a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp @@ -1,31 +1,28 @@ /** -* 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"; @@ -349,4 +346,62 @@ 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, SmithyClientShouldCopyAndAssign) { + SampleClient client{}; + SampleClient copy{client}; + AWS_UNREFERENCED_PARAM(copy); + SampleClient assign = 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 e69ffb30625..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 @@ -51,34 +51,6 @@ namespace ${serviceNamespace} static const char* GetServiceName(); static const char* GetAllocationTag(); inline const char* GetServiceClientName() const override { return "${metadata.serviceId}"; } - - ${className}(const ${className}& other); - - ${className}(${className}&& other); - - ${className}& operator=(const ${className}& other) - { - if(this == &other) - { - return *this; - } - AwsSmithyClientT::operator=(other); - Aws::Client::ClientWithAsyncTemplateMethods<${className}>::operator=(other); - init(m_clientConfiguration); - return *this; - } - - ${className}& operator=(${className}&& other) - { - if(this == &other) - { - return *this; - } - AwsSmithyClientT::operator=(std::move(other)); - Aws::Client::ClientWithAsyncTemplateMethods<${className}>::operator=(std::move(other)); - init(m_clientConfiguration); - return *this; - } #parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderConfigTypeDeclarations.vm") #parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderConstructors.vm") @@ -88,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 6381a47b2a0..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,46 +102,8 @@ 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); m_endpointProvider->OverrideEndpoint(endpoint); } - -${className}::${className}(const ${className}& other): - AwsSmithyClientT( - *other.m_clientConfig, - GetServiceName(), - Aws::Http::CreateHttpClient(other.m_clientConfiguration), - Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), - other.m_endpointProvider, - Aws::MakeShared>(ALLOCATION_TAG), - other.m_authSchemes), - Aws::Client::ClientWithAsyncTemplateMethods<${className}>(other) -{ - init(m_clientConfiguration); -} - -${className}::${className}(${className}&& other): - AwsSmithyClientT(std::move(other)), - Aws::Client::ClientWithAsyncTemplateMethods<${className}>(std::move(other)) -{ - init(m_clientConfiguration); -}