1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package sagemakerruntime 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/smithy-go/middleware" 10 smithyhttp "github.com/aws/smithy-go/transport/http" 11) 12 13// After you deploy a model into production using Amazon SageMaker hosting 14// services, your client applications use this API to get inferences from the model 15// hosted at the specified endpoint. For an overview of Amazon SageMaker, see How 16// It Works (https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html). 17// Amazon SageMaker strips all POST headers except those supported by the API. 18// Amazon SageMaker might add additional headers. You should not rely on the 19// behavior of headers outside those enumerated in the request syntax. Calls to 20// InvokeEndpoint are authenticated by using AWS Signature Version 4. For 21// information, see Authenticating Requests (AWS Signature Version 4) 22// (https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) 23// in the Amazon S3 API Reference. A customer's model containers must respond to 24// requests within 60 seconds. The model itself can have a maximum processing time 25// of 60 seconds before responding to invocations. If your model is going to take 26// 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 27// seconds. Endpoints are scoped to an individual account, and are not public. The 28// URL does not contain the account ID, but Amazon SageMaker determines the account 29// ID from the authentication token that is supplied by the caller. 30func (c *Client) InvokeEndpoint(ctx context.Context, params *InvokeEndpointInput, optFns ...func(*Options)) (*InvokeEndpointOutput, error) { 31 if params == nil { 32 params = &InvokeEndpointInput{} 33 } 34 35 result, metadata, err := c.invokeOperation(ctx, "InvokeEndpoint", params, optFns, addOperationInvokeEndpointMiddlewares) 36 if err != nil { 37 return nil, err 38 } 39 40 out := result.(*InvokeEndpointOutput) 41 out.ResultMetadata = metadata 42 return out, nil 43} 44 45type InvokeEndpointInput struct { 46 47 // Provides input data, in the format specified in the ContentType request header. 48 // Amazon SageMaker passes all of the data in the body to the model. For 49 // information about the format of the request body, see Common Data 50 // Formats-Inference 51 // (https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html). 52 // 53 // This member is required. 54 Body []byte 55 56 // The name of the endpoint that you specified when you created the endpoint using 57 // the CreateEndpoint 58 // (https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html) API. 59 // 60 // This member is required. 61 EndpointName *string 62 63 // The desired MIME type of the inference in the response. 64 Accept *string 65 66 // The MIME type of the input data in the request body. 67 ContentType *string 68 69 // Provides additional information about a request for an inference submitted to a 70 // model hosted at an Amazon SageMaker endpoint. The information is an opaque value 71 // that is forwarded verbatim. You could use this value, for example, to provide an 72 // ID that you can use to track a request or to provide other metadata that a 73 // service endpoint was programmed to process. The value must consist of no more 74 // than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value 75 // Components (https://tools.ietf.org/html/rfc7230#section-3.2.6) of the Hypertext 76 // Transfer Protocol (HTTP/1.1). The code in your model is responsible for setting 77 // or updating any custom attributes in the response. If your code does not set 78 // this value in the response, an empty value is returned. For example, if a custom 79 // attribute represents the trace ID, your model can prepend the custom attribute 80 // with Trace ID: in your post-processing function. This feature is currently 81 // supported in the AWS SDKs but not in the Amazon SageMaker Python SDK. 82 CustomAttributes *string 83 84 // If you provide a value, it is added to the captured data when you enable data 85 // capture on the endpoint. For information about data capture, see Capture Data 86 // (https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html). 87 InferenceId *string 88 89 // If the endpoint hosts multiple containers and is configured to use direct 90 // invocation, this parameter specifies the host name of the container to invoke. 91 TargetContainerHostname *string 92 93 // The model to request for inference when invoking a multi-model endpoint. 94 TargetModel *string 95 96 // Specify the production variant to send the inference request to when invoking an 97 // endpoint that is running two or more variants. Note that this parameter 98 // overrides the default behavior for the endpoint, which is to distribute the 99 // invocation traffic based on the variant weights. For information about how to 100 // use variant targeting to perform a/b testing, see Test models in production 101 // (https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html) 102 TargetVariant *string 103} 104 105type InvokeEndpointOutput struct { 106 107 // Includes the inference provided by the model. For information about the format 108 // of the response body, see Common Data Formats-Inference 109 // (https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html). 110 // 111 // This member is required. 112 Body []byte 113 114 // The MIME type of the inference returned in the response body. 115 ContentType *string 116 117 // Provides additional information in the response about the inference returned by 118 // a model hosted at an Amazon SageMaker endpoint. The information is an opaque 119 // value that is forwarded verbatim. You could use this value, for example, to 120 // return an ID received in the CustomAttributes header of a request or other 121 // metadata that a service endpoint was programmed to produce. The value must 122 // consist of no more than 1024 visible US-ASCII characters as specified in Section 123 // 3.3.6. Field Value Components 124 // (https://tools.ietf.org/html/rfc7230#section-3.2.6) of the Hypertext Transfer 125 // Protocol (HTTP/1.1). If the customer wants the custom attribute returned, the 126 // model must set the custom attribute to be included on the way back. The code in 127 // your model is responsible for setting or updating any custom attributes in the 128 // response. If your code does not set this value in the response, an empty value 129 // is returned. For example, if a custom attribute represents the trace ID, your 130 // model can prepend the custom attribute with Trace ID: in your post-processing 131 // function. This feature is currently supported in the AWS SDKs but not in the 132 // Amazon SageMaker Python SDK. 133 CustomAttributes *string 134 135 // Identifies the production variant that was invoked. 136 InvokedProductionVariant *string 137 138 // Metadata pertaining to the operation's result. 139 ResultMetadata middleware.Metadata 140} 141 142func addOperationInvokeEndpointMiddlewares(stack *middleware.Stack, options Options) (err error) { 143 err = stack.Serialize.Add(&awsRestjson1_serializeOpInvokeEndpoint{}, middleware.After) 144 if err != nil { 145 return err 146 } 147 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpInvokeEndpoint{}, middleware.After) 148 if err != nil { 149 return err 150 } 151 if err = addSetLoggerMiddleware(stack, options); err != nil { 152 return err 153 } 154 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 155 return err 156 } 157 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 158 return err 159 } 160 if err = addResolveEndpointMiddleware(stack, options); err != nil { 161 return err 162 } 163 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 164 return err 165 } 166 if err = addRetryMiddlewares(stack, options); err != nil { 167 return err 168 } 169 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 170 return err 171 } 172 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 173 return err 174 } 175 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 176 return err 177 } 178 if err = addClientUserAgent(stack); err != nil { 179 return err 180 } 181 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 182 return err 183 } 184 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 185 return err 186 } 187 if err = addOpInvokeEndpointValidationMiddleware(stack); err != nil { 188 return err 189 } 190 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opInvokeEndpoint(options.Region), middleware.Before); err != nil { 191 return err 192 } 193 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 194 return err 195 } 196 if err = addResponseErrorMiddleware(stack); err != nil { 197 return err 198 } 199 if err = addRequestResponseLogging(stack, options); err != nil { 200 return err 201 } 202 return nil 203} 204 205func newServiceMetadataMiddleware_opInvokeEndpoint(region string) *awsmiddleware.RegisterServiceMetadata { 206 return &awsmiddleware.RegisterServiceMetadata{ 207 Region: region, 208 ServiceID: ServiceID, 209 SigningName: "sagemaker", 210 OperationName: "InvokeEndpoint", 211 } 212} 213