diff --git a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp index da4cef3baa5..2ad46823406 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp +++ b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp @@ -109,6 +109,7 @@ DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clie std::shared_ptr endpointProvider) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), @@ -123,6 +124,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), @@ -137,6 +139,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), @@ -150,6 +153,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), @@ -163,6 +167,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), @@ -176,6 +181,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), 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 b643ee7ac91..0b6d3f3689e 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h @@ -36,13 +36,19 @@ namespace client 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, + explicit AwsSmithyClientT(const ServiceClientConfigurationT& clientConfig, + const Aws::String& serviceName, + const Aws::String& serviceUserAgentName, const std::shared_ptr& httpClient, const std::shared_ptr& errorMarshaller, const std::shared_ptr endpointProvider, const std::shared_ptr& authSchemeResolver, const Aws::UnorderedMap& authSchemes) - : AwsSmithyClientBase(Aws::MakeUnique(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller), + : AwsSmithyClientBase(Aws::MakeUnique(ServiceNameT, clientConfig), + serviceName, + serviceUserAgentName, + httpClient, + errorMarshaller), m_clientConfiguration(*static_cast(AwsSmithyClientBase::m_clientConfig.get())), m_endpointProvider(endpointProvider), m_authSchemeResolver(authSchemeResolver), @@ -57,6 +63,7 @@ namespace client AwsSmithyClientBase(other, Aws::MakeUnique(ServiceNameT, other.m_clientConfiguration), ServiceNameT, + other.m_serviceUserAgentName, Aws::Http::CreateHttpClient(other.m_clientConfiguration), Aws::MakeShared(ServiceNameT)), m_clientConfiguration{*static_cast(m_clientConfig.get())}, 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 3b6ce2b1623..ffd62f99e56 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h @@ -86,10 +86,12 @@ namespace client AwsSmithyClientBase(Aws::UniquePtr&& clientConfig, Aws::String serviceName, + Aws::String serviceUserAgentName, std::shared_ptr httpClient, std::shared_ptr errorMarshaller) : m_clientConfig(std::move(clientConfig)), m_serviceName(std::move(serviceName)), + m_serviceUserAgentName(std::move(serviceUserAgentName)), m_httpClient(std::move(httpClient)), m_errorMarshaller(std::move(errorMarshaller)), m_interceptors{Aws::MakeShared("AwsSmithyClientBase")} @@ -100,10 +102,12 @@ namespace client AwsSmithyClientBase(const AwsSmithyClientBase& other, Aws::UniquePtr&& clientConfig, Aws::String serviceName, + Aws::String serviceUserAgentName, std::shared_ptr httpClient, std::shared_ptr errorMarshaller) : m_clientConfig(std::move(clientConfig)), m_serviceName(std::move(serviceName)), + m_serviceUserAgentName(std::move(serviceUserAgentName)), m_httpClient(std::move(httpClient)), m_errorMarshaller(std::move(errorMarshaller)), m_interceptors{Aws::MakeShared("AwsSmithyClientBase")} @@ -180,6 +184,7 @@ namespace client std::shared_ptr m_clientConfig; Aws::String m_serviceName; + Aws::String m_serviceUserAgentName; std::shared_ptr m_httpClient; std::shared_ptr m_errorMarshaller; 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 5672d18c40f..7b7f249fa21 100644 --- a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp +++ b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp @@ -62,7 +62,7 @@ void AwsSmithyClientBase::baseInit() { m_interceptors.emplace_back(Aws::MakeShared(AWS_SMITHY_CLIENT_LOG, *m_clientConfig, m_clientConfig->retryStrategy->GetStrategyName(), - m_serviceName)); + m_serviceUserAgentName)); } } @@ -76,7 +76,7 @@ void AwsSmithyClientBase::baseCopyInit() { m_interceptors.emplace_back(Aws::MakeShared(AWS_SMITHY_CLIENT_LOG, *m_clientConfig, m_clientConfig->retryStrategy->GetStrategyName(), - m_serviceName)); + m_serviceUserAgentName)); } } 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 94296efb44a..a3d1c258aa1 100644 --- a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp @@ -186,6 +186,7 @@ class TestClient : public MySmithyClient MySmithyClient( clientConfig, serviceName, + "ServiceUserAgentName", httpClient, errorMarshaller, endpointProvider, @@ -408,6 +409,7 @@ class SampleClient: public smithy::client::AwsSmithyClientT(SampleServiceName), Aws::MakeShared(SampleServiceName), Aws::MakeShared(SampleServiceName), diff --git a/tests/aws-cpp-sdk-dynamodb-unit-tests/DynamoDBUnitTests.cpp b/tests/aws-cpp-sdk-dynamodb-unit-tests/DynamoDBUnitTests.cpp index 43f4e36908f..1ffa3770a68 100644 --- a/tests/aws-cpp-sdk-dynamodb-unit-tests/DynamoDBUnitTests.cpp +++ b/tests/aws-cpp-sdk-dynamodb-unit-tests/DynamoDBUnitTests.cpp @@ -309,7 +309,7 @@ TEST_F(DynamoDBUnitTest, ListTablesShouldHaveCorrectUserAgent) EXPECT_TRUE(sdkMetadata != userAgentParsed.end()); auto uaMetadata = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), [](const Aws::String & value) { return value.find("ua/") != Aws::String::npos; }); EXPECT_TRUE(uaMetadata != userAgentParsed.end()); - auto apiMetadata = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), [](const Aws::String & value) { return value.find("api/dynamodb") != Aws::String::npos; }); + auto apiMetadata = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), [](const Aws::String & value) { return value.find("api/DynamoDB") != Aws::String::npos; }); EXPECT_TRUE(apiMetadata != userAgentParsed.end()); auto osMetadata = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), [](const Aws::String & value) { return value.find("os/") != Aws::String::npos; }); EXPECT_TRUE(osMetadata != userAgentParsed.end()); 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 439256ea5ce..2137f5dc5e3 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 @@ -3,6 +3,7 @@ ${className}::${className}(const ${clientConfiguration}& clientConfiguration, std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), @@ -19,6 +20,7 @@ ${className}::${className}(const AWSCredentials& credentials, const ${clientConfiguration}& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), @@ -35,6 +37,7 @@ ${className}::${className}(const std::shared_ptr& creden const ${clientConfiguration}& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), @@ -50,6 +53,7 @@ ${className}::${className}(const std::shared_ptr& creden ${className}::${className}(const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), @@ -65,6 +69,7 @@ ${className}::${className}(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), @@ -80,6 +85,7 @@ ${className}::${className}(const std::shared_ptr& creden const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT(clientConfiguration, GetServiceName(), + "${metadata.serviceId}", Aws::Http::CreateHttpClient(clientConfiguration), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG),