api.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package sagemakerruntime
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/awsutil"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. )
  8. const opInvokeEndpoint = "InvokeEndpoint"
  9. // InvokeEndpointRequest generates a "aws/request.Request" representing the
  10. // client's request for the InvokeEndpoint operation. The "output" return
  11. // value will be populated with the request's response once the request completes
  12. // successfully.
  13. //
  14. // Use "Send" method on the returned Request to send the API call to the service.
  15. // the "output" return value is not valid until after Send returns without error.
  16. //
  17. // See InvokeEndpoint for more information on using the InvokeEndpoint
  18. // API call, and error handling.
  19. //
  20. // This method is useful when you want to inject custom logic or configuration
  21. // into the SDK's request lifecycle. Such as custom headers, or retry logic.
  22. //
  23. //
  24. // // Example sending a request using the InvokeEndpointRequest method.
  25. // req, resp := client.InvokeEndpointRequest(params)
  26. //
  27. // err := req.Send()
  28. // if err == nil { // resp is now filled
  29. // fmt.Println(resp)
  30. // }
  31. //
  32. // See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint
  33. func (c *SageMakerRuntime) InvokeEndpointRequest(input *InvokeEndpointInput) (req *request.Request, output *InvokeEndpointOutput) {
  34. op := &request.Operation{
  35. Name: opInvokeEndpoint,
  36. HTTPMethod: "POST",
  37. HTTPPath: "/endpoints/{EndpointName}/invocations",
  38. }
  39. if input == nil {
  40. input = &InvokeEndpointInput{}
  41. }
  42. output = &InvokeEndpointOutput{}
  43. req = c.newRequest(op, input, output)
  44. return
  45. }
  46. // InvokeEndpoint API operation for Amazon SageMaker Runtime.
  47. //
  48. // After you deploy a model into production using Amazon SageMaker hosting services,
  49. // your client applications use this API to get inferences from the model hosted
  50. // at the specified endpoint.
  51. //
  52. // For an overview of Amazon SageMaker, see How It Works (http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html).
  53. //
  54. // Amazon SageMaker strips all POST headers except those supported by the API.
  55. // Amazon SageMaker might add additional headers. You should not rely on the
  56. // behavior of headers outside those enumerated in the request syntax.
  57. //
  58. // Cals to InvokeEndpoint are authenticated by using AWS Signature Version 4.
  59. // For information, see Authenticating Requests (AWS Signature Version 4) (http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html)
  60. // in the Amazon S3 API Reference.
  61. //
  62. // Endpoints are scoped to an individual account, and are not public. The URL
  63. // does not contain the account ID, but Amazon SageMaker determines the account
  64. // ID from the authentication token that is supplied by the caller.
  65. //
  66. // Returns awserr.Error for service API and SDK errors. Use runtime type assertions
  67. // with awserr.Error's Code and Message methods to get detailed information about
  68. // the error.
  69. //
  70. // See the AWS API reference guide for Amazon SageMaker Runtime's
  71. // API operation InvokeEndpoint for usage and error information.
  72. //
  73. // Returned Error Codes:
  74. // * ErrCodeInternalFailure "InternalFailure"
  75. // An internal failure occurred.
  76. //
  77. // * ErrCodeServiceUnavailable "ServiceUnavailable"
  78. // The service is unavailable. Try your call again.
  79. //
  80. // * ErrCodeValidationError "ValidationError"
  81. // Inspect your request and try again.
  82. //
  83. // * ErrCodeModelError "ModelError"
  84. // Model (owned by the customer in the container) returned an error 500.
  85. //
  86. // See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13/InvokeEndpoint
  87. func (c *SageMakerRuntime) InvokeEndpoint(input *InvokeEndpointInput) (*InvokeEndpointOutput, error) {
  88. req, out := c.InvokeEndpointRequest(input)
  89. return out, req.Send()
  90. }
  91. // InvokeEndpointWithContext is the same as InvokeEndpoint with the addition of
  92. // the ability to pass a context and additional request options.
  93. //
  94. // See InvokeEndpoint for details on how to use this API operation.
  95. //
  96. // The context must be non-nil and will be used for request cancellation. If
  97. // the context is nil a panic will occur. In the future the SDK may create
  98. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  99. // for more information on using Contexts.
  100. func (c *SageMakerRuntime) InvokeEndpointWithContext(ctx aws.Context, input *InvokeEndpointInput, opts ...request.Option) (*InvokeEndpointOutput, error) {
  101. req, out := c.InvokeEndpointRequest(input)
  102. req.SetContext(ctx)
  103. req.ApplyOptions(opts...)
  104. return out, req.Send()
  105. }
  106. type InvokeEndpointInput struct {
  107. _ struct{} `type:"structure" payload:"Body"`
  108. // The desired MIME type of the inference in the response.
  109. Accept *string `location:"header" locationName:"Accept" type:"string"`
  110. // Provides input data, in the format specified in the ContentType request header.
  111. // Amazon SageMaker passes all of the data in the body to the model.
  112. //
  113. // For information about the format of the request body, see Common Data Formats—Inference
  114. // (http://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html).
  115. //
  116. // Body is a required field
  117. Body []byte `type:"blob" required:"true" sensitive:"true"`
  118. // The MIME type of the input data in the request body.
  119. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  120. CustomAttributes *string `location:"header" locationName:"X-Amzn-SageMaker-Custom-Attributes" type:"string" sensitive:"true"`
  121. // The name of the endpoint that you specified when you created the endpoint
  122. // using the CreateEndpoint (http://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html)
  123. // API.
  124. //
  125. // EndpointName is a required field
  126. EndpointName *string `location:"uri" locationName:"EndpointName" type:"string" required:"true"`
  127. }
  128. // String returns the string representation
  129. func (s InvokeEndpointInput) String() string {
  130. return awsutil.Prettify(s)
  131. }
  132. // GoString returns the string representation
  133. func (s InvokeEndpointInput) GoString() string {
  134. return s.String()
  135. }
  136. // Validate inspects the fields of the type to determine if they are valid.
  137. func (s *InvokeEndpointInput) Validate() error {
  138. invalidParams := request.ErrInvalidParams{Context: "InvokeEndpointInput"}
  139. if s.Body == nil {
  140. invalidParams.Add(request.NewErrParamRequired("Body"))
  141. }
  142. if s.EndpointName == nil {
  143. invalidParams.Add(request.NewErrParamRequired("EndpointName"))
  144. }
  145. if s.EndpointName != nil && len(*s.EndpointName) < 1 {
  146. invalidParams.Add(request.NewErrParamMinLen("EndpointName", 1))
  147. }
  148. if invalidParams.Len() > 0 {
  149. return invalidParams
  150. }
  151. return nil
  152. }
  153. // SetAccept sets the Accept field's value.
  154. func (s *InvokeEndpointInput) SetAccept(v string) *InvokeEndpointInput {
  155. s.Accept = &v
  156. return s
  157. }
  158. // SetBody sets the Body field's value.
  159. func (s *InvokeEndpointInput) SetBody(v []byte) *InvokeEndpointInput {
  160. s.Body = v
  161. return s
  162. }
  163. // SetContentType sets the ContentType field's value.
  164. func (s *InvokeEndpointInput) SetContentType(v string) *InvokeEndpointInput {
  165. s.ContentType = &v
  166. return s
  167. }
  168. // SetCustomAttributes sets the CustomAttributes field's value.
  169. func (s *InvokeEndpointInput) SetCustomAttributes(v string) *InvokeEndpointInput {
  170. s.CustomAttributes = &v
  171. return s
  172. }
  173. // SetEndpointName sets the EndpointName field's value.
  174. func (s *InvokeEndpointInput) SetEndpointName(v string) *InvokeEndpointInput {
  175. s.EndpointName = &v
  176. return s
  177. }
  178. type InvokeEndpointOutput struct {
  179. _ struct{} `type:"structure" payload:"Body"`
  180. // Includes the inference provided by the model.
  181. //
  182. // For information about the format of the response body, see Common Data Formats—Inference
  183. // (http://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html).
  184. //
  185. // Body is a required field
  186. Body []byte `type:"blob" required:"true" sensitive:"true"`
  187. // The MIME type of the inference returned in the response body.
  188. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  189. CustomAttributes *string `location:"header" locationName:"X-Amzn-SageMaker-Custom-Attributes" type:"string" sensitive:"true"`
  190. // Identifies the production variant that was invoked.
  191. InvokedProductionVariant *string `location:"header" locationName:"x-Amzn-Invoked-Production-Variant" type:"string"`
  192. }
  193. // String returns the string representation
  194. func (s InvokeEndpointOutput) String() string {
  195. return awsutil.Prettify(s)
  196. }
  197. // GoString returns the string representation
  198. func (s InvokeEndpointOutput) GoString() string {
  199. return s.String()
  200. }
  201. // SetBody sets the Body field's value.
  202. func (s *InvokeEndpointOutput) SetBody(v []byte) *InvokeEndpointOutput {
  203. s.Body = v
  204. return s
  205. }
  206. // SetContentType sets the ContentType field's value.
  207. func (s *InvokeEndpointOutput) SetContentType(v string) *InvokeEndpointOutput {
  208. s.ContentType = &v
  209. return s
  210. }
  211. // SetCustomAttributes sets the CustomAttributes field's value.
  212. func (s *InvokeEndpointOutput) SetCustomAttributes(v string) *InvokeEndpointOutput {
  213. s.CustomAttributes = &v
  214. return s
  215. }
  216. // SetInvokedProductionVariant sets the InvokedProductionVariant field's value.
  217. func (s *InvokeEndpointOutput) SetInvokedProductionVariant(v string) *InvokeEndpointOutput {
  218. s.InvokedProductionVariant = &v
  219. return s
  220. }