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 40b02568be6..f2d3e3f1ab8 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 @@ -6,15 +6,18 @@ #pragma once #include #include -#include #include -#include #include +#include +#include +#include +#include namespace Aws { namespace DynamoDB { + AWS_DYNAMODB_API extern const char SERVICE_NAME[]; /** * Amazon DynamoDB

Amazon DynamoDB is a fully managed NoSQL * database service that provides fast and predictable performance with seamless @@ -33,10 +36,16 @@ namespace DynamoDB * Zones in an Amazon Web Services Region, providing built-in high availability and * data durability.

*/ - class AWS_DYNAMODB_API DynamoDBClient : public Aws::Client::AWSJsonClient, public Aws::Client::ClientWithAsyncTemplateMethods + class AWS_DYNAMODB_API DynamoDBClient : smithy::client::AwsSmithyClientT, + Aws::Crt::Variant, + DynamoDBEndpointProviderBase, + smithy::client::JsonOutcomeSerializer, + smithy::client::JsonOutcome>, + Aws::Client::ClientWithAsyncTemplateMethods { public: - typedef Aws::Client::AWSJsonClient BASECLASS; static const char* GetServiceName(); static const char* GetAllocationTag(); @@ -2275,9 +2284,12 @@ namespace DynamoDB friend class Aws::Client::ClientWithAsyncTemplateMethods; void init(const DynamoDBClientConfiguration& clientConfiguration); + void OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint, + const Aws::String& operationName, + const Aws::String& endpointKey, + const Aws::DynamoDB::Model::DescribeEndpointsRequest& endpointRequest, + bool enforceDiscovery) const; mutable Aws::Utils::ConcurrentCache m_endpointsCache; - DynamoDBClientConfiguration m_clientConfiguration; - std::shared_ptr m_endpointProvider; }; } // namespace DynamoDB diff --git a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp index b06d89371c8..9f90e7058f9 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp +++ b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp @@ -4,19 +4,17 @@ */ #include -#include #include #include #include -#include #include #include -#include #include #include #include #include #include + #include #include @@ -82,6 +80,9 @@ #include +#include +#include +#include using namespace Aws; using namespace Aws::Auth; @@ -97,100 +98,106 @@ namespace Aws { namespace DynamoDB { - const char SERVICE_NAME[] = "dynamodb"; const char ALLOCATION_TAG[] = "DynamoDBClient"; + const char SERVICE_NAME[] = "dynamodb"; } } const char* DynamoDBClient::GetServiceName() {return SERVICE_NAME;} const char* DynamoDBClient::GetAllocationTag() {return ALLOCATION_TAG;} DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clientConfiguration, - std::shared_ptr endpointProvider) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - Aws::MakeShared(ALLOCATION_TAG), - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared(ALLOCATION_TAG)) + std::shared_ptr endpointProvider) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region}}, + }) { init(m_clientConfiguration); } DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, - std::shared_ptr endpointProvider, - const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - Aws::MakeShared(ALLOCATION_TAG, credentials), - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared(ALLOCATION_TAG)) + std::shared_ptr endpointProvider, + const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {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, - const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - credentialsProvider, - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared(ALLOCATION_TAG)) + std::shared_ptr endpointProvider, + const DynamoDB::DynamoDBClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {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) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - Aws::MakeShared(ALLOCATION_TAG), - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) +/* Legacy constructors due deprecation */ +DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {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) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - Aws::MakeShared(ALLOCATION_TAG, credentials), - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) + const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {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) : - BASECLASS(clientConfiguration, - Aws::MakeShared(ALLOCATION_TAG, - credentialsProvider, - SERVICE_NAME, - Aws::Region::ComputeSignerRegion(clientConfiguration.region)), - Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration), - m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) + const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { + {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} + }) { init(m_clientConfiguration); } +/* End of legacy constructors due deprecation */ - /* End of legacy constructors due deprecation */ DynamoDBClient::~DynamoDBClient() { ShutdownSdkClient(this, -1); @@ -203,7 +210,6 @@ std::shared_ptr& DynamoDBClient::accessEndpointPro void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config) { - AWSClient::SetServiceClientName("DynamoDB"); if (!m_clientConfiguration.executor) { if (!m_clientConfiguration.configFactories.executorCreateFn()) { AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn"); @@ -218,30 +224,26 @@ void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config) void DynamoDBClient::OverrideEndpoint(const Aws::String& endpoint) { - AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); - m_endpointProvider->OverrideEndpoint(endpoint); + AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); + m_endpointProvider->OverrideEndpoint(endpoint); } BatchExecuteStatementOutcome DynamoDBClient::BatchExecuteStatement(const BatchExecuteStatementRequest& request) const { AWS_OPERATION_GUARD(BatchExecuteStatement); AWS_OPERATION_CHECK_PTR(m_endpointProvider, BatchExecuteStatement, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, BatchExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, BatchExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, BatchExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".BatchExecuteStatement", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> BatchExecuteStatementOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, BatchExecuteStatement, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return BatchExecuteStatementOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return BatchExecuteStatementOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -252,57 +254,20 @@ BatchGetItemOutcome DynamoDBClient::BatchGetItem(const BatchGetItemRequest& requ { AWS_OPERATION_GUARD(BatchGetItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, BatchGetItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, BatchGetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, BatchGetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, BatchGetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".BatchGetItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> BatchGetItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("BatchGetItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("BatchGetItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("BatchGetItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("BatchGetItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, BatchGetItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return BatchGetItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return BatchGetItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -313,57 +278,20 @@ BatchWriteItemOutcome DynamoDBClient::BatchWriteItem(const BatchWriteItemRequest { AWS_OPERATION_GUARD(BatchWriteItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, BatchWriteItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, BatchWriteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, BatchWriteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, BatchWriteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".BatchWriteItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> BatchWriteItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("BatchWriteItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("BatchWriteItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("BatchWriteItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("BatchWriteItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, BatchWriteItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return BatchWriteItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return BatchWriteItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -374,57 +302,20 @@ CreateBackupOutcome DynamoDBClient::CreateBackup(const CreateBackupRequest& requ { AWS_OPERATION_GUARD(CreateBackup); AWS_OPERATION_CHECK_PTR(m_endpointProvider, CreateBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, CreateBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, CreateBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, CreateBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".CreateBackup", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> CreateBackupOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("CreateBackup", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("CreateBackup", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("CreateBackup", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("CreateBackup", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, CreateBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return CreateBackupOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return CreateBackupOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -435,57 +326,20 @@ CreateGlobalTableOutcome DynamoDBClient::CreateGlobalTable(const CreateGlobalTab { AWS_OPERATION_GUARD(CreateGlobalTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, CreateGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, CreateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, CreateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, CreateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".CreateGlobalTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> CreateGlobalTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("CreateGlobalTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("CreateGlobalTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("CreateGlobalTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("CreateGlobalTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, CreateGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return CreateGlobalTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return CreateGlobalTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -496,57 +350,20 @@ CreateTableOutcome DynamoDBClient::CreateTable(const CreateTableRequest& request { AWS_OPERATION_GUARD(CreateTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, CreateTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, CreateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, CreateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, CreateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".CreateTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> CreateTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("CreateTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("CreateTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("CreateTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("CreateTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, CreateTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return CreateTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return CreateTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -557,57 +374,20 @@ DeleteBackupOutcome DynamoDBClient::DeleteBackup(const DeleteBackupRequest& requ { AWS_OPERATION_GUARD(DeleteBackup); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DeleteBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DeleteBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DeleteBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DeleteBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DeleteBackup", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DeleteBackupOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DeleteBackup", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DeleteBackup", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DeleteBackup", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DeleteBackup", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DeleteBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DeleteBackupOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DeleteBackupOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -618,57 +398,20 @@ DeleteItemOutcome DynamoDBClient::DeleteItem(const DeleteItemRequest& request) c { AWS_OPERATION_GUARD(DeleteItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DeleteItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DeleteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DeleteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DeleteItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DeleteItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DeleteItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DeleteItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DeleteItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DeleteItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DeleteItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DeleteItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DeleteItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DeleteItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -679,57 +422,20 @@ DeleteResourcePolicyOutcome DynamoDBClient::DeleteResourcePolicy(const DeleteRes { AWS_OPERATION_GUARD(DeleteResourcePolicy); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DeleteResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DeleteResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DeleteResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DeleteResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DeleteResourcePolicy", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DeleteResourcePolicyOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DeleteResourcePolicy", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DeleteResourcePolicy", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DeleteResourcePolicy", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DeleteResourcePolicy", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DeleteResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DeleteResourcePolicyOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DeleteResourcePolicyOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -740,57 +446,20 @@ DeleteTableOutcome DynamoDBClient::DeleteTable(const DeleteTableRequest& request { AWS_OPERATION_GUARD(DeleteTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DeleteTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DeleteTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DeleteTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DeleteTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DeleteTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DeleteTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DeleteTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DeleteTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DeleteTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DeleteTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DeleteTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DeleteTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DeleteTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -801,57 +470,20 @@ DescribeBackupOutcome DynamoDBClient::DescribeBackup(const DescribeBackupRequest { AWS_OPERATION_GUARD(DescribeBackup); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeBackup", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeBackupOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeBackup", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeBackup", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeBackup", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeBackup", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeBackupOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeBackupOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -862,57 +494,20 @@ DescribeContinuousBackupsOutcome DynamoDBClient::DescribeContinuousBackups(const { AWS_OPERATION_GUARD(DescribeContinuousBackups); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeContinuousBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeContinuousBackups", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeContinuousBackupsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeContinuousBackups", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeContinuousBackups", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeContinuousBackups", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeContinuousBackups", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeContinuousBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeContinuousBackupsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeContinuousBackupsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -923,22 +518,18 @@ DescribeContributorInsightsOutcome DynamoDBClient::DescribeContributorInsights(c { AWS_OPERATION_GUARD(DescribeContributorInsights); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeContributorInsights", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeContributorInsightsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeContributorInsightsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeContributorInsightsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -949,22 +540,18 @@ DescribeEndpointsOutcome DynamoDBClient::DescribeEndpoints(const DescribeEndpoin { AWS_OPERATION_GUARD(DescribeEndpoints); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeEndpoints, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeEndpoints, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeEndpoints, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeEndpoints, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeEndpoints", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeEndpointsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeEndpoints, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeEndpointsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeEndpointsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -975,22 +562,18 @@ DescribeExportOutcome DynamoDBClient::DescribeExport(const DescribeExportRequest { AWS_OPERATION_GUARD(DescribeExport); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeExport, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeExport, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeExport, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeExport, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeExport", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeExportOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeExport, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeExportOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeExportOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1001,57 +584,20 @@ DescribeGlobalTableOutcome DynamoDBClient::DescribeGlobalTable(const DescribeGlo { AWS_OPERATION_GUARD(DescribeGlobalTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeGlobalTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeGlobalTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeGlobalTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeGlobalTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeGlobalTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeGlobalTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeGlobalTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeGlobalTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1062,57 +608,20 @@ DescribeGlobalTableSettingsOutcome DynamoDBClient::DescribeGlobalTableSettings(c { AWS_OPERATION_GUARD(DescribeGlobalTableSettings); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeGlobalTableSettings, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeGlobalTableSettings", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeGlobalTableSettingsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeGlobalTableSettings", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeGlobalTableSettings", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeGlobalTableSettings", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeGlobalTableSettings", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeGlobalTableSettings, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeGlobalTableSettingsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeGlobalTableSettingsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1123,22 +632,18 @@ DescribeImportOutcome DynamoDBClient::DescribeImport(const DescribeImportRequest { AWS_OPERATION_GUARD(DescribeImport); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeImport, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeImport, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeImport, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeImport, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeImport", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeImportOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeImport, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeImportOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeImportOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1149,57 +654,20 @@ DescribeKinesisStreamingDestinationOutcome DynamoDBClient::DescribeKinesisStream { AWS_OPERATION_GUARD(DescribeKinesisStreamingDestination); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeKinesisStreamingDestination", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeKinesisStreamingDestinationOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeKinesisStreamingDestination", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeKinesisStreamingDestination", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeKinesisStreamingDestination", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeKinesisStreamingDestination", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeKinesisStreamingDestinationOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeKinesisStreamingDestinationOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1210,57 +678,20 @@ DescribeLimitsOutcome DynamoDBClient::DescribeLimits(const DescribeLimitsRequest { AWS_OPERATION_GUARD(DescribeLimits); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeLimits, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeLimits, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeLimits, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeLimits, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeLimits", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeLimitsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeLimits", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeLimits", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeLimits", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeLimits", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeLimits, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeLimitsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeLimitsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1271,57 +702,20 @@ DescribeTableOutcome DynamoDBClient::DescribeTable(const DescribeTableRequest& r { AWS_OPERATION_GUARD(DescribeTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1332,22 +726,18 @@ DescribeTableReplicaAutoScalingOutcome DynamoDBClient::DescribeTableReplicaAutoS { AWS_OPERATION_GUARD(DescribeTableReplicaAutoScaling); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeTableReplicaAutoScaling, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeTableReplicaAutoScaling", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeTableReplicaAutoScalingOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeTableReplicaAutoScaling, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeTableReplicaAutoScalingOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeTableReplicaAutoScalingOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1358,57 +748,20 @@ DescribeTimeToLiveOutcome DynamoDBClient::DescribeTimeToLive(const DescribeTimeT { AWS_OPERATION_GUARD(DescribeTimeToLive); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DescribeTimeToLive, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DescribeTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DescribeTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DescribeTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DescribeTimeToLive", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DescribeTimeToLiveOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DescribeTimeToLive", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DescribeTimeToLive", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DescribeTimeToLive", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DescribeTimeToLive", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DescribeTimeToLive, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DescribeTimeToLiveOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DescribeTimeToLiveOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1419,57 +772,20 @@ DisableKinesisStreamingDestinationOutcome DynamoDBClient::DisableKinesisStreamin { AWS_OPERATION_GUARD(DisableKinesisStreamingDestination); AWS_OPERATION_CHECK_PTR(m_endpointProvider, DisableKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, DisableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, DisableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, DisableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".DisableKinesisStreamingDestination", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> DisableKinesisStreamingDestinationOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("DisableKinesisStreamingDestination", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("DisableKinesisStreamingDestination", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("DisableKinesisStreamingDestination", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("DisableKinesisStreamingDestination", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, DisableKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return DisableKinesisStreamingDestinationOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return DisableKinesisStreamingDestinationOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1480,57 +796,20 @@ EnableKinesisStreamingDestinationOutcome DynamoDBClient::EnableKinesisStreamingD { AWS_OPERATION_GUARD(EnableKinesisStreamingDestination); AWS_OPERATION_CHECK_PTR(m_endpointProvider, EnableKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, EnableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, EnableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, EnableKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".EnableKinesisStreamingDestination", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> EnableKinesisStreamingDestinationOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("EnableKinesisStreamingDestination", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("EnableKinesisStreamingDestination", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("EnableKinesisStreamingDestination", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("EnableKinesisStreamingDestination", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, EnableKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return EnableKinesisStreamingDestinationOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return EnableKinesisStreamingDestinationOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1541,22 +820,18 @@ ExecuteStatementOutcome DynamoDBClient::ExecuteStatement(const ExecuteStatementR { AWS_OPERATION_GUARD(ExecuteStatement); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ExecuteStatement, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ExecuteStatement, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ExecuteStatement", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ExecuteStatementOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ExecuteStatement, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ExecuteStatementOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ExecuteStatementOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1567,22 +842,18 @@ ExecuteTransactionOutcome DynamoDBClient::ExecuteTransaction(const ExecuteTransa { AWS_OPERATION_GUARD(ExecuteTransaction); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ExecuteTransaction, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ExecuteTransaction, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ExecuteTransaction, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ExecuteTransaction, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ExecuteTransaction", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ExecuteTransactionOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ExecuteTransaction, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ExecuteTransactionOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ExecuteTransactionOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1593,22 +864,18 @@ ExportTableToPointInTimeOutcome DynamoDBClient::ExportTableToPointInTime(const E { AWS_OPERATION_GUARD(ExportTableToPointInTime); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ExportTableToPointInTime, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ExportTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ExportTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ExportTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ExportTableToPointInTime", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ExportTableToPointInTimeOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ExportTableToPointInTime, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ExportTableToPointInTimeOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ExportTableToPointInTimeOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1619,57 +886,20 @@ GetItemOutcome DynamoDBClient::GetItem(const GetItemRequest& request) const { AWS_OPERATION_GUARD(GetItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, GetItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, GetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, GetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, GetItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".GetItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> GetItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("GetItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("GetItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("GetItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("GetItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, GetItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return GetItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return GetItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1680,57 +910,20 @@ GetResourcePolicyOutcome DynamoDBClient::GetResourcePolicy(const GetResourcePoli { AWS_OPERATION_GUARD(GetResourcePolicy); AWS_OPERATION_CHECK_PTR(m_endpointProvider, GetResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, GetResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, GetResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, GetResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".GetResourcePolicy", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> GetResourcePolicyOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("GetResourcePolicy", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("GetResourcePolicy", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("GetResourcePolicy", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("GetResourcePolicy", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, GetResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return GetResourcePolicyOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return GetResourcePolicyOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1741,22 +934,18 @@ ImportTableOutcome DynamoDBClient::ImportTable(const ImportTableRequest& request { AWS_OPERATION_GUARD(ImportTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ImportTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ImportTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ImportTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ImportTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ImportTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ImportTableOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ImportTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ImportTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ImportTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1767,57 +956,20 @@ ListBackupsOutcome DynamoDBClient::ListBackups(const ListBackupsRequest& request { AWS_OPERATION_GUARD(ListBackups); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListBackups", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListBackupsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("ListBackups", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("ListBackups", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("ListBackups", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("ListBackups", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListBackupsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListBackupsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1828,22 +980,18 @@ ListContributorInsightsOutcome DynamoDBClient::ListContributorInsights(const Lis { AWS_OPERATION_GUARD(ListContributorInsights); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListContributorInsights", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListContributorInsightsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListContributorInsightsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListContributorInsightsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1854,22 +1002,18 @@ ListExportsOutcome DynamoDBClient::ListExports(const ListExportsRequest& request { AWS_OPERATION_GUARD(ListExports); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListExports, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListExports, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListExports, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListExports, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListExports", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListExportsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListExports, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListExportsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListExportsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1880,57 +1024,20 @@ ListGlobalTablesOutcome DynamoDBClient::ListGlobalTables(const ListGlobalTablesR { AWS_OPERATION_GUARD(ListGlobalTables); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListGlobalTables, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListGlobalTables, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListGlobalTables, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListGlobalTables, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListGlobalTables", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListGlobalTablesOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("ListGlobalTables", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("ListGlobalTables", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("ListGlobalTables", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("ListGlobalTables", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListGlobalTables, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListGlobalTablesOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListGlobalTablesOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1941,22 +1048,18 @@ ListImportsOutcome DynamoDBClient::ListImports(const ListImportsRequest& request { AWS_OPERATION_GUARD(ListImports); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListImports, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListImports, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListImports, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListImports, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListImports", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListImportsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListImports, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListImportsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListImportsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -1967,57 +1070,20 @@ ListTablesOutcome DynamoDBClient::ListTables(const ListTablesRequest& request) c { AWS_OPERATION_GUARD(ListTables); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListTables, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListTables, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListTables, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListTables, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListTables", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListTablesOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("ListTables", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("ListTables", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("ListTables", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("ListTables", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListTables, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListTablesOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListTablesOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2028,57 +1094,20 @@ ListTagsOfResourceOutcome DynamoDBClient::ListTagsOfResource(const ListTagsOfRes { AWS_OPERATION_GUARD(ListTagsOfResource); AWS_OPERATION_CHECK_PTR(m_endpointProvider, ListTagsOfResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, ListTagsOfResource, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ListTagsOfResource, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, ListTagsOfResource, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".ListTagsOfResource", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ListTagsOfResourceOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("ListTagsOfResource", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("ListTagsOfResource", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("ListTagsOfResource", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("ListTagsOfResource", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ListTagsOfResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ListTagsOfResourceOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ListTagsOfResourceOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2089,57 +1118,20 @@ PutItemOutcome DynamoDBClient::PutItem(const PutItemRequest& request) const { AWS_OPERATION_GUARD(PutItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, PutItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, PutItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, PutItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, PutItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".PutItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> PutItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("PutItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("PutItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("PutItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("PutItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, PutItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return PutItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return PutItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2150,57 +1142,20 @@ PutResourcePolicyOutcome DynamoDBClient::PutResourcePolicy(const PutResourcePoli { AWS_OPERATION_GUARD(PutResourcePolicy); AWS_OPERATION_CHECK_PTR(m_endpointProvider, PutResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, PutResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, PutResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, PutResourcePolicy, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".PutResourcePolicy", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> PutResourcePolicyOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("PutResourcePolicy", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("PutResourcePolicy", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("PutResourcePolicy", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("PutResourcePolicy", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, PutResourcePolicy, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return PutResourcePolicyOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return PutResourcePolicyOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2211,57 +1166,20 @@ QueryOutcome DynamoDBClient::Query(const QueryRequest& request) const { AWS_OPERATION_GUARD(Query); AWS_OPERATION_CHECK_PTR(m_endpointProvider, Query, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, Query, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, Query, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, Query, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".Query", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> QueryOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("Query", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("Query", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("Query", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("Query", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, Query, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return QueryOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return QueryOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2272,57 +1190,20 @@ RestoreTableFromBackupOutcome DynamoDBClient::RestoreTableFromBackup(const Resto { AWS_OPERATION_GUARD(RestoreTableFromBackup); AWS_OPERATION_CHECK_PTR(m_endpointProvider, RestoreTableFromBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, RestoreTableFromBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, RestoreTableFromBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, RestoreTableFromBackup, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".RestoreTableFromBackup", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> RestoreTableFromBackupOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("RestoreTableFromBackup", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("RestoreTableFromBackup", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("RestoreTableFromBackup", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("RestoreTableFromBackup", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, RestoreTableFromBackup, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return RestoreTableFromBackupOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return RestoreTableFromBackupOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2333,57 +1214,20 @@ RestoreTableToPointInTimeOutcome DynamoDBClient::RestoreTableToPointInTime(const { AWS_OPERATION_GUARD(RestoreTableToPointInTime); AWS_OPERATION_CHECK_PTR(m_endpointProvider, RestoreTableToPointInTime, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, RestoreTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, RestoreTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, RestoreTableToPointInTime, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".RestoreTableToPointInTime", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> RestoreTableToPointInTimeOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("RestoreTableToPointInTime", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("RestoreTableToPointInTime", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("RestoreTableToPointInTime", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("RestoreTableToPointInTime", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, RestoreTableToPointInTime, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return RestoreTableToPointInTimeOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return RestoreTableToPointInTimeOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2394,57 +1238,20 @@ ScanOutcome DynamoDBClient::Scan(const ScanRequest& request) const { AWS_OPERATION_GUARD(Scan); AWS_OPERATION_CHECK_PTR(m_endpointProvider, Scan, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, Scan, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, Scan, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, Scan, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".Scan", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> ScanOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("Scan", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("Scan", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("Scan", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("Scan", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, Scan, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return ScanOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return ScanOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2455,57 +1262,20 @@ TagResourceOutcome DynamoDBClient::TagResource(const TagResourceRequest& request { AWS_OPERATION_GUARD(TagResource); AWS_OPERATION_CHECK_PTR(m_endpointProvider, TagResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, TagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, TagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, TagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".TagResource", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> TagResourceOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("TagResource", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("TagResource", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("TagResource", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("TagResource", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, TagResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return TagResourceOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return TagResourceOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2516,57 +1286,20 @@ TransactGetItemsOutcome DynamoDBClient::TransactGetItems(const TransactGetItemsR { AWS_OPERATION_GUARD(TransactGetItems); AWS_OPERATION_CHECK_PTR(m_endpointProvider, TransactGetItems, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, TransactGetItems, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, TransactGetItems, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, TransactGetItems, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".TransactGetItems", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> TransactGetItemsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("TransactGetItems", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("TransactGetItems", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("TransactGetItems", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("TransactGetItems", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, TransactGetItems, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return TransactGetItemsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return TransactGetItemsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2577,57 +1310,20 @@ TransactWriteItemsOutcome DynamoDBClient::TransactWriteItems(const TransactWrite { AWS_OPERATION_GUARD(TransactWriteItems); AWS_OPERATION_CHECK_PTR(m_endpointProvider, TransactWriteItems, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, TransactWriteItems, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, TransactWriteItems, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, TransactWriteItems, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".TransactWriteItems", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> TransactWriteItemsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("TransactWriteItems", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("TransactWriteItems", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("TransactWriteItems", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("TransactWriteItems", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, TransactWriteItems, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return TransactWriteItemsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return TransactWriteItemsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2638,57 +1334,20 @@ UntagResourceOutcome DynamoDBClient::UntagResource(const UntagResourceRequest& r { AWS_OPERATION_GUARD(UntagResource); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UntagResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UntagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UntagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UntagResource, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UntagResource", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UntagResourceOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UntagResource", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UntagResource", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UntagResource", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UntagResource", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UntagResource, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UntagResourceOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UntagResourceOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2699,57 +1358,20 @@ UpdateContinuousBackupsOutcome DynamoDBClient::UpdateContinuousBackups(const Upd { AWS_OPERATION_GUARD(UpdateContinuousBackups); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateContinuousBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateContinuousBackups, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateContinuousBackups", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateContinuousBackupsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateContinuousBackups", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateContinuousBackups", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateContinuousBackups", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateContinuousBackups", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateContinuousBackups, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateContinuousBackupsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateContinuousBackupsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2760,22 +1382,18 @@ UpdateContributorInsightsOutcome DynamoDBClient::UpdateContributorInsights(const { AWS_OPERATION_GUARD(UpdateContributorInsights); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateContributorInsights, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateContributorInsights", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateContributorInsightsOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateContributorInsights, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateContributorInsightsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateContributorInsightsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2786,57 +1404,20 @@ UpdateGlobalTableOutcome DynamoDBClient::UpdateGlobalTable(const UpdateGlobalTab { AWS_OPERATION_GUARD(UpdateGlobalTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateGlobalTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateGlobalTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateGlobalTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateGlobalTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateGlobalTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateGlobalTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateGlobalTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateGlobalTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateGlobalTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateGlobalTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2847,57 +1428,20 @@ UpdateGlobalTableSettingsOutcome DynamoDBClient::UpdateGlobalTableSettings(const { AWS_OPERATION_GUARD(UpdateGlobalTableSettings); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateGlobalTableSettings, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateGlobalTableSettings, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateGlobalTableSettings", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateGlobalTableSettingsOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateGlobalTableSettings", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateGlobalTableSettings", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateGlobalTableSettings", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateGlobalTableSettings", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateGlobalTableSettings, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateGlobalTableSettingsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateGlobalTableSettingsOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2908,57 +1452,20 @@ UpdateItemOutcome DynamoDBClient::UpdateItem(const UpdateItemRequest& request) c { AWS_OPERATION_GUARD(UpdateItem); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateItem, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateItem, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateItem, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateItem", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateItemOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateItem", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateItem", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateItem", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateItem", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateItem, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateItemOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateItemOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -2969,57 +1476,20 @@ UpdateKinesisStreamingDestinationOutcome DynamoDBClient::UpdateKinesisStreamingD { AWS_OPERATION_GUARD(UpdateKinesisStreamingDestination); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateKinesisStreamingDestination, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateKinesisStreamingDestination", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateKinesisStreamingDestinationOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateKinesisStreamingDestination", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateKinesisStreamingDestination", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateKinesisStreamingDestination", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateKinesisStreamingDestination", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateKinesisStreamingDestination, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateKinesisStreamingDestinationOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateKinesisStreamingDestinationOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -3030,57 +1500,20 @@ UpdateTableOutcome DynamoDBClient::UpdateTable(const UpdateTableRequest& request { AWS_OPERATION_GUARD(UpdateTable); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateTable, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateTable", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateTableOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateTable", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateTable", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateTable", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateTable", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateTable, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateTableOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateTableOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -3091,22 +1524,18 @@ UpdateTableReplicaAutoScalingOutcome DynamoDBClient::UpdateTableReplicaAutoScali { AWS_OPERATION_GUARD(UpdateTableReplicaAutoScaling); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateTableReplicaAutoScaling, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateTableReplicaAutoScaling, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateTableReplicaAutoScaling", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateTableReplicaAutoScalingOutcome { - auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateTableReplicaAutoScaling, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateTableReplicaAutoScalingOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateTableReplicaAutoScalingOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + AWS_UNREFERENCED_PARAM(resolvedEndpoint); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, @@ -3117,60 +1546,66 @@ UpdateTimeToLiveOutcome DynamoDBClient::UpdateTimeToLive(const UpdateTimeToLiveR { AWS_OPERATION_GUARD(UpdateTimeToLive); AWS_OPERATION_CHECK_PTR(m_endpointProvider, UpdateTimeToLive, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); - AWS_OPERATION_CHECK_PTR(m_telemetryProvider, UpdateTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); - auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); - auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, UpdateTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, UpdateTimeToLive, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".UpdateTimeToLive", {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, smithy::components::tracing::SpanKind::CLIENT); return TracingUtils::MakeCallWithTiming( [&]()-> UpdateTimeToLiveOutcome { - ResolveEndpointOutcome endpointResolutionOutcome = Aws::Endpoint::AWSEndpoint(); - const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); - if (enableEndpointDiscovery) - { - Aws::String endpointKey = "Shared"; - Aws::String endpoint; - if (m_endpointsCache.Get(endpointKey, endpoint)) - { - AWS_LOGSTREAM_TRACE("UpdateTimeToLive", "Making request to cached endpoint: " << endpoint); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_TRACE("UpdateTimeToLive", "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); - DescribeEndpointsRequest endpointRequest; - auto endpointOutcome = DescribeEndpoints(endpointRequest); - if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) - { - const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; - - m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); - endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); - AWS_LOGSTREAM_TRACE("UpdateTimeToLive", "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); - endpointResolutionOutcome.GetResult().SetURI(endpoint); - } - else - { - AWS_LOGSTREAM_ERROR("UpdateTimeToLive", "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); - endpointResolutionOutcome = endpointOutcome.GetError(); - } - } - } - if (!enableEndpointDiscovery || !endpointResolutionOutcome.IsSuccess() || endpointResolutionOutcome.GetResult().GetURL().empty()) { - endpointResolutionOutcome = TracingUtils::MakeCallWithTiming( - [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, - TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, - *meter, - {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); - } - AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, UpdateTimeToLive, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); - return UpdateTimeToLiveOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); + return UpdateTimeToLiveOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { + Aws::String endpointKey{"Shared"}; + DescribeEndpointsRequest endpointRequest{}; + this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, false); + })); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); } + +void DynamoDBClient::OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint, + const Aws::String& operationName, + const Aws::String& endpointKey, + const Aws::DynamoDB::Model::DescribeEndpointsRequest& endpointRequest, + bool enforceDiscovery) const +{ + const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); + if (enableEndpointDiscovery) + { + Aws::String endpoint; + if (m_endpointsCache.Get(endpointKey, endpoint)) + { + AWS_LOGSTREAM_TRACE(operationName.c_str(), "Making request to cached endpoint: " << endpoint); + endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; + resolvedEndpoint.SetURI(endpoint); + } + else + { + AWS_LOGSTREAM_TRACE(operationName.c_str(), "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); + auto endpointOutcome = DescribeEndpoints(endpointRequest); + if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) + { + const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; + m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); + endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); + AWS_LOGSTREAM_TRACE(operationName.c_str(), "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); + resolvedEndpoint.SetURI(endpoint); + } + else + { + if(enforceDiscovery) + { + AWS_LOGSTREAM_ERROR(operationName.c_str(), "Failed to discover endpoints " << endpointOutcome.GetError()); + } + else + { + AWS_LOGSTREAM_ERROR(operationName.c_str(), "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); + } + } + } + } +} diff --git a/src/aws-cpp-sdk-core/CMakeLists.txt b/src/aws-cpp-sdk-core/CMakeLists.txt index 9fcf6b62487..29a52690278 100644 --- a/src/aws-cpp-sdk-core/CMakeLists.txt +++ b/src/aws-cpp-sdk-core/CMakeLists.txt @@ -77,6 +77,7 @@ file(GLOB SMITHY_CLIENT_HEADERS "include/smithy/client/*.h") file(GLOB SMITHY_CLIENT_IMPL_HEADERS "include/smithy/client/impl/*.h") file(GLOB SMITHY_CLIENT_COMMON_HEADERS "include/smithy/client/common/*.h") file(GLOB SMITHY_CLIENT_FEATURES_HEADERS "include/smithy/client/features/*.h") +file(GLOB SMITHY_CLIENT_SERIALIZER_HEADERS "include/smithy/client/serializer/*.h") file(GLOB SMITHY_TRACING_HEADERS "include/smithy/tracing/*.h") file(GLOB SMITHY_IDENTITY_HEADERS "include/smithy/identity/*.h") file(GLOB SMITHY_IDENTITY_AUTH_HEADERS "include/smithy/identity/auth/*.h") @@ -346,6 +347,7 @@ file(GLOB AWS_NATIVE_SDK_COMMON_HEADERS ${SMITHY_CLIENT_IMPL_HEADERS} ${SMITHY_CLIENT_COMMON_HEADERS} ${SMITHY_CLIENT_FEATURES_HEADERS} + ${SMITHY_CLIENT_SERIALIZER_HEADERS} ${SMITHY_TRACING_HEADERS} ${SMITHY_IDENTITY_HEADERS} ${SMITHY_IDENTITY_AUTH_HEADERS} @@ -478,6 +480,7 @@ if(MSVC) source_group("Header Files\\smithy\\client" FILES ${SMITHY_CLIENT_IMPL_HEADERS}) source_group("Header Files\\smithy\\client" FILES ${SMITHY_CLIENT_COMMON_HEADERS}) source_group("Header Files\\smithy\\client" FILES ${SMITHY_CLIENT_FEATURES_HEADERS}) + source_group("Header Files\\smithy\\client" FILES ${SMITHY_CLIENT_SERIALIZER_HEADERS}) source_group("Header Files\\smithy\\tracing" FILES ${SMITHY_TRACING_HEADERS}) source_group("Header Files\\smithy\\identity\\auth" FILES ${SMITHY_IDENTITY_AUTH_HEADERS}) source_group("Header Files\\smithy\\identity\\auth\\impl" FILES ${SMITHY_IDENTITY_AUTH_IMPL_HEADERS}) @@ -751,6 +754,10 @@ install (FILES ${CJSON_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/extern install (FILES ${TINYXML2_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/external/tinyxml2) install (FILES ${SMITHY_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy) install (FILES ${SMITHY_CLIENT_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/client) +install (FILES ${SMITHY_CLIENT_IMPL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/client/impl) +install (FILES ${SMITHY_CLIENT_COMMON_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/client/common) +install (FILES ${SMITHY_CLIENT_FEATURES_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/client/features) +install (FILES ${SMITHY_CLIENT_SERIALIZER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/client/serializer) install (FILES ${SMITHY_TRACING_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/tracing) install (FILES ${SMITHY_IDENTITY_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity) install (FILES ${SMITHY_IDENTITY_AUTH_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/auth) @@ -758,6 +765,7 @@ install (FILES ${SMITHY_IDENTITY_AUTH_IMPL_HEADERS} DESTINATION ${INCLUDE_DIRECT install (FILES ${SMITHY_IDENTITY_AUTH_BUILTIN_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/auth/built-in) install (FILES ${SMITHY_IDENTITY_IDENTITY_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/identity) install (FILES ${SMITHY_IDENTITY_RESOLVER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/resolver) +install (FILES ${SMITHY_IDENTITY_RESOLVER_BUILTIN_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/resolver/built-in) install (FILES ${SMITHY_IDENTITY_IDENTITY_IMPL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/identity/impl) install (FILES ${SMITHY_IDENTITY_RESOLVER_IMPL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/resolver/impl) install (FILES ${SMITHY_IDENTITY_SIGNER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/smithy/identity/signer) 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 ecbe34fac17..32e22e30e85 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h @@ -27,7 +27,9 @@ namespace client typename ServiceClientConfigurationT, typename ServiceAuthSchemeResolverT, typename AuthSchemesVariantT, - typename EndpointProviderT> + typename EndpointProviderT, + typename SerializerT, + typename ResponseT> class AwsSmithyClientT : public AwsSmithyClientBase { public: @@ -38,10 +40,11 @@ namespace client const std::shared_ptr& authSchemeResolver, const Aws::UnorderedMap& authSchemes) : AwsSmithyClientBase(Aws::MakeUnique(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller), - m_clientConfig(*AwsSmithyClientBase::m_clientConfig.get()), + m_clientConfiguration(*static_cast(AwsSmithyClientBase::m_clientConfig.get())), m_endpointProvider(endpointProvider), m_authSchemeResolver(authSchemeResolver), - m_authSchemes(authSchemes) + m_authSchemes(authSchemes), + m_serializer(Aws::MakeUnique(ServiceNameT, m_clientConfiguration.telemetryProvider)) { m_serviceName = ServiceNameT; } @@ -69,7 +72,7 @@ namespace client identityParams.serviceName = m_serviceName; identityParams.operation = ctx.m_requestName; - identityParams.region = m_clientConfig.region; + identityParams.region = m_clientConfiguration.region; if (ctx.m_pRequest) { // refactor once auth scheme resolver will use it's own rule set @@ -118,11 +121,21 @@ namespace client return AwsClientRequestSigning::AdjustClockSkew(outcome, authSchemeOption, m_authSchemes); } + ResponseT MakeRequestDeserialize(Aws::AmazonWebServiceRequest const * const request, + const char* requestName, + Aws::Http::HttpMethod method, + EndpointUpdateCallback&& endpointCallback) const + { + auto httpResponseOutcome = MakeRequestSync(request, requestName, method, std::move(endpointCallback)); + return m_serializer->Deserialize(std::move(httpResponseOutcome), GetServiceClientName(), requestName); + } + protected: - ServiceClientConfigurationT& m_clientConfig; + ServiceClientConfigurationT& m_clientConfiguration; std::shared_ptr m_endpointProvider{}; std::shared_ptr m_authSchemeResolver{}; Aws::UnorderedMap m_authSchemes{}; + Aws::UniquePtr 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 80e6012564d..85fc668d226 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h @@ -148,6 +148,8 @@ namespace client 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; diff --git a/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h b/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h index 8c3cb23af16..e8634773c98 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h @@ -114,7 +114,7 @@ namespace smithy return; } - auto identityResult = identityResolver->getIdentity(m_targetAuthSchemeOption.identityProperties, m_targetAuthSchemeOption.identityProperties); + auto identityResult = identityResolver->getIdentity(m_targetAuthSchemeOption.identityProperties(), m_targetAuthSchemeOption.identityProperties()); if (!identityResult.IsSuccess()) { @@ -133,7 +133,7 @@ namespace smithy return; } - result.emplace(signer->sign(m_httpRequest, *identity, m_targetAuthSchemeOption.signerProperties)); + result.emplace(signer->sign(m_httpRequest, *identity, m_targetAuthSchemeOption.signerProperties())); } }; diff --git a/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h new file mode 100644 index 00000000000..243a1726d62 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h @@ -0,0 +1,100 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include + +namespace smithy +{ + namespace client + { + using TracingUtils = components::tracing::TracingUtils; + using CoreErrors = Aws::Client::CoreErrors; + using AWSError = Aws::Client::AWSError; + using JsonValue = Aws::Utils::Json::JsonValue; + using HttpResponseOutcome = Aws::Utils::Outcome, AWSError>; + using JsonOutcome = Aws::Utils::Outcome, AWSError>; + using TelemetryProvider = components::tracing::TelemetryProvider; + + class JsonOutcomeSerializer + { + public: + explicit JsonOutcomeSerializer(const std::shared_ptr& telemetryProvider) + : m_telemetryProvider(telemetryProvider) + { + } + + JsonOutcomeSerializer(const JsonOutcomeSerializer& other) = delete; + JsonOutcomeSerializer(JsonOutcomeSerializer&& other) noexcept = default; + JsonOutcomeSerializer& operator=(const JsonOutcomeSerializer& other) = delete; + JsonOutcomeSerializer& operator=(JsonOutcomeSerializer&& other) noexcept = default; + virtual ~JsonOutcomeSerializer() = default; + + JsonOutcome Deserialize(HttpResponseOutcome&& httpOutcome, + const Aws::String& serviceName, + const Aws::String& requestName) const + { + if (!httpOutcome.IsSuccess()) + { + return TracingUtils::MakeCallWithTiming( + [&]() -> JsonOutcome { + return JsonOutcome{std::move(httpOutcome)}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + if (httpOutcome.GetResult()->GetResponseBody().good() && + httpOutcome.GetResult()->GetResponseBody().tellp() > 0) + { + JsonValue jsonValue(httpOutcome.GetResult()->GetResponseBody()); + if (!jsonValue.WasParseSuccessful()) { + return TracingUtils::MakeCallWithTiming( + [&]() -> JsonOutcome { + return JsonOutcome{AWSError(CoreErrors::UNKNOWN, + "Json Parser Error", + jsonValue.GetErrorMessage(), + false)}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + return TracingUtils::MakeCallWithTiming( + [&]() -> JsonOutcome { + return JsonOutcome{Aws::AmazonWebServiceResult(std::move(jsonValue), + httpOutcome.GetResult()->GetHeaders(), + httpOutcome.GetResult()->GetResponseCode())}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + return TracingUtils::MakeCallWithTiming( + [&]() -> JsonOutcome { + return JsonOutcome{Aws::AmazonWebServiceResult(JsonValue(), + httpOutcome.GetResult()->GetHeaders())}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + private: + std::shared_ptr m_telemetryProvider; + }; + } // namespace client +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h new file mode 100644 index 00000000000..61b05f8f9c7 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h @@ -0,0 +1,88 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include + +namespace smithy +{ + namespace client + { + using TracingUtils = components::tracing::TracingUtils; + using CoreErrors = Aws::Client::CoreErrors; + using AWSError = Aws::Client::AWSError; + using XmlDocument = Aws::Utils::Xml::XmlDocument; + using HttpResponseOutcome = Aws::Utils::Outcome, AWSError>; + using XmlServiceResult = Aws::AmazonWebServiceResult; + using XmlOutcome = Aws::Utils::Outcome; + using TelemetryProvider = components::tracing::TelemetryProvider; + + class XmlOutcomeSerializer + { + public: + explicit XmlOutcomeSerializer(const std::shared_ptr& telemetryProvider) + : m_telemetryProvider(telemetryProvider) + { + } + + XmlOutcomeSerializer(const XmlOutcomeSerializer& other) = delete; + XmlOutcomeSerializer(XmlOutcomeSerializer&& other) noexcept = default; + XmlOutcomeSerializer& operator=(const XmlOutcomeSerializer& other) = delete; + XmlOutcomeSerializer& operator=(XmlOutcomeSerializer&& other) noexcept = default; + virtual ~XmlOutcomeSerializer() = default; + + + XmlOutcome Deserialize(HttpResponseOutcome&& httpOutcome, + const Aws::String& serviceName, + const Aws::String& requestName) const + { + if (!httpOutcome.IsSuccess()) + { + return TracingUtils::MakeCallWithTiming( + [&]() -> XmlOutcome { + return {std::move(httpOutcome)}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + if (httpOutcome.GetResult()->GetResponseBody().good() && + httpOutcome.GetResult()->GetResponseBody().tellp() > 0) + { + return TracingUtils::MakeCallWithTiming( + [&]() -> XmlOutcome { + XmlDocument xmlDoc = XmlDocument::CreateFromXmlStream(httpOutcome.GetResult()->GetResponseBody()); + + if (!xmlDoc.WasParseSuccessful()) + { + AWS_LOGSTREAM_ERROR("XmlOutcomeSerializer", "Xml parsing for error failed with message " << xmlDoc.GetErrorMessage().c_str()); + return AWSError(CoreErrors::UNKNOWN, + "Xml Parse Error", + xmlDoc.GetErrorMessage(), + false); + } + + return {XmlServiceResult(std::move(xmlDoc), + httpOutcome.GetResult()->GetHeaders(), + httpOutcome.GetResult()->GetResponseCode())}; + }, + TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, + *m_telemetryProvider->getMeter(serviceName, {}), + {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); + } + + return {XmlServiceResult(XmlDocument(), httpOutcome.GetResult()->GetHeaders())}; + } + private: + std::shared_ptr m_telemetryProvider; + }; + + } // namespace client +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/AuthSchemeOption.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/AuthSchemeOption.h index d14f283277e..92672daad1c 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/AuthSchemeOption.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/AuthSchemeOption.h @@ -18,15 +18,13 @@ namespace smithy { using EndpointParameters = Aws::Vector; /* note: AuthSchemeOption is not connected with AuthScheme by type system, only by the String of schemeId, this is in accordance with SRA */ public: - AuthSchemeOption(const char* id = nullptr, PropertyBag identityProps = {{}}, PropertyBag signerProps = {{}}, EndpointParameters epParams = {{}}) - : schemeId(id), identityProperties(identityProps), signerProperties(signerProps), endpointParameters(epParams) - { - } + AuthSchemeOption(const char* id = nullptr): schemeId(id) {} + virtual ~AuthSchemeOption() = default; const char* schemeId = nullptr; - PropertyBag identityProperties{}; - PropertyBag signerProperties{}; - EndpointParameters endpointParameters{}; + PropertyBag virtual identityProperties() const { return {}; }; + PropertyBag virtual signerProperties() const { return {}; }; + EndpointParameters virtual endpointParameters() const { return {}; }; }; } \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthSchemeOption.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthSchemeOption.h index b85c7e489bf..f2810a31f34 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthSchemeOption.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthSchemeOption.h @@ -4,13 +4,12 @@ */ #pragma once +#include #include namespace smithy { struct SigV4AuthSchemeOption { - static AuthSchemeOption sigV4AuthSchemeOption; + static SMITHY_API AuthSchemeOption sigV4AuthSchemeOption; }; - - AuthSchemeOption SigV4AuthSchemeOption::sigV4AuthSchemeOption = AuthSchemeOption("aws.auth#sigv4"); } \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h index 7227acaee6b..84c206ac93c 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h @@ -4,13 +4,12 @@ */ #pragma once +#include #include namespace smithy { struct SigV4aAuthSchemeOption { - static AuthSchemeOption sigV4aAuthSchemeOption; + static SMITHY_API AuthSchemeOption sigV4aAuthSchemeOption; }; - - AuthSchemeOption SigV4aAuthSchemeOption::sigV4aAuthSchemeOption = AuthSchemeOption("aws.auth#sigv4a"); } \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/AwsCredentialsProviderIdentityResolver.h b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/AwsCredentialsProviderIdentityResolver.h new file mode 100644 index 00000000000..35ded383886 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/AwsCredentialsProviderIdentityResolver.h @@ -0,0 +1,48 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include + +#include +#include + +namespace smithy +{ + class AwsCredentialsProviderIdentityResolver : public AwsCredentialIdentityResolver + { + public: + using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters; + + explicit AwsCredentialsProviderIdentityResolver(const std::shared_ptr credentialsProvider) + : m_credentialsProvider(credentialsProvider) + { + } + + AwsCredentialsProviderIdentityResolver(const AwsCredentialsProviderIdentityResolver& other) = delete; + AwsCredentialsProviderIdentityResolver(AwsCredentialsProviderIdentityResolver&& other) noexcept = default; + AwsCredentialsProviderIdentityResolver& operator=(const AwsCredentialsProviderIdentityResolver& other) = delete; + AwsCredentialsProviderIdentityResolver& operator=(AwsCredentialsProviderIdentityResolver&& other) noexcept = default; + ~AwsCredentialsProviderIdentityResolver() override = default; + + ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, + const AdditionalParameters& additionalParameters) override + { + AWS_UNREFERENCED_PARAM(identityProperties); + AWS_UNREFERENCED_PARAM(additionalParameters); + + const auto fetchedCreds = m_credentialsProvider->GetAWSCredentials(); + + auto smithyCreds = Aws::MakeUnique("DefaultAwsCredentialIdentityResolver", + fetchedCreds.GetAWSAccessKeyId(), fetchedCreds.GetAWSSecretKey(), + fetchedCreds.GetSessionToken(), fetchedCreds.GetExpiration()); + + return {std::move(smithyCreds)}; + } + + protected: + std::shared_ptr m_credentialsProvider; + }; +} diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h index cd01179a947..0f5e5b3ef10 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h @@ -20,7 +20,6 @@ namespace smithy { mutable std::shared_ptr legacyChain_sp; - //mutable Aws::Auth::DefaultAWSCredentialsProviderChain legacyCredentialsProvider{}; public: using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters; @@ -28,6 +27,12 @@ namespace smithy { }; + DefaultAwsCredentialIdentityResolver(const DefaultAwsCredentialIdentityResolver& other) = delete; + DefaultAwsCredentialIdentityResolver(DefaultAwsCredentialIdentityResolver&& other) noexcept = default; + DefaultAwsCredentialIdentityResolver& operator=(const DefaultAwsCredentialIdentityResolver& other) = delete; + DefaultAwsCredentialIdentityResolver& operator=(DefaultAwsCredentialIdentityResolver&& other) noexcept = default; + virtual ~DefaultAwsCredentialIdentityResolver() = default; + DefaultAwsCredentialIdentityResolver(std::shared_ptr providerChain): legacyChain_sp{providerChain} { assert(legacyChain_sp); @@ -43,13 +48,10 @@ namespace smithy { auto smithyCreds = Aws::MakeUnique("DefaultAwsCredentialIdentityResolver", legacyCreds.GetAWSAccessKeyId(), legacyCreds.GetAWSSecretKey(), - legacyCreds.GetSessionToken().empty()? Aws::Crt::Optional() : legacyCreds.GetSessionToken(), + legacyCreds.GetSessionToken().empty()? Aws::Crt::Optional() : legacyCreds.GetSessionToken(), legacyCreds.GetExpiration()); return ResolveIdentityFutureOutcome(std::move(smithyCreds)); } - - virtual ~DefaultAwsCredentialIdentityResolver() {}; - }; } diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/SimpleAwsCredentialIdentityResolver.h b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/SimpleAwsCredentialIdentityResolver.h new file mode 100644 index 00000000000..89cb5077397 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/built-in/SimpleAwsCredentialIdentityResolver.h @@ -0,0 +1,46 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include + +#include +#include + +namespace smithy +{ + class SimpleAwsCredentialIdentityResolver : public AwsCredentialIdentityResolver + { + public: + using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters; + + explicit SimpleAwsCredentialIdentityResolver(const Aws::Auth::AWSCredentials& credentials) + : m_credentials(credentials) + { + } + + SimpleAwsCredentialIdentityResolver(const SimpleAwsCredentialIdentityResolver& other) = delete; + SimpleAwsCredentialIdentityResolver(SimpleAwsCredentialIdentityResolver&& other) noexcept = default; + SimpleAwsCredentialIdentityResolver& operator=(const SimpleAwsCredentialIdentityResolver& other) = delete; + SimpleAwsCredentialIdentityResolver& operator=(SimpleAwsCredentialIdentityResolver&& other) noexcept = default; + virtual ~SimpleAwsCredentialIdentityResolver() = default; + + ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, + const AdditionalParameters& additionalParameters) override + { + AWS_UNREFERENCED_PARAM(identityProperties); + AWS_UNREFERENCED_PARAM(additionalParameters); + + auto smithyCreds = Aws::MakeUnique("DefaultAwsCredentialIdentityResolver", + m_credentials.GetAWSAccessKeyId(), m_credentials.GetAWSSecretKey(), + m_credentials.GetSessionToken(), m_credentials.GetExpiration()); + + return {std::move(smithyCreds)}; + } + + protected: + Aws::Auth::AWSCredentials m_credentials; + }; +} 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 6ad02cd9b30..c361d9b8a2b 100644 --- a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp +++ b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp @@ -143,7 +143,8 @@ void AwsSmithyClientBase::MakeRequestAsync(Aws::AmazonWebServiceRequest const* c pRequestCtx->m_authSchemeOption = std::move(authSchemeOptionOutcome.GetResultWithOwnership()); assert(pRequestCtx->m_authSchemeOption.schemeId); Aws::Endpoint::EndpointParameters epParams = request ? request->GetEndpointContextParams() : Aws::Endpoint::EndpointParameters(); - epParams.insert(epParams.end(), pRequestCtx->m_authSchemeOption.endpointParameters.begin(), pRequestCtx->m_authSchemeOption.endpointParameters.end()); + const auto authSchemeEpParams = pRequestCtx->m_authSchemeOption.endpointParameters(); + epParams.insert(epParams.end(), authSchemeEpParams.begin(), authSchemeEpParams.end()); auto epResolutionOutcome = this->ResolveEndpoint(std::move(epParams), std::move(endpointCallback)); if (!epResolutionOutcome.IsSuccess()) { @@ -478,4 +479,9 @@ AwsSmithyClientBase::MakeRequestSync(Aws::AmazonWebServiceRequest const * const pExecutor->WaitUntilStopped(); return outcome; -} \ No newline at end of file +} + +void AwsSmithyClientBase::DisableRequestProcessing() +{ + m_httpClient->DisableRequestProcessing(); +} diff --git a/src/aws-cpp-sdk-core/source/smithy/identity/AuthSchemeOption.cpp b/src/aws-cpp-sdk-core/source/smithy/identity/AuthSchemeOption.cpp new file mode 100644 index 00000000000..354f61254ca --- /dev/null +++ b/src/aws-cpp-sdk-core/source/smithy/identity/AuthSchemeOption.cpp @@ -0,0 +1,11 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include + +using namespace smithy; + +AuthSchemeOption SigV4AuthSchemeOption::sigV4AuthSchemeOption = AuthSchemeOption("aws.auth#sigv4"); +AuthSchemeOption SigV4aAuthSchemeOption::sigV4aAuthSchemeOption = AuthSchemeOption("aws.auth#sigv4a"); \ No newline at end of file diff --git a/tests/aws-cpp-sdk-core-tests/CMakeLists.txt b/tests/aws-cpp-sdk-core-tests/CMakeLists.txt index 2bf24d151d4..39a7c87ac08 100644 --- a/tests/aws-cpp-sdk-core-tests/CMakeLists.txt +++ b/tests/aws-cpp-sdk-core-tests/CMakeLists.txt @@ -25,6 +25,7 @@ file(GLOB UTILS_COMPONENT_REGISTRY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/compon file(GLOB MONITORING_SRC "${CMAKE_CURRENT_SOURCE_DIR}/monitoring/*.cpp") file(GLOB SMITHY_TRACING_SRC "${CMAKE_CURRENT_SOURCE_DIR}/smithy/tracing/*.cpp") file(GLOB SMITHY_CLIENT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/smithy/client/*.cpp") +file(GLOB SMITHY_CLIENT_SERIALIZER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/smithy/client/serializer/*.cpp") file(GLOB ENDPOINT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/endpoint/*.cpp") @@ -51,6 +52,7 @@ file(GLOB AWS_CPP_SDK_CORE_TESTS_SRC ${UTILS_RATE_LIMITER_SRC} ${SMITHY_TRACING_SRC} ${SMITHY_CLIENT_SRC} + ${SMITHY_CLIENT_SERIALIZER_SRC} ${ENDPOINT_SRC} ) @@ -76,6 +78,7 @@ if(PLATFORM_WINDOWS) source_group("Source Files\\utils\\threading" FILES ${UTILS_THREADING_SRC}) source_group("Source Files\\smithy\\tracing" FILES ${SMITHY_TRACING_SRC}) source_group("Source Files\\smithy\\client" FILES ${SMITHY_CLIENT_SRC}) + source_group("Source Files\\smithy\\client" FILES ${SMITHY_CLIENT_SERIALIZER_SRC}) endif() endif() 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 24a6a0e61eb..daf888c8c3e 100644 --- a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp @@ -54,6 +54,37 @@ class TestCredentialsProviderChain: public Aws::Auth::AWSCredentialsProviderChai } }; +class MockDeserializer +{ +public: + MockDeserializer(std::shared_ptr noop) { + AWS_UNREFERENCED_PARAM(noop); + } + + Aws::String Deserialize(Aws::Client::HttpResponseOutcome&& httpOutcome, + const Aws::String& serviceName, + const Aws::String& requestName) + { + AWS_UNREFERENCED_PARAM(httpOutcome); + AWS_UNREFERENCED_PARAM(serviceName); + AWS_UNREFERENCED_PARAM(requestName); + if (m_responseQueue.empty()) + { + return {}; + } + const auto response = m_responseQueue.front(); + m_responseQueue.pop(); + return response; + } + + void PushResponse(Aws::String&& response) + { + m_responseQueue.emplace(std::move(response)); + } + +private: + std::queue m_responseQueue{}; +}; class SmithyClientTest : public Aws::Testing::AwsCppSdkGTestSuite { @@ -110,6 +141,8 @@ class TestAwsBearerTokenIdentityResolver //=============================================================== const char SmithyClientTest::ALLOCATION_TAG[] = "SmithyClientTest"; + + using MySmithyClientConfig = Aws::Client::ClientConfiguration; using MyServiceAuthSchemeResolver = smithy::AuthSchemeResolverBase; //smithy::SigV4AuthSchemeResolver<>; static constexpr char MyServiceName[] = "MySuperService"; @@ -120,8 +153,9 @@ using MySmithyClient = smithy::client::AwsSmithyClientT; - + TestEndPointProvider, + MockDeserializer, + Aws::String>; class TestClient : public MySmithyClient { @@ -183,8 +217,7 @@ TEST_F(SmithyClientTest, testSigV4) { errorMarshaller, endPointProvider, authSchemeResolver, - authSchemesMap - ); + authSchemesMap); smithy::client::AwsSmithyClientAsyncRequestContext ctx; ctx.m_pRequest = nullptr; @@ -236,8 +269,7 @@ TEST_F(SmithyClientTest, testSigV4a) { errorMarshaller, endPointProvider, authSchemeResolver, - authSchemesMap - ); + authSchemesMap); smithy::client::AwsSmithyClientAsyncRequestContext ctx; ctx.m_pRequest = nullptr; diff --git a/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/JsonOutcomeSerializerTest.cpp b/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/JsonOutcomeSerializerTest.cpp new file mode 100644 index 00000000000..dfc76f3f5a3 --- /dev/null +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/JsonOutcomeSerializerTest.cpp @@ -0,0 +1,102 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include +#include +#include +#include + +using namespace smithy::client; +using namespace smithy::components::tracing; +using namespace Aws::Http; + +class SmithyClientJsonOutcomeSerializerTest : public Aws::Testing::AwsCppSdkGTestSuite +{ +protected: + const char* ALLOCATION_TAG = "JsonOutcomesSerializerTest"; + const char* SERVICE_NAME = "ShinraEmployeeLookupService"; + const char* REQUEST_NAME = "FindEmployee"; + const char* TEST_URI = "http://www.quartersnacks.com"; + JsonOutcomeSerializer m_serializer{NoopTelemetryProvider::CreateProvider()}; +}; + +TEST_F(SmithyClientJsonOutcomeSerializerTest, TestSerializationWorks) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->GetResponseBody() << R"({"city": "midgar", "first_name": "cloud", "last_name": "strife" })"; + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_TRUE(value.IsSuccess()); + const auto& result = value.GetResult(); + EXPECT_EQ(HttpResponseCode::OK, result.GetResponseCode()); + EXPECT_TRUE(result.GetPayload().WasParseSuccessful()); + EXPECT_EQ("midgar", result.GetPayload().View().GetString("city")); + EXPECT_EQ("cloud", result.GetPayload().View().GetString("first_name")); + EXPECT_EQ("strife", result.GetPayload().View().GetString("last_name")); +} + +TEST_F(SmithyClientJsonOutcomeSerializerTest, TestEmptyBodySerializationWorks) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->AddHeader("content-type", "application/mako"); + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_TRUE(value.IsSuccess()); + const auto& result = value.GetResult(); + EXPECT_EQ(HttpResponseCode::OK, result.GetResponseCode()); + EXPECT_EQ("application/mako", value.GetResult().GetHeaderValueCollection().at("content-type")); +} + +TEST_F(SmithyClientJsonOutcomeSerializerTest, CoreErrorShouldSkipSeriliaze) +{ + const auto awsError = AWSError{CoreErrors::RESOURCE_NOT_FOUND, + "NoSuchEmployeeException", + "No such employee Barrett", + false}; + HttpResponseOutcome outcome{awsError}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_FALSE(value.IsSuccess()); + EXPECT_EQ(CoreErrors::RESOURCE_NOT_FOUND, value.GetError().GetErrorType()); + EXPECT_EQ("NoSuchEmployeeException", value.GetError().GetExceptionName()); + EXPECT_EQ("No such employee Barrett", value.GetError().GetMessage()); +} + +TEST_F(SmithyClientJsonOutcomeSerializerTest, CoreErrorGracefullyFailBadJson) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->GetResponseBody() << R"(what really happened in Nibelheim)"; + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_FALSE(value.IsSuccess()); + EXPECT_EQ("Json Parser Error", value.GetError().GetExceptionName()); + EXPECT_EQ("Failed to parse JSON. Invalid input at: what really happened in Nibelheim", value.GetError().GetMessage()); +} diff --git a/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/XmlOutcomeSerializerTest.cpp b/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/XmlOutcomeSerializerTest.cpp new file mode 100644 index 00000000000..aebe61256fb --- /dev/null +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/serializer/XmlOutcomeSerializerTest.cpp @@ -0,0 +1,112 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include +#include +#include +#include + +using namespace smithy::client; +using namespace smithy::components::tracing; +using namespace Aws::Http; + +class SmithyClientXMLOutcomeSerializerTest : public Aws::Testing::AwsCppSdkGTestSuite +{ +protected: + const char* ALLOCATION_TAG = "JsonOutcomesSerializerTest"; + const char* SERVICE_NAME = "ShinraEmployeeLookupService"; + const char* REQUEST_NAME = "FindEmployee"; + const char* TEST_URI = "http://www.quartersnacks.com"; + XmlOutcomeSerializer m_serializer{NoopTelemetryProvider::CreateProvider()}; +}; + +TEST_F(SmithyClientXMLOutcomeSerializerTest, TestSerializationWorks) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->GetResponseBody() << R"(midgarcloudstrife)"; + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_TRUE(value.IsSuccess()); + const auto& result = value.GetResult(); + EXPECT_EQ(HttpResponseCode::OK, result.GetResponseCode()); + EXPECT_TRUE(result.GetPayload().WasParseSuccessful()); + Aws::Map foundResponses; + EXPECT_TRUE(result.GetPayload().GetRootElement().HasChildren()); + auto node = result.GetPayload().GetRootElement().FirstChild(); + while (node.HasNextNode()) + { + foundResponses[node.GetName()] = node.GetText(); + node = node.NextNode(); + } + foundResponses[node.GetName()] = node.GetText(); + EXPECT_EQ(3ul, foundResponses.size()); + EXPECT_EQ("midgar", foundResponses.at("city")); + EXPECT_EQ("cloud", foundResponses.at("first_name")); + EXPECT_EQ("strife", foundResponses.at("last_name")); +} + +TEST_F(SmithyClientXMLOutcomeSerializerTest, TestEmptyBodySerializationWorks) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->AddHeader("content-type", "application/mako"); + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_TRUE(value.IsSuccess()); + const auto& result = value.GetResult(); + EXPECT_EQ(HttpResponseCode::OK, result.GetResponseCode()); + EXPECT_EQ("application/mako", value.GetResult().GetHeaderValueCollection().at("content-type")); +} + +TEST_F(SmithyClientXMLOutcomeSerializerTest, CoreErrorShouldSkipSeriliaze) +{ + const auto awsError = AWSError{CoreErrors::RESOURCE_NOT_FOUND, + "NoSuchEmployeeException", + "No such employee Barrett", + false}; + HttpResponseOutcome outcome{awsError}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_FALSE(value.IsSuccess()); + EXPECT_EQ(CoreErrors::RESOURCE_NOT_FOUND, value.GetError().GetErrorType()); + EXPECT_EQ("NoSuchEmployeeException", value.GetError().GetExceptionName()); + EXPECT_EQ("No such employee Barrett", value.GetError().GetMessage()); +} + +TEST_F(SmithyClientXMLOutcomeSerializerTest, CoreErrorGracefullyFailBadJson) +{ + const auto request = Aws::MakeShared(ALLOCATION_TAG, + TEST_URI, + HttpMethod::HTTP_POST); + request->SetResponseStreamFactory([this]() -> Aws::IOStream* { return Aws::New(ALLOCATION_TAG); }); + auto response = Aws::MakeShared(ALLOCATION_TAG, request); + response->SetResponseCode(HttpResponseCode::OK); + response->GetResponseBody() << R"(what really happened in Nibelheim)"; + HttpResponseOutcome outcome{response}; + const auto value = m_serializer.Deserialize(std::move(outcome), + SERVICE_NAME, + REQUEST_NAME); + + EXPECT_FALSE(value.IsSuccess()); + EXPECT_EQ("Xml Parse Error", value.GetError().GetExceptionName()); + EXPECT_EQ("XML_ERROR_PARSING_TEXT", value.GetError().GetMessage()); +} diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jMetadata.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jMetadata.java index cf2a23616a6..451fa54027d 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jMetadata.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jMetadata.java @@ -7,6 +7,8 @@ import lombok.Data; +import java.util.List; + @Data public class C2jMetadata { private String apiVersion; @@ -25,4 +27,5 @@ public class C2jMetadata { private String timestampFormat; private String serviceId; private C2jAwsQueryCompatible awsQueryCompatible; + private List auth; } \ No newline at end of file diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java index 876f1e11bdd..5c6bbf216df 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java @@ -83,4 +83,6 @@ public Operation getOperationForRequestShapeName(String requestShapeName) { EndpointRuleSetModel endpointRuleSetModel; EndpointTests endpointTests; ClientContextParams clientContextParams; + boolean useSmithyClient; + List authSchemes; } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java index d055eb66092..3a033484c94 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java @@ -34,7 +34,7 @@ public DirectFromC2jGenerator(final MainGenerator mainClientGenerator) { public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, String endpointRuleSet, String endpointRulesTests, String languageBinding, String serviceName, String namespace, String licenseText, boolean generateStandalonePackage, - boolean enableVirtualOperations) throws Exception { + boolean enableVirtualOperations, boolean useSmithyClient) throws Exception { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(EndpointTests.EndpointTestParams.class, new EndpointTestParamsDeserializer()); gsonBuilder.registerTypeAdapter(EndpointParameterValue.class, new EndpointParameterValueDeserializer()); @@ -50,7 +50,7 @@ public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, Strin c2jServiceModel.setEndpointTests(endpointTestsModel); } return mainClientGenerator.generateSourceFromC2jModel(c2jServiceModel, serviceName, languageBinding, namespace, - licenseText, generateStandalonePackage, enableVirtualOperations); + licenseText, generateStandalonePackage, enableVirtualOperations, useSmithyClient); } /** diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/MainGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/MainGenerator.java index 7e92aa0cc29..a309b86bc38 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/MainGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/MainGenerator.java @@ -31,7 +31,7 @@ public class MainGenerator { public ByteArrayOutputStream generateSourceFromC2jModel(C2jServiceModel c2jModel, String serviceName, String languageBinding, String namespace, String licenseText, boolean generateStandalonePackage, - boolean enableVirtualOperations) throws Exception { + boolean enableVirtualOperations, boolean useSmithyClient) throws Exception { SdkSpec spec = new SdkSpec(languageBinding, serviceName, null); // Transform to ServiceModel @@ -43,6 +43,7 @@ public ByteArrayOutputStream generateSourceFromC2jModel(C2jServiceModel c2jModel serviceModel.setNamespace(namespace); serviceModel.setLicenseText(licenseText); serviceModel.setEnableVirtualOperations(enableVirtualOperations); + serviceModel.setUseSmithyClient(useSmithyClient); spec.setVersion(serviceModel.getMetadata().getApiVersion()); diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java index a9c52d9ca41..7ab3845ae22 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java @@ -666,6 +666,68 @@ protected Set getOperationsToRemove(){ return new HashSet(); } + protected SdkFileEntry generateClientSmithyHeaderFile(final ServiceModel serviceModel) { + Template template = velocityEngine.getTemplate("com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm", StandardCharsets.UTF_8.name()); + + VelocityContext context = createContext(serviceModel); + context.put("CppViewHelper", CppViewHelper.class); + context.put("RequestlessOperations", requestlessOperations); + context.put("AuthSchemeResolver", "SigV4AuthSchemeResolver"); + context.put("AuthSchemeVariants", serviceModel.getAuthSchemes().stream().map(this::mapAuthSchemes).collect(Collectors.joining(","))); + + String fileName = String.format("include/aws/%s/%sClient.h", serviceModel.getMetadata().getProjectName(), + serviceModel.getMetadata().getClassNamePrefix()); + + return makeFile(template, context, fileName, true); + } + + protected List generateSmithyClientSourceFile(final List serviceModels) { + List sourceFiles = new ArrayList<>(); + for (int i = 0; i < serviceModels.size(); i++) { + Template template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSource.vm", StandardCharsets.UTF_8.name()); + + VelocityContext context = createContext(serviceModels.get(i)); + context.put("CppViewHelper", CppViewHelper.class); + context.put("AuthSchemeResolver", "SigV4AuthSchemeResolver"); + context.put("AuthSchemeMapEntries", createAuthSchemeMapEntries(serviceModels.get(i))); + + final String fileName; + if (i == 0) { + context.put("onlyGeneratedOperations", false); + fileName = String.format("source/%sClient.cpp", serviceModels.get(i).getMetadata().getClassNamePrefix()); + } else { + context.put("onlyGeneratedOperations", true); + fileName = String.format("source/%sClient%d.cpp", serviceModels.get(i).getMetadata().getClassNamePrefix(), i); + } + sourceFiles.add(makeFile(template, context, fileName, true)); + } + return sourceFiles; + } + + private static final Map AuthSchemeMapping = ImmutableMap.of( + "aws.auth#sigv4", "smithy::SigV4AuthScheme", + "aws.auth#sigv4a", "smithy::SigV4aAuthScheme" + ); + + protected String mapAuthSchemes(final String authSchemeName) { + if (AuthSchemeMapping.containsKey(authSchemeName)) { + return AuthSchemeMapping.get(authSchemeName); + } + throw new RuntimeException(String.format("Unsupported authScheme '%s'", authSchemeName)); + } + + + private static final Map SchemeIdMapping = ImmutableMap.of( + "aws.auth#sigv4", "smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption", + "aws.auth#sigv4a", "smithy::SigV4AuthSchemeOption::sigV4aAuthSchemeOption" + ); + private static final String SchemeMapFormat = "%s.schemeId, %s"; + private List createAuthSchemeMapEntries(final ServiceModel serviceModel) { + return serviceModel.getAuthSchemes().stream() + .map(authScheme -> String.format(SchemeMapFormat, SchemeIdMapping.get(authScheme), AuthSchemeMapping.get(authScheme))) + .collect(Collectors.toList()); + } + private void addRequestlessRequestObjectS(final ServiceModel serviceModel) { serviceModel.getOperations().values().stream() .filter(operation -> !operation.hasRequest() || operation.getRequest().getShape().getMembers().values().stream().noneMatch(ShapeMember::isRequired)) diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/dynamodb/DynamoDBJsonCppClientGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/dynamodb/DynamoDBJsonCppClientGenerator.java index 896c926c394..dcb03778a74 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/dynamodb/DynamoDBJsonCppClientGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/dynamodb/DynamoDBJsonCppClientGenerator.java @@ -8,14 +8,19 @@ import com.amazonaws.util.awsclientgenerator.domainmodels.SdkFileEntry; import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.ServiceModel; import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.Shape; +import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.cpp.CppViewHelper; import com.amazonaws.util.awsclientgenerator.generators.cpp.JsonCppClientGenerator; import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class DynamoDBJsonCppClientGenerator extends JsonCppClientGenerator { @@ -35,6 +40,25 @@ public SdkFileEntry[] generateSourceFiles(ServiceModel serviceModel) throws Exce return super.generateSourceFiles(serviceModel); } + @Override + protected SdkFileEntry generateClientHeaderFile(ServiceModel serviceModel) throws Exception { + if (!serviceModel.isUseSmithyClient()) { + return super.generateClientHeaderFile(serviceModel); + } + return super.generateClientSmithyHeaderFile(serviceModel); + } + + @Override + protected List generateClientSourceFile(List serviceModels) throws Exception { + final List awsClients = super.generateClientSourceFile(serviceModels.stream() + .filter(serviceModel -> !serviceModel.isUseSmithyClient()) + .collect(Collectors.toList())); + final List smithyClients = generateSmithyClientSourceFile(serviceModels.stream() + .filter(ServiceModel::isUseSmithyClient) + .collect(Collectors.toList())); + return Stream.concat(awsClients.stream(), smithyClients.stream()).collect(Collectors.toList()); + } + @Override protected SdkFileEntry generateModelHeaderFile(ServiceModel serviceModel, Map.Entry shapeEntry) throws Exception { switch(shapeEntry.getKey()) { diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/main.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/main.java index f56ed17ea8c..b369fb8dd9e 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/main.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/main.java @@ -41,6 +41,7 @@ public class main { static final String LICENSE_TEXT = "license-text"; static final String STANDALONE_OPTION = "standalone"; static final String ENABLE_VIRTUAL_OPERATIONS = "enable-virtual-operations"; + static final String USE_SMITHY_CLIENT = "use-smithy-client"; public static void main(String[] args) throws IOException { @@ -100,6 +101,8 @@ public static void main(String[] args) throws IOException { outputFileName = argPairs.get(OUTPUT_FILE_NAME); } + boolean useSmithyClient = argPairs.containsKey(USE_SMITHY_CLIENT); + if (arbitraryJson != null && arbitraryJson.length() > 0) { try { ByteArrayOutputStream generated; @@ -108,7 +111,7 @@ public static void main(String[] args) throws IOException { if (serviceName != null && !serviceName.isEmpty()) { if (!generateTests) { generated = generateService(arbitraryJson, endpointRules, endpointRuleTests, languageBinding, serviceName, namespace, - licenseText, generateStandalonePackage, enableVirtualOperations); + licenseText, generateStandalonePackage, enableVirtualOperations, useSmithyClient); componentOutputName = String.format("aws-cpp-sdk-%s", serviceName); } else { @@ -179,7 +182,8 @@ private static ByteArrayOutputStream generateService(String arbitraryJson, String namespace, String licenseText, boolean generateStandalonePackage, - boolean enableVirtualOperations) throws Exception { + boolean enableVirtualOperations, + boolean useSmithyClient) throws Exception { MainGenerator generator = new MainGenerator(); DirectFromC2jGenerator directFromC2jGenerator = new DirectFromC2jGenerator(generator); @@ -192,7 +196,8 @@ private static ByteArrayOutputStream generateService(String arbitraryJson, namespace, licenseText, generateStandalonePackage, - enableVirtualOperations); + enableVirtualOperations, + useSmithyClient); return outputStream; } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java index dac0a0f42c8..d4dfa30db55 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java @@ -152,6 +152,7 @@ public ServiceModel convert() { serviceModel.setVersion(c2jServiceModel.getVersion()); serviceModel.setDocumentation(formatDocumentation(c2jServiceModel.getDocumentation(), 3)); serviceModel.setServiceName(c2jServiceModel.getServiceName()); + serviceModel.setAuthSchemes(c2jServiceModel.getMetadata().getAuth()); convertShapes(); convertOperations(); 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 new file mode 100644 index 00000000000..08d5777f1ad --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientHeader.vm @@ -0,0 +1,73 @@ +#parse("com/amazonaws/util/awsclientgenerator/velocity/cfamily/Attribution.vm") + +#set($metadata = $serviceModel.metadata) +#set($rootNamespace = $serviceModel.namespace) +#set($serviceNamespace = $metadata.namespace) +#set($className = "${metadata.classNamePrefix}Client") +#if($serviceModel.metadata.protocol == "json" || $serviceModel.metadata.protocol == "rest-json" || $serviceModel.metadata.protocol == "application-json") +#set($serializer = "JsonOutcomeSerializer") +#set($serializerOutcome = "JsonOutcome") +#elseif($serviceModel.metadata.protocol == "rest-xml" || $serviceModel.metadata.protocol == "query") +#set($serializer = "XmlOutcomeSerializer") +#set($serializerOutcome = "XmlOutcome") +#end +#set($serviceConfiguration = "Aws::" + ${serviceNamespace} + "::" + ${metadata.classNamePrefix} + "ClientConfiguration") +#pragma once +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include + +namespace ${rootNamespace} +{ +namespace ${serviceNamespace} +{ + ${CppViewHelper.computeExportValue($metadata.classNamePrefix)} extern const char SERVICE_NAME[]; +#if($serviceModel.documentation) + /** + * ${serviceModel.documentation} + */ +#end +#set($finalClass = " final") +#if($serviceModel.enableVirtualOperations) +#set($finalClass = "") +#end + class ${CppViewHelper.computeExportValue($metadata.classNamePrefix)} ${className}${finalClass} : smithy::client::AwsSmithyClientT<${rootNamespace}::${serviceNamespace}::SERVICE_NAME, + ${serviceConfiguration}, + smithy::${AuthSchemeResolver}<>, + ${rootNamespace}::Crt::Variant<${AuthSchemeVariants}>, + ${metadata.classNamePrefix}EndpointProviderBase, + smithy::client::$serializer, + smithy::client::$serializerOutcome>, + Aws::Client::ClientWithAsyncTemplateMethods<${className}> + { + public: + static const char* GetServiceName(); + static const char* GetAllocationTag(); + +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderConfigTypeDeclarations.vm") +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderConstructors.vm") +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderOperations.vm") + + void OverrideEndpoint(const ${rootNamespace}::String& endpoint); + 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, + const ${rootNamespace}::String& operationName, + const ${rootNamespace}::String& endpointKey, + const ${rootNamespace}::${serviceNamespace}::Model::${metadata.endpointOperationName}Request& endpointRequest, + bool enforceDiscovery) const; + mutable Aws::Utils::ConcurrentCache<${rootNamespace}::String, ${rootNamespace}::String> m_endpointsCache; +#end + }; + +} // namespace ${serviceNamespace} +} // namespace ${rootNamespace} diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSource.vm new file mode 100644 index 00000000000..35121c390ef --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSource.vm @@ -0,0 +1,54 @@ +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/common/MacroParseOverrideOrDefault.vm") +#parse("com/amazonaws/util/awsclientgenerator/velocity/cfamily/Attribution.vm") + +#set($metadata = $serviceModel.metadata) +#set($rootNamespace = $serviceModel.namespace) +#set($serviceNamespace = $metadata.namespace) +#set($className = "${metadata.classNamePrefix}Client") +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include + +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm") +\#include +\#include +\#include + +using namespace Aws; +using namespace Aws::Auth; +using namespace Aws::Client; +using namespace ${rootNamespace}::${serviceNamespace}; +using namespace ${rootNamespace}::${serviceNamespace}::Model; +using namespace Aws::Http; +using namespace Aws::Utils::Json; +using namespace smithy::components::tracing; +using ResolveEndpointOutcome = Aws::Endpoint::ResolveEndpointOutcome; + +#if(!${onlyGeneratedOperations}) +namespace Aws +{ + namespace ${metadata.namespace} + { + const char ALLOCATION_TAG[] = "${className}"; + const char SERVICE_NAME[] = "${metadata.signingName}"; + } +} +const char* ${className}::GetServiceName() {return SERVICE_NAME;} +const char* ${className}::GetAllocationTag() {return ALLOCATION_TAG;} + +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm") +#end + +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyServiceOperationsSource.vm") + +#if($metadata.hasEndpointDiscoveryTrait) +#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointDiscoveryDefinition.vm") +#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 new file mode 100644 index 00000000000..35fc81ecdc4 --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm @@ -0,0 +1,138 @@ +#set($clientConfiguration = ${serviceNamespace} + "::" + ${metadata.classNamePrefix} + "ClientConfiguration") +${className}::${className}(const ${clientConfiguration}& clientConfiguration, + std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {${entry}{GetServiceName(), clientConfiguration.region}}, +#end + }) +{ + init(m_clientConfiguration); +} + +${className}::${className}(const AWSCredentials& credentials, + std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider, + const ${clientConfiguration}& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {${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, + const ${clientConfiguration}& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + endpointProvider ? endpointProvider : Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {${entry}{ Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} +#end + }) +{ + init(m_clientConfiguration); +} + +/* Legacy constructors due deprecation */ +${className}::${className}(const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {$entry{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}} +#end + }) +{ + init(m_clientConfiguration); +} + +${className}::${className}(const AWSCredentials& credentials, + const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {$entry{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}} +#end + }) +{ + init(m_clientConfiguration); +} + +${className}::${className}(const std::shared_ptr& credentialsProvider, + const Client::ClientConfiguration& clientConfiguration) : + AwsSmithyClientT(clientConfiguration, + GetServiceName(), + Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG), + Aws::MakeShared<${metadata.classNamePrefix}EndpointProvider>(ALLOCATION_TAG), + Aws::MakeShared>(ALLOCATION_TAG), + { +#foreach($entry in $AuthSchemeMapEntries) + {$entry{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}} +#end + }) +{ + init(m_clientConfiguration); +} +/* End of legacy constructors due deprecation */ + +${className}::~${className}() +{ + ShutdownSdkClient(this, -1); +} + +std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase>& ${className}::accessEndpointProvider() +{ + 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); +} diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointClosure.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointClosure.vm new file mode 100644 index 00000000000..25bf51df18b --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointClosure.vm @@ -0,0 +1,34 @@ +#if($metadata.hasEndpointDiscoveryTrait) +#set($indent = " ") +#if($operation.hasEndpointDiscoveryTrait) +#set($hasId=false) +#foreach($memberEntry in $operation.request.shape.members.entrySet()) +#if($memberEntry.value.endpointDiscoveryId) +#set($hasId=true) +#break +#end +#end +#if($hasId) +${indent}Aws::String endpointKey{"${operation.name}."}; +#foreach($memberEntry in $operation.request.shape.members.entrySet()) +#if($memberEntry.value.endpointDiscoveryId) +${indent}endpointKey += "${memberEntry.key}:" + request.Get${memberEntry.key}() + "."; +#end +#end +#else +${indent}Aws::String endpointKey{"Shared"}; +#end +${indent}${metadata.endpointOperationName}Request endpointRequest{}; +#if($hasId) +${indent} endpointRequest.WithOperation("${operation.name}"); +#end +#foreach($memberEntry in $operation.request.shape.members.entrySet()) +#if($memberEntry.value.endpointDiscoveryId) +${indent}endpointRequest.AddIdentifiers("${memberEntry.key}", request.Get${memberEntry.key}()); +#end +#end +${indent}this->OptionallyUpdateDescribeEndpointsCache(resolvedEndpoint, request.GetServiceRequestName(), endpointKey, endpointRequest, $operation.requireEndpointDiscovery); +#else +${indent}AWS_UNREFERENCED_PARAM(resolvedEndpoint); +#end +#end \ No newline at end of file diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointDiscoveryDefinition.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointDiscoveryDefinition.vm new file mode 100644 index 00000000000..469fc155de5 --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointDiscoveryDefinition.vm @@ -0,0 +1,43 @@ +#set($indent = " ") +void ${className}::OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint, + const Aws::String& operationName, + const Aws::String& endpointKey, + const ${rootNamespace}::${serviceNamespace}::Model::${metadata.endpointOperationName}Request& endpointRequest, + bool enforceDiscovery) const +{ +${indent}const bool enableEndpointDiscovery = m_clientConfiguration.enableEndpointDiscovery && m_clientConfiguration.enableEndpointDiscovery.value() && m_clientConfiguration.endpointOverride.empty(); +${indent}if (enableEndpointDiscovery) +${indent}{ +${indent} Aws::String endpoint; +${indent} if (m_endpointsCache.Get(endpointKey, endpoint)) +${indent} { +${indent} AWS_LOGSTREAM_TRACE(operationName.c_str(), "Making request to cached endpoint: " << endpoint); +${indent} endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + endpoint; +${indent} resolvedEndpoint.SetURI(endpoint); +${indent} } +${indent} else +${indent} { +${indent} AWS_LOGSTREAM_TRACE(operationName.c_str(), "Endpoint discovery is enabled and there is no usable endpoint in cache. Discovering endpoints from service..."); +${indent} auto endpointOutcome = ${metadata.endpointOperationName}(endpointRequest); +${indent} if (endpointOutcome.IsSuccess() && !endpointOutcome.GetResult().GetEndpoints().empty()) +${indent} { +${indent} const auto& item = endpointOutcome.GetResult().GetEndpoints()[0]; +${indent} m_endpointsCache.Put(endpointKey, item.GetAddress(), std::chrono::minutes(item.GetCachePeriodInMinutes())); +${indent} endpoint = Aws::String(SchemeMapper::ToString(m_clientConfiguration.scheme)) + "://" + item.GetAddress(); +${indent} AWS_LOGSTREAM_TRACE(operationName.c_str(), "Endpoints cache updated. Address: " << item.GetAddress() << ". Valid in: " << item.GetCachePeriodInMinutes() << " minutes. Making request to newly discovered endpoint."); +${indent} resolvedEndpoint.SetURI(endpoint); +${indent} } +${indent} else +${indent} { +${indent} if(enforceDiscovery) +${indent} { +${indent} AWS_LOGSTREAM_ERROR(operationName.c_str(), "Failed to discover endpoints " << endpointOutcome.GetError()); +${indent} } +${indent} else +${indent} { +${indent} AWS_LOGSTREAM_ERROR(operationName.c_str(), "Failed to discover endpoints " << endpointOutcome.GetError() << "\n Endpoint discovery is not required for this operation, falling back to the regional endpoint."); +${indent} } +${indent} } +${indent} } +${indent}} +} diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyServiceOperationsSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyServiceOperationsSource.vm new file mode 100644 index 00000000000..eb57244ddd4 --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyServiceOperationsSource.vm @@ -0,0 +1,24 @@ +#foreach($operation in $serviceModel.operations) +${operation.name}Outcome ${className}::${operation.name}(const ${operation.request.shape.name}& request) const +{ + AWS_OPERATION_GUARD(${operation.name}); + AWS_OPERATION_CHECK_PTR(m_endpointProvider, ${operation.name}, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); + AWS_OPERATION_CHECK_PTR(m_clientConfiguration.telemetryProvider, ${operation.name}, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto tracer = m_clientConfiguration.telemetryProvider->getTracer(this->GetServiceClientName(), {}); + auto meter = m_clientConfiguration.telemetryProvider->getMeter(this->GetServiceClientName(), {}); + AWS_OPERATION_CHECK_PTR(meter, ${operation.name}, CoreErrors, CoreErrors::NOT_INITIALIZED); + auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".${operation.name}", + {{ TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName() }, { TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName() }, { TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE }}, + smithy::components::tracing::SpanKind::CLIENT); + return TracingUtils::MakeCallWithTiming<${operation.name}Outcome>( + [&]()-> ${operation.name}Outcome { + return ${operation.name}Outcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_${operation.http.method}, [&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void { +#parse("/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointClosure.vm") + })); + }, + TracingUtils::SMITHY_CLIENT_DURATION_METRIC, + *meter, + {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); +} + +#end \ No newline at end of file diff --git a/tools/scripts/run_code_generation.py b/tools/scripts/run_code_generation.py index 5da94ee66e4..ee9f4a76758 100644 --- a/tools/scripts/run_code_generation.py +++ b/tools/scripts/run_code_generation.py @@ -45,6 +45,10 @@ CORE_COMPONENT_TO_MODEL = {"defaults": DEFAULTS_FILE_LOCATION, "partitions": PARTITIONS_FILE_LOCATION} +SMITHY_SUPPORTED_CLIENTS = [ + "dynamodb" +] + DEBUG = False class ServiceModel(object): @@ -307,6 +311,9 @@ def generate_single_client(service_name: str, run_command += ["--service", service_name] run_command += ["--outputfile", output_filename] + if service_name in SMITHY_SUPPORTED_CLIENTS: + run_command += ["--use-smithy-client"] + for key, val in kwargs.items(): run_command += [f"--{key}", val]