feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放

This commit is contained in:
彭宣正
2020-12-14 17:24:58 +08:00
parent 505d529c32
commit 10b370e486
55976 changed files with 8544395 additions and 2 deletions

View File

@@ -0,0 +1,76 @@
add_project(aws-cpp-sdk-sagemaker-runtime "C++ SDK for the AWS sagemaker-runtime service" aws-cpp-sdk-core)
file(GLOB AWS_SAGEMAKER-RUNTIME_HEADERS
"include/aws/sagemaker-runtime/*.h"
)
file(GLOB AWS_SAGEMAKER-RUNTIME_MODEL_HEADERS
"include/aws/sagemaker-runtime/model/*.h"
)
file(GLOB AWS_SAGEMAKER-RUNTIME_SOURCE
"source/*.cpp"
)
file(GLOB AWS_SAGEMAKER-RUNTIME_MODEL_SOURCE
"source/model/*.cpp"
)
file(GLOB SAGEMAKER-RUNTIME_UNIFIED_HEADERS
${AWS_SAGEMAKER-RUNTIME_HEADERS}
${AWS_SAGEMAKER-RUNTIME_MODEL_HEADERS}
)
file(GLOB SAGEMAKER-RUNTIME_UNITY_SRC
${AWS_SAGEMAKER-RUNTIME_SOURCE}
${AWS_SAGEMAKER-RUNTIME_MODEL_SOURCE}
)
if(ENABLE_UNITY_BUILD)
enable_unity_build("SAGEMAKER-RUNTIME" SAGEMAKER-RUNTIME_UNITY_SRC)
endif()
file(GLOB SAGEMAKER-RUNTIME_SRC
${SAGEMAKER-RUNTIME_UNIFIED_HEADERS}
${SAGEMAKER-RUNTIME_UNITY_SRC}
)
if(WIN32)
#if we are compiling for visual studio, create a sane directory tree.
if(MSVC)
source_group("Header Files\\aws\\sagemaker-runtime" FILES ${AWS_SAGEMAKER-RUNTIME_HEADERS})
source_group("Header Files\\aws\\sagemaker-runtime\\model" FILES ${AWS_SAGEMAKER-RUNTIME_MODEL_HEADERS})
source_group("Source Files" FILES ${AWS_SAGEMAKER-RUNTIME_SOURCE})
source_group("Source Files\\model" FILES ${AWS_SAGEMAKER-RUNTIME_MODEL_SOURCE})
endif(MSVC)
endif()
set(SAGEMAKER-RUNTIME_INCLUDES
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
)
add_library(${PROJECT_NAME} ${SAGEMAKER-RUNTIME_SRC})
add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_compiler_flags(${PROJECT_NAME})
set_compiler_warnings(${PROJECT_NAME})
if(USE_WINDOWS_DLL_SEMANTICS AND BUILD_SHARED_LIBS)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_SAGEMAKERRUNTIME_EXPORTS")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_DEP_LIBS} ${PROJECT_LIBS})
setup_install()
install (FILES ${AWS_SAGEMAKER-RUNTIME_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/sagemaker-runtime)
install (FILES ${AWS_SAGEMAKER-RUNTIME_MODEL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/sagemaker-runtime/model)
do_packaging()

View File

@@ -0,0 +1,189 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeErrors.h>
#include <aws/core/client/AWSError.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/client/AWSClient.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/sagemaker-runtime/model/InvokeEndpointResult.h>
#include <aws/core/client/AsyncCallerContext.h>
#include <aws/core/http/HttpTypes.h>
#include <future>
#include <functional>
namespace Aws
{
namespace Http
{
class HttpClient;
class HttpClientFactory;
} // namespace Http
namespace Utils
{
template< typename R, typename E> class Outcome;
namespace Threading
{
class Executor;
} // namespace Threading
} // namespace Utils
namespace Auth
{
class AWSCredentials;
class AWSCredentialsProvider;
} // namespace Auth
namespace Client
{
class RetryStrategy;
} // namespace Client
namespace SageMakerRuntime
{
namespace Model
{
class InvokeEndpointRequest;
typedef Aws::Utils::Outcome<InvokeEndpointResult, SageMakerRuntimeError> InvokeEndpointOutcome;
typedef std::future<InvokeEndpointOutcome> InvokeEndpointOutcomeCallable;
} // namespace Model
class SageMakerRuntimeClient;
typedef std::function<void(const SageMakerRuntimeClient*, const Model::InvokeEndpointRequest&, Model::InvokeEndpointOutcome, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > InvokeEndpointResponseReceivedHandler;
/**
* <p> The Amazon SageMaker runtime API. </p>
*/
class AWS_SAGEMAKERRUNTIME_API SageMakerRuntimeClient : public Aws::Client::AWSJsonClient
{
public:
typedef Aws::Client::AWSJsonClient BASECLASS;
/**
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
SageMakerRuntimeClient(const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
SageMakerRuntimeClient(const Aws::Auth::AWSCredentials& credentials, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied,
* the default http client factory will be used
*/
SageMakerRuntimeClient(const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
virtual ~SageMakerRuntimeClient();
/**
* <p>After you deploy a model into production using Amazon SageMaker hosting
* services, your client applications use this API to get inferences from the model
* hosted at the specified endpoint. </p> <p>For an overview of Amazon SageMaker,
* see <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It
* Works</a>. </p> <p>Amazon SageMaker strips all POST headers except those
* supported by the API. Amazon SageMaker might add additional headers. You should
* not rely on the behavior of headers outside those enumerated in the request
* syntax. </p> <p>Calls to <code>InvokeEndpoint</code> are authenticated by using
* AWS Signature Version 4. For information, see <a
* href="http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
* Requests (AWS Signature Version 4)</a> in the <i>Amazon S3 API
* Reference</i>.</p> <p>A customer's model containers must respond to requests
* within 60 seconds. The model itself can have a maximum processing time of 60
* seconds before responding to the /invocations. If your model is going to take
* 50-60 seconds of processing time, the SDK socket timeout should be set to be 70
* seconds.</p> <p>Endpoints are scoped to an individual account, and are
* not public. The URL does not contain the account ID, but Amazon SageMaker
* determines the account ID from the authentication token that is supplied by the
* caller.</p> <p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">AWS
* API Reference</a></p>
*/
virtual Model::InvokeEndpointOutcome InvokeEndpoint(const Model::InvokeEndpointRequest& request) const;
/**
* <p>After you deploy a model into production using Amazon SageMaker hosting
* services, your client applications use this API to get inferences from the model
* hosted at the specified endpoint. </p> <p>For an overview of Amazon SageMaker,
* see <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It
* Works</a>. </p> <p>Amazon SageMaker strips all POST headers except those
* supported by the API. Amazon SageMaker might add additional headers. You should
* not rely on the behavior of headers outside those enumerated in the request
* syntax. </p> <p>Calls to <code>InvokeEndpoint</code> are authenticated by using
* AWS Signature Version 4. For information, see <a
* href="http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
* Requests (AWS Signature Version 4)</a> in the <i>Amazon S3 API
* Reference</i>.</p> <p>A customer's model containers must respond to requests
* within 60 seconds. The model itself can have a maximum processing time of 60
* seconds before responding to the /invocations. If your model is going to take
* 50-60 seconds of processing time, the SDK socket timeout should be set to be 70
* seconds.</p> <p>Endpoints are scoped to an individual account, and are
* not public. The URL does not contain the account ID, but Amazon SageMaker
* determines the account ID from the authentication token that is supplied by the
* caller.</p> <p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::InvokeEndpointOutcomeCallable InvokeEndpointCallable(const Model::InvokeEndpointRequest& request) const;
/**
* <p>After you deploy a model into production using Amazon SageMaker hosting
* services, your client applications use this API to get inferences from the model
* hosted at the specified endpoint. </p> <p>For an overview of Amazon SageMaker,
* see <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It
* Works</a>. </p> <p>Amazon SageMaker strips all POST headers except those
* supported by the API. Amazon SageMaker might add additional headers. You should
* not rely on the behavior of headers outside those enumerated in the request
* syntax. </p> <p>Calls to <code>InvokeEndpoint</code> are authenticated by using
* AWS Signature Version 4. For information, see <a
* href="http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
* Requests (AWS Signature Version 4)</a> in the <i>Amazon S3 API
* Reference</i>.</p> <p>A customer's model containers must respond to requests
* within 60 seconds. The model itself can have a maximum processing time of 60
* seconds before responding to the /invocations. If your model is going to take
* 50-60 seconds of processing time, the SDK socket timeout should be set to be 70
* seconds.</p> <p>Endpoints are scoped to an individual account, and are
* not public. The URL does not contain the account ID, but Amazon SageMaker
* determines the account ID from the authentication token that is supplied by the
* caller.</p> <p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void InvokeEndpointAsync(const Model::InvokeEndpointRequest& request, const InvokeEndpointResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
void OverrideEndpoint(const Aws::String& endpoint);
private:
void init(const Aws::Client::ClientConfiguration& clientConfiguration);
void InvokeEndpointAsyncHelper(const Model::InvokeEndpointRequest& request, const InvokeEndpointResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
Aws::String m_uri;
Aws::String m_configScheme;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
};
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,21 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/core/Region.h>
#include <aws/core/utils/memory/stl/AWSString.h>
namespace Aws
{
namespace SageMakerRuntime
{
namespace SageMakerRuntimeEndpoint
{
AWS_SAGEMAKERRUNTIME_API Aws::String ForRegion(const Aws::String& regionName, bool useDualStack = false);
} // namespace SageMakerRuntimeEndpoint
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,23 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/core/client/AWSErrorMarshaller.h>
namespace Aws
{
namespace Client
{
class AWS_SAGEMAKERRUNTIME_API SageMakerRuntimeErrorMarshaller : public Aws::Client::JsonErrorMarshaller
{
public:
Aws::Client::AWSError<Aws::Client::CoreErrors> FindErrorByName(const char* exceptionName) const override;
};
} // namespace Client
} // namespace Aws

View File

@@ -0,0 +1,72 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/core/client/AWSError.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
namespace Aws
{
namespace SageMakerRuntime
{
enum class SageMakerRuntimeErrors
{
//From Core//
//////////////////////////////////////////////////////////////////////////////////////////
INCOMPLETE_SIGNATURE = 0,
INTERNAL_FAILURE = 1,
INVALID_ACTION = 2,
INVALID_CLIENT_TOKEN_ID = 3,
INVALID_PARAMETER_COMBINATION = 4,
INVALID_QUERY_PARAMETER = 5,
INVALID_PARAMETER_VALUE = 6,
MISSING_ACTION = 7, // SDK should never allow
MISSING_AUTHENTICATION_TOKEN = 8, // SDK should never allow
MISSING_PARAMETER = 9, // SDK should never allow
OPT_IN_REQUIRED = 10,
REQUEST_EXPIRED = 11,
SERVICE_UNAVAILABLE = 12,
THROTTLING = 13,
VALIDATION = 14,
ACCESS_DENIED = 15,
RESOURCE_NOT_FOUND = 16,
UNRECOGNIZED_CLIENT = 17,
MALFORMED_QUERY_STRING = 18,
SLOW_DOWN = 19,
REQUEST_TIME_TOO_SKEWED = 20,
INVALID_SIGNATURE = 21,
SIGNATURE_DOES_NOT_MATCH = 22,
INVALID_ACCESS_KEY_ID = 23,
REQUEST_TIMEOUT = 24,
NETWORK_CONNECTION = 99,
UNKNOWN = 100,
///////////////////////////////////////////////////////////////////////////////////////////
MODEL= static_cast<int>(Aws::Client::CoreErrors::SERVICE_EXTENSION_START_RANGE) + 1
};
class AWS_SAGEMAKERRUNTIME_API SageMakerRuntimeError : public Aws::Client::AWSError<SageMakerRuntimeErrors>
{
public:
SageMakerRuntimeError() {}
SageMakerRuntimeError(const Aws::Client::AWSError<Aws::Client::CoreErrors>& rhs) : Aws::Client::AWSError<SageMakerRuntimeErrors>(rhs) {}
SageMakerRuntimeError(Aws::Client::AWSError<Aws::Client::CoreErrors>&& rhs) : Aws::Client::AWSError<SageMakerRuntimeErrors>(rhs) {}
SageMakerRuntimeError(const Aws::Client::AWSError<SageMakerRuntimeErrors>& rhs) : Aws::Client::AWSError<SageMakerRuntimeErrors>(rhs) {}
SageMakerRuntimeError(Aws::Client::AWSError<SageMakerRuntimeErrors>&& rhs) : Aws::Client::AWSError<SageMakerRuntimeErrors>(rhs) {}
template <typename T>
T GetModeledError();
};
namespace SageMakerRuntimeErrorMapper
{
AWS_SAGEMAKERRUNTIME_API Aws::Client::AWSError<Aws::Client::CoreErrors> GetErrorForName(const char* errorName);
}
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,44 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/core/AmazonSerializableWebServiceRequest.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <aws/core/http/HttpRequest.h>
#include <aws/core/AmazonStreamingWebServiceRequest.h>
namespace Aws
{
namespace SageMakerRuntime
{
class AWS_SAGEMAKERRUNTIME_API SageMakerRuntimeRequest : public Aws::AmazonSerializableWebServiceRequest
{
public:
virtual ~SageMakerRuntimeRequest () {}
void AddParametersToRequest(Aws::Http::HttpRequest& httpRequest) const { AWS_UNREFERENCED_PARAM(httpRequest); }
inline Aws::Http::HeaderValueCollection GetHeaders() const override
{
auto headers = GetRequestSpecificHeaders();
if(headers.size() == 0 || (headers.size() > 0 && headers.count(Aws::Http::CONTENT_TYPE_HEADER) == 0))
{
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::CONTENT_TYPE_HEADER, Aws::AMZN_JSON_CONTENT_TYPE_1_1 ));
}
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::API_VERSION_HEADER, "2017-05-13"));
return headers;
}
protected:
virtual Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const { return Aws::Http::HeaderValueCollection(); }
};
typedef Aws::AmazonStreamingWebServiceRequest StreamingSageMakerRuntimeRequest;
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,29 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#ifdef _MSC_VER
//disable windows complaining about max template size.
#pragma warning (disable : 4503)
#endif // _MSC_VER
#if defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32)
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif // _MSC_VER
#ifdef USE_IMPORT_EXPORT
#ifdef AWS_SAGEMAKERRUNTIME_EXPORTS
#define AWS_SAGEMAKERRUNTIME_API __declspec(dllexport)
#else
#define AWS_SAGEMAKERRUNTIME_API __declspec(dllimport)
#endif /* AWS_SAGEMAKERRUNTIME_EXPORTS */
#else
#define AWS_SAGEMAKERRUNTIME_API
#endif // USE_IMPORT_EXPORT
#else // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)
#define AWS_SAGEMAKERRUNTIME_API
#endif // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)

View File

@@ -0,0 +1,381 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/Array.h>
#include <utility>
namespace Aws
{
namespace SageMakerRuntime
{
namespace Model
{
/**
*/
class AWS_SAGEMAKERRUNTIME_API InvokeEndpointRequest : public StreamingSageMakerRuntimeRequest
{
public:
InvokeEndpointRequest();
// Service request name is the Operation name which will send this request out,
// each operation should has unique request name, so that we can get operation's name from this request.
// Note: this is not true for response, multiple operations may have the same response name,
// so we can not get operation's name from response.
inline virtual const char* GetServiceRequestName() const override { return "InvokeEndpoint"; }
Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override;
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline const Aws::String& GetEndpointName() const{ return m_endpointName; }
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline bool EndpointNameHasBeenSet() const { return m_endpointNameHasBeenSet; }
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline void SetEndpointName(const Aws::String& value) { m_endpointNameHasBeenSet = true; m_endpointName = value; }
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline void SetEndpointName(Aws::String&& value) { m_endpointNameHasBeenSet = true; m_endpointName = std::move(value); }
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline void SetEndpointName(const char* value) { m_endpointNameHasBeenSet = true; m_endpointName.assign(value); }
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline InvokeEndpointRequest& WithEndpointName(const Aws::String& value) { SetEndpointName(value); return *this;}
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline InvokeEndpointRequest& WithEndpointName(Aws::String&& value) { SetEndpointName(std::move(value)); return *this;}
/**
* <p>The name of the endpoint that you specified when you created the endpoint
* using the <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a>
* API. </p>
*/
inline InvokeEndpointRequest& WithEndpointName(const char* value) { SetEndpointName(value); return *this;}
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline const Aws::String& GetAccept() const{ return m_accept; }
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline bool AcceptHasBeenSet() const { return m_acceptHasBeenSet; }
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline void SetAccept(const Aws::String& value) { m_acceptHasBeenSet = true; m_accept = value; }
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline void SetAccept(Aws::String&& value) { m_acceptHasBeenSet = true; m_accept = std::move(value); }
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline void SetAccept(const char* value) { m_acceptHasBeenSet = true; m_accept.assign(value); }
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline InvokeEndpointRequest& WithAccept(const Aws::String& value) { SetAccept(value); return *this;}
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline InvokeEndpointRequest& WithAccept(Aws::String&& value) { SetAccept(std::move(value)); return *this;}
/**
* <p>The desired MIME type of the inference in the response.</p>
*/
inline InvokeEndpointRequest& WithAccept(const char* value) { SetAccept(value); return *this;}
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline const Aws::String& GetCustomAttributes() const{ return m_customAttributes; }
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline bool CustomAttributesHasBeenSet() const { return m_customAttributesHasBeenSet; }
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline void SetCustomAttributes(const Aws::String& value) { m_customAttributesHasBeenSet = true; m_customAttributes = value; }
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline void SetCustomAttributes(Aws::String&& value) { m_customAttributesHasBeenSet = true; m_customAttributes = std::move(value); }
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline void SetCustomAttributes(const char* value) { m_customAttributesHasBeenSet = true; m_customAttributes.assign(value); }
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline InvokeEndpointRequest& WithCustomAttributes(const Aws::String& value) { SetCustomAttributes(value); return *this;}
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline InvokeEndpointRequest& WithCustomAttributes(Aws::String&& value) { SetCustomAttributes(std::move(value)); return *this;}
/**
* <p>Provides additional information about a request for an inference submitted to
* a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* provide an ID that you can use to track a request or to provide other metadata
* that a service endpoint was programmed to process. The value must consist of no
* more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). This feature
* is currently supported in the AWS SDKs but not in the Amazon SageMaker Python
* SDK.</p>
*/
inline InvokeEndpointRequest& WithCustomAttributes(const char* value) { SetCustomAttributes(value); return *this;}
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline const Aws::String& GetTargetModel() const{ return m_targetModel; }
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline bool TargetModelHasBeenSet() const { return m_targetModelHasBeenSet; }
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline void SetTargetModel(const Aws::String& value) { m_targetModelHasBeenSet = true; m_targetModel = value; }
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline void SetTargetModel(Aws::String&& value) { m_targetModelHasBeenSet = true; m_targetModel = std::move(value); }
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline void SetTargetModel(const char* value) { m_targetModelHasBeenSet = true; m_targetModel.assign(value); }
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline InvokeEndpointRequest& WithTargetModel(const Aws::String& value) { SetTargetModel(value); return *this;}
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline InvokeEndpointRequest& WithTargetModel(Aws::String&& value) { SetTargetModel(std::move(value)); return *this;}
/**
* <p>The model to request for inference when invoking a multi-model endpoint. </p>
*/
inline InvokeEndpointRequest& WithTargetModel(const char* value) { SetTargetModel(value); return *this;}
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline const Aws::String& GetTargetVariant() const{ return m_targetVariant; }
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline bool TargetVariantHasBeenSet() const { return m_targetVariantHasBeenSet; }
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline void SetTargetVariant(const Aws::String& value) { m_targetVariantHasBeenSet = true; m_targetVariant = value; }
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline void SetTargetVariant(Aws::String&& value) { m_targetVariantHasBeenSet = true; m_targetVariant = std::move(value); }
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline void SetTargetVariant(const char* value) { m_targetVariantHasBeenSet = true; m_targetVariant.assign(value); }
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline InvokeEndpointRequest& WithTargetVariant(const Aws::String& value) { SetTargetVariant(value); return *this;}
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline InvokeEndpointRequest& WithTargetVariant(Aws::String&& value) { SetTargetVariant(std::move(value)); return *this;}
/**
* <p>Specify the production variant to send the inference request to when invoking
* an endpoint that is running two or more variants. Note that this parameter
* overrides the default behavior for the endpoint, which is to distribute the
* invocation traffic based on the variant weights.</p>
*/
inline InvokeEndpointRequest& WithTargetVariant(const char* value) { SetTargetVariant(value); return *this;}
private:
Aws::String m_endpointName;
bool m_endpointNameHasBeenSet;
Aws::String m_accept;
bool m_acceptHasBeenSet;
Aws::String m_customAttributes;
bool m_customAttributesHasBeenSet;
Aws::String m_targetModel;
bool m_targetModelHasBeenSet;
Aws::String m_targetVariant;
bool m_targetVariantHasBeenSet;
};
} // namespace Model
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,247 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/core/utils/stream/ResponseStream.h>
#include <aws/core/utils/Array.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace SageMakerRuntime
{
namespace Model
{
class AWS_SAGEMAKERRUNTIME_API InvokeEndpointResult
{
public:
InvokeEndpointResult();
//We have to define these because Microsoft doesn't auto generate them
InvokeEndpointResult(InvokeEndpointResult&&);
InvokeEndpointResult& operator=(InvokeEndpointResult&&);
//we delete these because Microsoft doesn't handle move generation correctly
//and we therefore don't trust them to get it right here either.
InvokeEndpointResult(const InvokeEndpointResult&) = delete;
InvokeEndpointResult& operator=(const InvokeEndpointResult&) = delete;
InvokeEndpointResult(Aws::AmazonWebServiceResult<Aws::Utils::Stream::ResponseStream>&& result);
InvokeEndpointResult& operator=(Aws::AmazonWebServiceResult<Aws::Utils::Stream::ResponseStream>&& result);
/**
* <p>Includes the inference provided by the model.</p> <p>For information about
* the format of the response body, see <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common
* Data Formats-Inference</a>.</p>
*/
inline Aws::IOStream& GetBody() { return m_body.GetUnderlyingStream(); }
/**
* <p>Includes the inference provided by the model.</p> <p>For information about
* the format of the response body, see <a
* href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common
* Data Formats-Inference</a>.</p>
*/
inline void ReplaceBody(Aws::IOStream* body) { m_body = Aws::Utils::Stream::ResponseStream(body); }
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline const Aws::String& GetContentType() const{ return m_contentType; }
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline void SetContentType(const Aws::String& value) { m_contentType = value; }
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline void SetContentType(Aws::String&& value) { m_contentType = std::move(value); }
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline void SetContentType(const char* value) { m_contentType.assign(value); }
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline InvokeEndpointResult& WithContentType(const Aws::String& value) { SetContentType(value); return *this;}
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline InvokeEndpointResult& WithContentType(Aws::String&& value) { SetContentType(std::move(value)); return *this;}
/**
* <p>The MIME type of the inference returned in the response body.</p>
*/
inline InvokeEndpointResult& WithContentType(const char* value) { SetContentType(value); return *this;}
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline const Aws::String& GetInvokedProductionVariant() const{ return m_invokedProductionVariant; }
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline void SetInvokedProductionVariant(const Aws::String& value) { m_invokedProductionVariant = value; }
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline void SetInvokedProductionVariant(Aws::String&& value) { m_invokedProductionVariant = std::move(value); }
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline void SetInvokedProductionVariant(const char* value) { m_invokedProductionVariant.assign(value); }
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline InvokeEndpointResult& WithInvokedProductionVariant(const Aws::String& value) { SetInvokedProductionVariant(value); return *this;}
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline InvokeEndpointResult& WithInvokedProductionVariant(Aws::String&& value) { SetInvokedProductionVariant(std::move(value)); return *this;}
/**
* <p>Identifies the production variant that was invoked.</p>
*/
inline InvokeEndpointResult& WithInvokedProductionVariant(const char* value) { SetInvokedProductionVariant(value); return *this;}
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline const Aws::String& GetCustomAttributes() const{ return m_customAttributes; }
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline void SetCustomAttributes(const Aws::String& value) { m_customAttributes = value; }
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline void SetCustomAttributes(Aws::String&& value) { m_customAttributes = std::move(value); }
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline void SetCustomAttributes(const char* value) { m_customAttributes.assign(value); }
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline InvokeEndpointResult& WithCustomAttributes(const Aws::String& value) { SetCustomAttributes(value); return *this;}
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline InvokeEndpointResult& WithCustomAttributes(Aws::String&& value) { SetCustomAttributes(std::move(value)); return *this;}
/**
* <p>Provides additional information in the response about the inference returned
* by a model hosted at an Amazon SageMaker endpoint. The information is an opaque
* value that is forwarded verbatim. You could use this value, for example, to
* return an ID received in the <code>CustomAttributes</code> header of a request
* or other metadata that a service endpoint was programmed to produce. The value
* must consist of no more than 1024 visible US-ASCII characters as specified in <a
* href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field
* Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the
* customer wants the custom attribute returned, the model must set the custom
* attribute to be included on the way back. </p> <p>This feature is currently
* supported in the AWS SDKs but not in the Amazon SageMaker Python SDK.</p>
*/
inline InvokeEndpointResult& WithCustomAttributes(const char* value) { SetCustomAttributes(value); return *this;}
private:
Aws::Utils::Stream::ResponseStream m_body;
Aws::String m_contentType;
Aws::String m_invokedProductionVariant;
Aws::String m_customAttributes;
};
} // namespace Model
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,185 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/sagemaker-runtime/SageMakerRuntime_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace SageMakerRuntime
{
namespace Model
{
/**
* <p> Model (owned by the customer in the container) returned 4xx or 5xx error
* code. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/ModelError">AWS
* API Reference</a></p>
*/
class AWS_SAGEMAKERRUNTIME_API ModelError
{
public:
ModelError();
ModelError(Aws::Utils::Json::JsonView jsonValue);
ModelError& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
inline const Aws::String& GetMessage() const{ return m_message; }
inline bool MessageHasBeenSet() const { return m_messageHasBeenSet; }
inline void SetMessage(const Aws::String& value) { m_messageHasBeenSet = true; m_message = value; }
inline void SetMessage(Aws::String&& value) { m_messageHasBeenSet = true; m_message = std::move(value); }
inline void SetMessage(const char* value) { m_messageHasBeenSet = true; m_message.assign(value); }
inline ModelError& WithMessage(const Aws::String& value) { SetMessage(value); return *this;}
inline ModelError& WithMessage(Aws::String&& value) { SetMessage(std::move(value)); return *this;}
inline ModelError& WithMessage(const char* value) { SetMessage(value); return *this;}
/**
* <p> Original status code. </p>
*/
inline int GetOriginalStatusCode() const{ return m_originalStatusCode; }
/**
* <p> Original status code. </p>
*/
inline bool OriginalStatusCodeHasBeenSet() const { return m_originalStatusCodeHasBeenSet; }
/**
* <p> Original status code. </p>
*/
inline void SetOriginalStatusCode(int value) { m_originalStatusCodeHasBeenSet = true; m_originalStatusCode = value; }
/**
* <p> Original status code. </p>
*/
inline ModelError& WithOriginalStatusCode(int value) { SetOriginalStatusCode(value); return *this;}
/**
* <p> Original message. </p>
*/
inline const Aws::String& GetOriginalMessage() const{ return m_originalMessage; }
/**
* <p> Original message. </p>
*/
inline bool OriginalMessageHasBeenSet() const { return m_originalMessageHasBeenSet; }
/**
* <p> Original message. </p>
*/
inline void SetOriginalMessage(const Aws::String& value) { m_originalMessageHasBeenSet = true; m_originalMessage = value; }
/**
* <p> Original message. </p>
*/
inline void SetOriginalMessage(Aws::String&& value) { m_originalMessageHasBeenSet = true; m_originalMessage = std::move(value); }
/**
* <p> Original message. </p>
*/
inline void SetOriginalMessage(const char* value) { m_originalMessageHasBeenSet = true; m_originalMessage.assign(value); }
/**
* <p> Original message. </p>
*/
inline ModelError& WithOriginalMessage(const Aws::String& value) { SetOriginalMessage(value); return *this;}
/**
* <p> Original message. </p>
*/
inline ModelError& WithOriginalMessage(Aws::String&& value) { SetOriginalMessage(std::move(value)); return *this;}
/**
* <p> Original message. </p>
*/
inline ModelError& WithOriginalMessage(const char* value) { SetOriginalMessage(value); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline const Aws::String& GetLogStreamArn() const{ return m_logStreamArn; }
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline bool LogStreamArnHasBeenSet() const { return m_logStreamArnHasBeenSet; }
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline void SetLogStreamArn(const Aws::String& value) { m_logStreamArnHasBeenSet = true; m_logStreamArn = value; }
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline void SetLogStreamArn(Aws::String&& value) { m_logStreamArnHasBeenSet = true; m_logStreamArn = std::move(value); }
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline void SetLogStreamArn(const char* value) { m_logStreamArnHasBeenSet = true; m_logStreamArn.assign(value); }
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline ModelError& WithLogStreamArn(const Aws::String& value) { SetLogStreamArn(value); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline ModelError& WithLogStreamArn(Aws::String&& value) { SetLogStreamArn(std::move(value)); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the log stream. </p>
*/
inline ModelError& WithLogStreamArn(const char* value) { SetLogStreamArn(value); return *this;}
private:
Aws::String m_message;
bool m_messageHasBeenSet;
int m_originalStatusCode;
bool m_originalStatusCodeHasBeenSet;
Aws::String m_originalMessage;
bool m_originalMessageHasBeenSet;
Aws::String m_logStreamArn;
bool m_logStreamArnHasBeenSet;
};
} // namespace Model
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,131 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/utils/Outcome.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/http/HttpClientFactory.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/core/utils/DNS.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeClient.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeEndpoint.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeErrorMarshaller.h>
#include <aws/sagemaker-runtime/model/InvokeEndpointRequest.h>
using namespace Aws;
using namespace Aws::Auth;
using namespace Aws::Client;
using namespace Aws::SageMakerRuntime;
using namespace Aws::SageMakerRuntime::Model;
using namespace Aws::Http;
using namespace Aws::Utils::Json;
static const char* SERVICE_NAME = "sagemaker";
static const char* ALLOCATION_TAG = "SageMakerRuntimeClient";
SageMakerRuntimeClient::SageMakerRuntimeClient(const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<SageMakerRuntimeErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
SageMakerRuntimeClient::SageMakerRuntimeClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<SageMakerRuntimeErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
SageMakerRuntimeClient::SageMakerRuntimeClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<SageMakerRuntimeErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
SageMakerRuntimeClient::~SageMakerRuntimeClient()
{
}
void SageMakerRuntimeClient::init(const ClientConfiguration& config)
{
SetServiceClientName("SageMaker Runtime");
m_configScheme = SchemeMapper::ToString(config.scheme);
if (config.endpointOverride.empty())
{
m_uri = m_configScheme + "://" + SageMakerRuntimeEndpoint::ForRegion(config.region, config.useDualStack);
}
else
{
OverrideEndpoint(config.endpointOverride);
}
}
void SageMakerRuntimeClient::OverrideEndpoint(const Aws::String& endpoint)
{
if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
{
m_uri = endpoint;
}
else
{
m_uri = m_configScheme + "://" + endpoint;
}
}
InvokeEndpointOutcome SageMakerRuntimeClient::InvokeEndpoint(const InvokeEndpointRequest& request) const
{
if (!request.EndpointNameHasBeenSet())
{
AWS_LOGSTREAM_ERROR("InvokeEndpoint", "Required field: EndpointName, is not set");
return InvokeEndpointOutcome(Aws::Client::AWSError<SageMakerRuntimeErrors>(SageMakerRuntimeErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [EndpointName]", false));
}
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/endpoints/";
ss << request.GetEndpointName();
ss << "/invocations";
uri.SetPath(uri.GetPath() + ss.str());
return InvokeEndpointOutcome(MakeRequestWithUnparsedResponse(uri, request, Aws::Http::HttpMethod::HTTP_POST));
}
InvokeEndpointOutcomeCallable SageMakerRuntimeClient::InvokeEndpointCallable(const InvokeEndpointRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< InvokeEndpointOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->InvokeEndpoint(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void SageMakerRuntimeClient::InvokeEndpointAsync(const InvokeEndpointRequest& request, const InvokeEndpointResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->InvokeEndpointAsyncHelper( request, handler, context ); } );
}
void SageMakerRuntimeClient::InvokeEndpointAsyncHelper(const InvokeEndpointRequest& request, const InvokeEndpointResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, InvokeEndpoint(request), context);
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/sagemaker-runtime/SageMakerRuntimeEndpoint.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/HashingUtils.h>
using namespace Aws;
using namespace Aws::SageMakerRuntime;
namespace Aws
{
namespace SageMakerRuntime
{
namespace SageMakerRuntimeEndpoint
{
static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString("cn-north-1");
static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString("cn-northwest-1");
static const int US_ISO_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-iso-east-1");
static const int US_ISOB_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-isob-east-1");
Aws::String ForRegion(const Aws::String& regionName, bool useDualStack)
{
// Fallback to us-east-1 if global endpoint does not exists.
Aws::String region = regionName == Aws::Region::AWS_GLOBAL ? Aws::Region::US_EAST_1 : regionName;
auto hash = Aws::Utils::HashingUtils::HashString(region.c_str());
Aws::StringStream ss;
ss << "runtime.sagemaker" << ".";
if(useDualStack)
{
ss << "dualstack.";
}
ss << region;
if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH)
{
ss << ".amazonaws.com.cn";
}
else if (hash == US_ISO_EAST_1_HASH)
{
ss << ".c2s.ic.gov";
}
else if (hash == US_ISOB_EAST_1_HASH)
{
ss << ".sc2s.sgov.gov";
}
else
{
ss << ".amazonaws.com";
}
return ss.str();
}
} // namespace SageMakerRuntimeEndpoint
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,22 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeErrorMarshaller.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeErrors.h>
using namespace Aws::Client;
using namespace Aws::SageMakerRuntime;
AWSError<CoreErrors> SageMakerRuntimeErrorMarshaller::FindErrorByName(const char* errorName) const
{
AWSError<CoreErrors> error = SageMakerRuntimeErrorMapper::GetErrorForName(errorName);
if(error.GetErrorType() != CoreErrors::UNKNOWN)
{
return error;
}
return AWSErrorMarshaller::FindErrorByName(errorName);
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/sagemaker-runtime/SageMakerRuntimeErrors.h>
#include <aws/sagemaker-runtime/model/ModelError.h>
using namespace Aws::Client;
using namespace Aws::Utils;
using namespace Aws::SageMakerRuntime;
using namespace Aws::SageMakerRuntime::Model;
namespace Aws
{
namespace SageMakerRuntime
{
template<> AWS_SAGEMAKERRUNTIME_API ModelError SageMakerRuntimeError::GetModeledError()
{
assert(this->GetErrorType() == SageMakerRuntimeErrors::MODEL);
return ModelError(this->GetJsonPayload().View());
}
namespace SageMakerRuntimeErrorMapper
{
static const int MODEL_HASH = HashingUtils::HashString("ModelError");
AWSError<CoreErrors> GetErrorForName(const char* errorName)
{
int hashCode = HashingUtils::HashString(errorName);
if (hashCode == MODEL_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(SageMakerRuntimeErrors::MODEL), false);
}
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
}
} // namespace SageMakerRuntimeErrorMapper
} // namespace SageMakerRuntime
} // namespace Aws

View File

@@ -0,0 +1,63 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/sagemaker-runtime/model/InvokeEndpointRequest.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <utility>
using namespace Aws::SageMakerRuntime::Model;
using namespace Aws::Utils::Stream;
using namespace Aws::Utils;
using namespace Aws;
InvokeEndpointRequest::InvokeEndpointRequest() :
m_endpointNameHasBeenSet(false),
m_acceptHasBeenSet(false),
m_customAttributesHasBeenSet(false),
m_targetModelHasBeenSet(false),
m_targetVariantHasBeenSet(false)
{
}
Aws::Http::HeaderValueCollection InvokeEndpointRequest::GetRequestSpecificHeaders() const
{
Aws::Http::HeaderValueCollection headers;
Aws::StringStream ss;
if(m_acceptHasBeenSet)
{
ss << m_accept;
headers.emplace("accept", ss.str());
ss.str("");
}
if(m_customAttributesHasBeenSet)
{
ss << m_customAttributes;
headers.emplace("x-amzn-sagemaker-custom-attributes", ss.str());
ss.str("");
}
if(m_targetModelHasBeenSet)
{
ss << m_targetModel;
headers.emplace("x-amzn-sagemaker-target-model", ss.str());
ss.str("");
}
if(m_targetVariantHasBeenSet)
{
ss << m_targetVariant;
headers.emplace("x-amzn-sagemaker-target-variant", ss.str());
ss.str("");
}
return headers;
}

View File

@@ -0,0 +1,75 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/sagemaker-runtime/model/InvokeEndpointResult.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <utility>
using namespace Aws::SageMakerRuntime::Model;
using namespace Aws::Utils::Stream;
using namespace Aws::Utils;
using namespace Aws;
InvokeEndpointResult::InvokeEndpointResult()
{
}
InvokeEndpointResult::InvokeEndpointResult(InvokeEndpointResult&& toMove) :
m_body(std::move(toMove.m_body)),
m_contentType(std::move(toMove.m_contentType)),
m_invokedProductionVariant(std::move(toMove.m_invokedProductionVariant)),
m_customAttributes(std::move(toMove.m_customAttributes))
{
}
InvokeEndpointResult& InvokeEndpointResult::operator=(InvokeEndpointResult&& toMove)
{
if(this == &toMove)
{
return *this;
}
m_body = std::move(toMove.m_body);
m_contentType = std::move(toMove.m_contentType);
m_invokedProductionVariant = std::move(toMove.m_invokedProductionVariant);
m_customAttributes = std::move(toMove.m_customAttributes);
return *this;
}
InvokeEndpointResult::InvokeEndpointResult(Aws::AmazonWebServiceResult<ResponseStream>&& result)
{
*this = std::move(result);
}
InvokeEndpointResult& InvokeEndpointResult::operator =(Aws::AmazonWebServiceResult<ResponseStream>&& result)
{
m_body = result.TakeOwnershipOfPayload();
const auto& headers = result.GetHeaderValueCollection();
const auto& contentTypeIter = headers.find("content-type");
if(contentTypeIter != headers.end())
{
m_contentType = contentTypeIter->second;
}
const auto& invokedProductionVariantIter = headers.find("x-amzn-invoked-production-variant");
if(invokedProductionVariantIter != headers.end())
{
m_invokedProductionVariant = invokedProductionVariantIter->second;
}
const auto& customAttributesIter = headers.find("x-amzn-sagemaker-custom-attributes");
if(customAttributesIter != headers.end())
{
m_customAttributes = customAttributesIter->second;
}
return *this;
}

View File

@@ -0,0 +1,106 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/sagemaker-runtime/model/ModelError.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace SageMakerRuntime
{
namespace Model
{
ModelError::ModelError() :
m_messageHasBeenSet(false),
m_originalStatusCode(0),
m_originalStatusCodeHasBeenSet(false),
m_originalMessageHasBeenSet(false),
m_logStreamArnHasBeenSet(false)
{
}
ModelError::ModelError(JsonView jsonValue) :
m_messageHasBeenSet(false),
m_originalStatusCode(0),
m_originalStatusCodeHasBeenSet(false),
m_originalMessageHasBeenSet(false),
m_logStreamArnHasBeenSet(false)
{
*this = jsonValue;
}
ModelError& ModelError::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("Message"))
{
m_message = jsonValue.GetString("Message");
m_messageHasBeenSet = true;
}
if(jsonValue.ValueExists("OriginalStatusCode"))
{
m_originalStatusCode = jsonValue.GetInteger("OriginalStatusCode");
m_originalStatusCodeHasBeenSet = true;
}
if(jsonValue.ValueExists("OriginalMessage"))
{
m_originalMessage = jsonValue.GetString("OriginalMessage");
m_originalMessageHasBeenSet = true;
}
if(jsonValue.ValueExists("LogStreamArn"))
{
m_logStreamArn = jsonValue.GetString("LogStreamArn");
m_logStreamArnHasBeenSet = true;
}
return *this;
}
JsonValue ModelError::Jsonize() const
{
JsonValue payload;
if(m_messageHasBeenSet)
{
payload.WithString("Message", m_message);
}
if(m_originalStatusCodeHasBeenSet)
{
payload.WithInteger("OriginalStatusCode", m_originalStatusCode);
}
if(m_originalMessageHasBeenSet)
{
payload.WithString("OriginalMessage", m_originalMessage);
}
if(m_logStreamArnHasBeenSet)
{
payload.WithString("LogStreamArn", m_logStreamArn);
}
return payload;
}
} // namespace Model
} // namespace SageMakerRuntime
} // namespace Aws