/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Aws; using namespace Aws::Auth; using namespace Aws::Client; using namespace Aws::SagemakerEdgeManager; using namespace Aws::SagemakerEdgeManager::Model; using namespace Aws::Http; using namespace Aws::Utils::Json; using namespace smithy::components::tracing; using ResolveEndpointOutcome = Aws::Endpoint::ResolveEndpointOutcome; const char* SagemakerEdgeManagerClient::SERVICE_NAME = "sagemaker"; const char* SagemakerEdgeManagerClient::ALLOCATION_TAG = "SagemakerEdgeManagerClient"; SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(const SagemakerEdgeManager::SagemakerEdgeManagerClientConfiguration& 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_executor(clientConfiguration.executor), m_endpointProvider(std::move(endpointProvider)) { init(m_clientConfiguration); } SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(const AWSCredentials& credentials, std::shared_ptr endpointProvider, const SagemakerEdgeManager::SagemakerEdgeManagerClientConfiguration& 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_executor(clientConfiguration.executor), m_endpointProvider(std::move(endpointProvider)) { init(m_clientConfiguration); } SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(const std::shared_ptr& credentialsProvider, std::shared_ptr endpointProvider, const SagemakerEdgeManager::SagemakerEdgeManagerClientConfiguration& clientConfiguration) : BASECLASS(clientConfiguration, Aws::MakeShared(ALLOCATION_TAG, credentialsProvider, SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)), Aws::MakeShared(ALLOCATION_TAG)), m_clientConfiguration(clientConfiguration), m_executor(clientConfiguration.executor), m_endpointProvider(std::move(endpointProvider)) { init(m_clientConfiguration); } /* Legacy constructors due deprecation */ SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(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_executor(clientConfiguration.executor), m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) { init(m_clientConfiguration); } SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(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_executor(clientConfiguration.executor), m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) { init(m_clientConfiguration); } SagemakerEdgeManagerClient::SagemakerEdgeManagerClient(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_executor(clientConfiguration.executor), m_endpointProvider(Aws::MakeShared(ALLOCATION_TAG)) { init(m_clientConfiguration); } /* End of legacy constructors due deprecation */ SagemakerEdgeManagerClient::~SagemakerEdgeManagerClient() { ShutdownSdkClient(this, -1); } std::shared_ptr& SagemakerEdgeManagerClient::accessEndpointProvider() { return m_endpointProvider; } void SagemakerEdgeManagerClient::init(const SagemakerEdgeManager::SagemakerEdgeManagerClientConfiguration& config) { AWSClient::SetServiceClientName("Sagemaker Edge"); AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); m_endpointProvider->InitBuiltInParameters(config); } void SagemakerEdgeManagerClient::OverrideEndpoint(const Aws::String& endpoint) { AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider); m_endpointProvider->OverrideEndpoint(endpoint); } GetDeploymentsOutcome SagemakerEdgeManagerClient::GetDeployments(const GetDeploymentsRequest& request) const { AWS_OPERATION_GUARD(GetDeployments); AWS_OPERATION_CHECK_PTR(m_endpointProvider, GetDeployments, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); AWS_OPERATION_CHECK_PTR(m_telemetryProvider, GetDeployments, CoreErrors, CoreErrors::NOT_INITIALIZED); auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, GetDeployments, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".GetDeployments", {{ 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( [&]()-> GetDeploymentsOutcome { 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, GetDeployments, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); endpointResolutionOutcome.GetResult().AddPathSegments("/GetDeployments"); return GetDeploymentsOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); } GetDeviceRegistrationOutcome SagemakerEdgeManagerClient::GetDeviceRegistration(const GetDeviceRegistrationRequest& request) const { AWS_OPERATION_GUARD(GetDeviceRegistration); AWS_OPERATION_CHECK_PTR(m_endpointProvider, GetDeviceRegistration, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); AWS_OPERATION_CHECK_PTR(m_telemetryProvider, GetDeviceRegistration, CoreErrors, CoreErrors::NOT_INITIALIZED); auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, GetDeviceRegistration, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".GetDeviceRegistration", {{ 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( [&]()-> GetDeviceRegistrationOutcome { 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, GetDeviceRegistration, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); endpointResolutionOutcome.GetResult().AddPathSegments("/GetDeviceRegistration"); return GetDeviceRegistrationOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); } SendHeartbeatOutcome SagemakerEdgeManagerClient::SendHeartbeat(const SendHeartbeatRequest& request) const { AWS_OPERATION_GUARD(SendHeartbeat); AWS_OPERATION_CHECK_PTR(m_endpointProvider, SendHeartbeat, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); AWS_OPERATION_CHECK_PTR(m_telemetryProvider, SendHeartbeat, CoreErrors, CoreErrors::NOT_INITIALIZED); auto tracer = m_telemetryProvider->getTracer(this->GetServiceClientName(), {}); auto meter = m_telemetryProvider->getMeter(this->GetServiceClientName(), {}); AWS_OPERATION_CHECK_PTR(meter, SendHeartbeat, CoreErrors, CoreErrors::NOT_INITIALIZED); auto span = tracer->CreateSpan(Aws::String(this->GetServiceClientName()) + ".SendHeartbeat", {{ 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( [&]()-> SendHeartbeatOutcome { 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, SendHeartbeat, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); endpointResolutionOutcome.GetResult().AddPathSegments("/SendHeartbeat"); return SendHeartbeatOutcome(MakeRequest(request, endpointResolutionOutcome.GetResult(), Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER)); }, TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, {{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, {TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); }