/// <summary> /// 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. /// /// /// <para> /// For an overview of Amazon SageMaker, see <a href="http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How /// It Works</a> /// </para> /// /// <para> /// 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. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the InvokeEndpoint service method.</param> /// /// <returns>The response from the InvokeEndpoint service method, as returned by SageMakerRuntime.</returns> /// <exception cref="Amazon.SageMakerRuntime.Model.InternalFailureException"> /// Internal failure occurred. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ModelErrorException"> /// Model (owned by the customer in the container) returned an error 500. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ServiceUnavailableException"> /// Service is unavailable. Try your call again. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ValidationErrorException"> /// Inspect your request and try again. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">REST API Reference for InvokeEndpoint Operation</seealso> public virtual InvokeEndpointResponse InvokeEndpoint(InvokeEndpointRequest request) { var marshaller = InvokeEndpointRequestMarshaller.Instance; var unmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(Invoke <InvokeEndpointRequest, InvokeEndpointResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the InvokeEndpoint operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InvokeEndpoint operation on AmazonSageMakerRuntimeClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndInvokeEndpoint /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">REST API Reference for InvokeEndpoint Operation</seealso> public virtual IAsyncResult BeginInvokeEndpoint(InvokeEndpointRequest request, AsyncCallback callback, object state) { var marshaller = InvokeEndpointRequestMarshaller.Instance; var unmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(BeginInvoke <InvokeEndpointRequest>(request, marshaller, unmarshaller, callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the InvokeEndpoint operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InvokeEndpoint operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">REST API Reference for InvokeEndpoint Operation</seealso> public virtual Task <InvokeEndpointResponse> InvokeEndpointAsync(InvokeEndpointRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = InvokeEndpointRequestMarshaller.Instance; var unmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(InvokeAsync <InvokeEndpointRequest, InvokeEndpointResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// 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. /// /// /// <para> /// 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>. /// </para> /// /// <para> /// 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. /// </para> /// /// <para> /// 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>. /// </para> /// /// <para> /// 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. /// </para> /// <note> /// <para> /// 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. /// </para> /// </note> /// </summary> /// <param name="request">Container for the necessary parameters to execute the InvokeEndpoint service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the InvokeEndpoint service method, as returned by SageMakerRuntime.</returns> /// <exception cref="Amazon.SageMakerRuntime.Model.InternalFailureException"> /// An internal failure occurred. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ModelErrorException"> /// Model (owned by the customer in the container) returned 4xx or 5xx error code. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ServiceUnavailableException"> /// The service is unavailable. Try your call again. /// </exception> /// <exception cref="Amazon.SageMakerRuntime.Model.ValidationErrorException"> /// Inspect your request and try again. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">REST API Reference for InvokeEndpoint Operation</seealso> public virtual Task <InvokeEndpointResponse> InvokeEndpointAsync(InvokeEndpointRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = InvokeEndpointRequestMarshaller.Instance; options.ResponseUnmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(InvokeAsync <InvokeEndpointResponse>(request, options, cancellationToken)); }
internal virtual InvokeEndpointResponse InvokeEndpoint(InvokeEndpointRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = InvokeEndpointRequestMarshaller.Instance; options.ResponseUnmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(Invoke <InvokeEndpointResponse>(request, options)); }
/// <summary> /// Initiates the asynchronous execution of the InvokeEndpoint operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InvokeEndpoint operation on AmazonSageMakerRuntimeClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndInvokeEndpoint /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint">REST API Reference for InvokeEndpoint Operation</seealso> public virtual IAsyncResult BeginInvokeEndpoint(InvokeEndpointRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = InvokeEndpointRequestMarshaller.Instance; options.ResponseUnmarshaller = InvokeEndpointResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
static async Task <byte[]> TestSageMakerEndpoint() { string awsAccessKey = ""; string awsSecretKey = ""; byte[] content = Encoding.ASCII.GetBytes("{\"instances\": [{\"data\": \"abandon\"}]}"); InvokeEndpointRequest request = new InvokeEndpointRequest(); request.Accept = "application/json"; request.ContentType = "application/json"; request.Body = new MemoryStream(content); request.EndpointName = "Seq2SeqEndpoint-2019-05-09-10-10-22"; AmazonSageMakerRuntimeClient client = new AmazonSageMakerRuntimeClient(awsAccessKey, awsSecretKey, RegionEndpoint.USEast1); InvokeEndpointResponse response = await client.InvokeEndpointAsync(request); return(response.Body.ToArray()); }
public override async Task <APIGatewayProxyResponse> ProcessMessageAsync(APIGatewayProxyRequest request, ILambdaContext context) { // TODO: add business logic LogInfo("Call the InvokeEndpoint method"); LogInfo(_sagemakerEndpoint); LogInfo(request.Body); var sagemakerRequest = new InvokeEndpointRequest { Body = request.Body.ToStream(), ContentType = "application/json", EndpointName = _sagemakerEndpoint }; var response = await _runtimeClient.InvokeEndpointAsync(sagemakerRequest); var responseBody = response.Body.AsString(); return(new APIGatewayProxyResponse { StatusCode = 200, Body = responseBody }); }