// // Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file is distributed // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. // #import "AWSSageMakerRuntimeResources.h" #import @interface AWSSageMakerRuntimeResources () @property (nonatomic, strong) NSDictionary *definitionDictionary; @end @implementation AWSSageMakerRuntimeResources + (instancetype)sharedInstance { static AWSSageMakerRuntimeResources *_sharedResources = nil; static dispatch_once_t once_token; dispatch_once(&once_token, ^{ _sharedResources = [AWSSageMakerRuntimeResources new]; }); return _sharedResources; } - (NSDictionary *)JSONObject { return self.definitionDictionary; } - (instancetype)init { if (self = [super init]) { //init method NSError *error = nil; _definitionDictionary = [NSJSONSerialization JSONObjectWithData:[[self definitionString] dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error]; if (_definitionDictionary == nil) { if (error) { AWSDDLogError(@"Failed to parse JSON service definition: %@",error); } } } return self; } - (NSString *)definitionString { return @"{\ \"version\":\"2.0\",\ \"metadata\":{\ \"apiVersion\":\"2017-05-13\",\ \"endpointPrefix\":\"runtime.sagemaker\",\ \"jsonVersion\":\"1.1\",\ \"protocol\":\"rest-json\",\ \"serviceFullName\":\"Amazon SageMaker Runtime\",\ \"serviceId\":\"SageMaker Runtime\",\ \"signatureVersion\":\"v4\",\ \"signingName\":\"sagemaker\",\ \"uid\":\"runtime.sagemaker-2017-05-13\"\ },\ \"operations\":{\ \"InvokeEndpoint\":{\ \"name\":\"InvokeEndpoint\",\ \"http\":{\ \"method\":\"POST\",\ \"requestUri\":\"/endpoints/{EndpointName}/invocations\"\ },\ \"input\":{\"shape\":\"InvokeEndpointInput\"},\ \"output\":{\"shape\":\"InvokeEndpointOutput\"},\ \"errors\":[\ {\"shape\":\"InternalFailure\"},\ {\"shape\":\"ServiceUnavailable\"},\ {\"shape\":\"ValidationError\"},\ {\"shape\":\"ModelError\"},\ {\"shape\":\"InternalDependencyException\"},\ {\"shape\":\"ModelNotReadyException\"}\ ],\ \"documentation\":\"

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.

For an overview of Amazon SageMaker, see How It Works.

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.

Calls to InvokeEndpoint are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.

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 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.

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.

\"\ },\ \"InvokeEndpointAsync\":{\ \"name\":\"InvokeEndpointAsync\",\ \"http\":{\ \"method\":\"POST\",\ \"requestUri\":\"/endpoints/{EndpointName}/async-invocations\",\ \"responseCode\":202\ },\ \"input\":{\"shape\":\"InvokeEndpointAsyncInput\"},\ \"output\":{\"shape\":\"InvokeEndpointAsyncOutput\"},\ \"errors\":[\ {\"shape\":\"InternalFailure\"},\ {\"shape\":\"ServiceUnavailable\"},\ {\"shape\":\"ValidationError\"}\ ],\ \"documentation\":\"

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 in an asynchronous manner.

Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it.

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.

Calls to InvokeEndpointAsync are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.

\"\ }\ },\ \"shapes\":{\ \"BodyBlob\":{\ \"type\":\"blob\",\ \"max\":6291456,\ \"sensitive\":true\ },\ \"CustomAttributesHeader\":{\ \"type\":\"string\",\ \"max\":1024,\ \"pattern\":\"\\\\p{ASCII}*\",\ \"sensitive\":true\ },\ \"EnableExplanationsHeader\":{\ \"type\":\"string\",\ \"max\":64,\ \"min\":1,\ \"pattern\":\".*\"\ },\ \"EndpointName\":{\ \"type\":\"string\",\ \"max\":63,\ \"pattern\":\"^[a-zA-Z0-9](-*[a-zA-Z0-9])*\"\ },\ \"Header\":{\ \"type\":\"string\",\ \"max\":1024,\ \"pattern\":\"\\\\p{ASCII}*\"\ },\ \"InferenceId\":{\ \"type\":\"string\",\ \"max\":64,\ \"min\":1,\ \"pattern\":\"\\\\A\\\\S[\\\\p{Print}]*\\\\z\"\ },\ \"InputLocationHeader\":{\ \"type\":\"string\",\ \"max\":1024,\ \"min\":1,\ \"pattern\":\"^(https|s3)://([^/]+)/?(.*)$\"\ },\ \"InternalDependencyException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"}\ },\ \"documentation\":\"

Your request caused an exception with an internal dependency. Contact customer support.

\",\ \"error\":{\"httpStatusCode\":530},\ \"exception\":true,\ \"fault\":true,\ \"synthetic\":true\ },\ \"InternalFailure\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"}\ },\ \"documentation\":\"

An internal failure occurred.

\",\ \"error\":{\"httpStatusCode\":500},\ \"exception\":true,\ \"fault\":true,\ \"synthetic\":true\ },\ \"InvocationTimeoutSecondsHeader\":{\ \"type\":\"integer\",\ \"max\":3600,\ \"min\":1\ },\ \"InvokeEndpointAsyncInput\":{\ \"type\":\"structure\",\ \"required\":[\ \"EndpointName\",\ \"InputLocation\"\ ],\ \"members\":{\ \"EndpointName\":{\ \"shape\":\"EndpointName\",\ \"documentation\":\"

The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.

\",\ \"location\":\"uri\",\ \"locationName\":\"EndpointName\"\ },\ \"ContentType\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The MIME type of the input data in the request body.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Content-Type\"\ },\ \"Accept\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The desired MIME type of the inference in the response.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Accept\"\ },\ \"CustomAttributes\":{\ \"shape\":\"CustomAttributesHeader\",\ \"documentation\":\"

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 Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).

The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.

This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Custom-Attributes\"\ },\ \"InferenceId\":{\ \"shape\":\"InferenceId\",\ \"documentation\":\"

The identifier for the inference request. Amazon SageMaker will generate an identifier for you if none is specified.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Inference-Id\"\ },\ \"InputLocation\":{\ \"shape\":\"InputLocationHeader\",\ \"documentation\":\"

The Amazon S3 URI where the inference request payload is stored.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-InputLocation\"\ },\ \"RequestTTLSeconds\":{\ \"shape\":\"RequestTTLSecondsHeader\",\ \"documentation\":\"

Maximum age in seconds a request can be in the queue before it is marked as expired. The default is 6 hours, or 21,600 seconds.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-RequestTTLSeconds\"\ },\ \"InvocationTimeoutSeconds\":{\ \"shape\":\"InvocationTimeoutSecondsHeader\",\ \"documentation\":\"

Maximum amount of time in seconds a request can be processed before it is marked as expired. The default is 15 minutes, or 900 seconds.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-InvocationTimeoutSeconds\"\ }\ }\ },\ \"InvokeEndpointAsyncOutput\":{\ \"type\":\"structure\",\ \"members\":{\ \"InferenceId\":{\ \"shape\":\"Header\",\ \"documentation\":\"

Identifier for an inference request. This will be the same as the InferenceId specified in the input. Amazon SageMaker will generate an identifier for you if you do not specify one.

\"\ },\ \"OutputLocation\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The Amazon S3 URI where the inference response payload is stored.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-OutputLocation\"\ },\ \"FailureLocation\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The Amazon S3 URI where the inference failure response payload is stored.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-FailureLocation\"\ }\ }\ },\ \"InvokeEndpointInput\":{\ \"type\":\"structure\",\ \"required\":[\ \"EndpointName\",\ \"Body\"\ ],\ \"members\":{\ \"EndpointName\":{\ \"shape\":\"EndpointName\",\ \"documentation\":\"

The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.

\",\ \"location\":\"uri\",\ \"locationName\":\"EndpointName\"\ },\ \"Body\":{\ \"shape\":\"BodyBlob\",\ \"documentation\":\"

Provides input data, in the format specified in the ContentType request header. Amazon SageMaker passes all of the data in the body to the model.

For information about the format of the request body, see Common Data Formats-Inference.

\"\ },\ \"ContentType\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The MIME type of the input data in the request body.

\",\ \"location\":\"header\",\ \"locationName\":\"Content-Type\"\ },\ \"Accept\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The desired MIME type of the inference in the response.

\",\ \"location\":\"header\",\ \"locationName\":\"Accept\"\ },\ \"CustomAttributes\":{\ \"shape\":\"CustomAttributesHeader\",\ \"documentation\":\"

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 Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).

The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.

This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Custom-Attributes\"\ },\ \"TargetModel\":{\ \"shape\":\"TargetModelHeader\",\ \"documentation\":\"

The model to request for inference when invoking a multi-model endpoint.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Target-Model\"\ },\ \"TargetVariant\":{\ \"shape\":\"TargetVariantHeader\",\ \"documentation\":\"

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.

For information about how to use variant targeting to perform a/b testing, see Test models in production

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Target-Variant\"\ },\ \"TargetContainerHostname\":{\ \"shape\":\"TargetContainerHostnameHeader\",\ \"documentation\":\"

If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Target-Container-Hostname\"\ },\ \"InferenceId\":{\ \"shape\":\"InferenceId\",\ \"documentation\":\"

If you provide a value, it is added to the captured data when you enable data capture on the endpoint. For information about data capture, see Capture Data.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Inference-Id\"\ },\ \"EnableExplanations\":{\ \"shape\":\"EnableExplanationsHeader\",\ \"documentation\":\"

An optional JMESPath expression used to override the EnableExplanations parameter of the ClarifyExplainerConfig API. See the EnableExplanations section in the developer guide for more information.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Enable-Explanations\"\ }\ },\ \"payload\":\"Body\"\ },\ \"InvokeEndpointOutput\":{\ \"type\":\"structure\",\ \"required\":[\"Body\"],\ \"members\":{\ \"Body\":{\ \"shape\":\"BodyBlob\",\ \"documentation\":\"

Includes the inference provided by the model.

For information about the format of the response body, see Common Data Formats-Inference.

If the explainer is activated, the body includes the explanations provided by the model. For more information, see the Response section under Invoke the Endpoint in the Developer Guide.

\"\ },\ \"ContentType\":{\ \"shape\":\"Header\",\ \"documentation\":\"

The MIME type of the inference returned in the response body.

\",\ \"location\":\"header\",\ \"locationName\":\"Content-Type\"\ },\ \"InvokedProductionVariant\":{\ \"shape\":\"Header\",\ \"documentation\":\"

Identifies the production variant that was invoked.

\",\ \"location\":\"header\",\ \"locationName\":\"x-Amzn-Invoked-Production-Variant\"\ },\ \"CustomAttributes\":{\ \"shape\":\"CustomAttributesHeader\",\ \"documentation\":\"

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 CustomAttributes 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 Section 3.3.6. Field Value Components 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.

The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.

This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.

\",\ \"location\":\"header\",\ \"locationName\":\"X-Amzn-SageMaker-Custom-Attributes\"\ }\ },\ \"payload\":\"Body\"\ },\ \"LogStreamArn\":{\"type\":\"string\"},\ \"Message\":{\ \"type\":\"string\",\ \"max\":2048\ },\ \"ModelError\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"},\ \"OriginalStatusCode\":{\ \"shape\":\"StatusCode\",\ \"documentation\":\"

Original status code.

\"\ },\ \"OriginalMessage\":{\ \"shape\":\"Message\",\ \"documentation\":\"

Original message.

\"\ },\ \"LogStreamArn\":{\ \"shape\":\"LogStreamArn\",\ \"documentation\":\"

The Amazon Resource Name (ARN) of the log stream.

\"\ }\ },\ \"documentation\":\"

Model (owned by the customer in the container) returned 4xx or 5xx error code.

\",\ \"error\":{\"httpStatusCode\":424},\ \"exception\":true\ },\ \"ModelNotReadyException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"}\ },\ \"documentation\":\"

Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.

\",\ \"error\":{\"httpStatusCode\":429},\ \"exception\":true,\ \"synthetic\":true\ },\ \"RequestTTLSecondsHeader\":{\ \"type\":\"integer\",\ \"max\":21600,\ \"min\":60\ },\ \"ServiceUnavailable\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"}\ },\ \"documentation\":\"

The service is unavailable. Try your call again.

\",\ \"error\":{\"httpStatusCode\":503},\ \"exception\":true,\ \"fault\":true,\ \"synthetic\":true\ },\ \"StatusCode\":{\"type\":\"integer\"},\ \"TargetContainerHostnameHeader\":{\ \"type\":\"string\",\ \"max\":63,\ \"pattern\":\"^[a-zA-Z0-9](-*[a-zA-Z0-9])*\"\ },\ \"TargetModelHeader\":{\ \"type\":\"string\",\ \"max\":1024,\ \"min\":1,\ \"pattern\":\"\\\\A\\\\S[\\\\p{Print}]*\\\\z\"\ },\ \"TargetVariantHeader\":{\ \"type\":\"string\",\ \"max\":63,\ \"pattern\":\"^[a-zA-Z0-9](-*[a-zA-Z0-9])*\"\ },\ \"ValidationError\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"Message\"}\ },\ \"documentation\":\"

Inspect your request and try again.

\",\ \"error\":{\"httpStatusCode\":400},\ \"exception\":true,\ \"synthetic\":true\ }\ },\ \"documentation\":\"

The Amazon SageMaker runtime API.

\"\ }\ "; } @end