aws_sdk_sagemakerruntime/operation/invoke_endpoint/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::invoke_endpoint::_invoke_endpoint_output::InvokeEndpointOutputBuilder;
3
4pub use crate::operation::invoke_endpoint::_invoke_endpoint_input::InvokeEndpointInputBuilder;
5
6impl crate::operation::invoke_endpoint::builders::InvokeEndpointInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::invoke_endpoint::InvokeEndpointOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::invoke_endpoint::InvokeEndpointError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.invoke_endpoint();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `InvokeEndpoint`.
24///
25/// <p>After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.</p>
26/// <p>For an overview of Amazon SageMaker AI, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It Works</a>.</p>
27/// <p>Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.</p>
28/// <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API Reference</i>.</p>
29/// <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 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><note>
30/// <p>Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker AI determines the account ID from the authentication token that is supplied by the caller.</p>
31/// </note>
32#[derive(::std::clone::Clone, ::std::fmt::Debug)]
33pub struct InvokeEndpointFluentBuilder {
34 handle: ::std::sync::Arc<crate::client::Handle>,
35 inner: crate::operation::invoke_endpoint::builders::InvokeEndpointInputBuilder,
36 config_override: ::std::option::Option<crate::config::Builder>,
37}
38impl
39 crate::client::customize::internal::CustomizableSend<
40 crate::operation::invoke_endpoint::InvokeEndpointOutput,
41 crate::operation::invoke_endpoint::InvokeEndpointError,
42 > for InvokeEndpointFluentBuilder
43{
44 fn send(
45 self,
46 config_override: crate::config::Builder,
47 ) -> crate::client::customize::internal::BoxFuture<
48 crate::client::customize::internal::SendResult<
49 crate::operation::invoke_endpoint::InvokeEndpointOutput,
50 crate::operation::invoke_endpoint::InvokeEndpointError,
51 >,
52 > {
53 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
54 }
55}
56impl InvokeEndpointFluentBuilder {
57 /// Creates a new `InvokeEndpointFluentBuilder`.
58 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
59 Self {
60 handle,
61 inner: ::std::default::Default::default(),
62 config_override: ::std::option::Option::None,
63 }
64 }
65 /// Access the InvokeEndpoint as a reference.
66 pub fn as_input(&self) -> &crate::operation::invoke_endpoint::builders::InvokeEndpointInputBuilder {
67 &self.inner
68 }
69 /// Sends the request and returns the response.
70 ///
71 /// If an error occurs, an `SdkError` will be returned with additional details that
72 /// can be matched against.
73 ///
74 /// By default, any retryable failures will be retried twice. Retry behavior
75 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
76 /// set when configuring the client.
77 pub async fn send(
78 self,
79 ) -> ::std::result::Result<
80 crate::operation::invoke_endpoint::InvokeEndpointOutput,
81 ::aws_smithy_runtime_api::client::result::SdkError<
82 crate::operation::invoke_endpoint::InvokeEndpointError,
83 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
84 >,
85 > {
86 let input = self
87 .inner
88 .build()
89 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
90 let runtime_plugins = crate::operation::invoke_endpoint::InvokeEndpoint::operation_runtime_plugins(
91 self.handle.runtime_plugins.clone(),
92 &self.handle.conf,
93 self.config_override,
94 );
95 crate::operation::invoke_endpoint::InvokeEndpoint::orchestrate(&runtime_plugins, input).await
96 }
97
98 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
99 pub fn customize(
100 self,
101 ) -> crate::client::customize::CustomizableOperation<
102 crate::operation::invoke_endpoint::InvokeEndpointOutput,
103 crate::operation::invoke_endpoint::InvokeEndpointError,
104 Self,
105 > {
106 crate::client::customize::CustomizableOperation::new(self)
107 }
108 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
109 self.set_config_override(::std::option::Option::Some(config_override.into()));
110 self
111 }
112
113 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
114 self.config_override = config_override;
115 self
116 }
117 /// <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>
118 pub fn endpoint_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
119 self.inner = self.inner.endpoint_name(input.into());
120 self
121 }
122 /// <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>
123 pub fn set_endpoint_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
124 self.inner = self.inner.set_endpoint_name(input);
125 self
126 }
127 /// <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>
128 pub fn get_endpoint_name(&self) -> &::std::option::Option<::std::string::String> {
129 self.inner.get_endpoint_name()
130 }
131 /// <p>Provides input data, in the format specified in the <code>ContentType</code> request header. Amazon SageMaker AI passes all of the data in the body to the model.</p>
132 /// <p>For information about the format of the request body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p>
133 pub fn body(mut self, input: ::aws_smithy_types::Blob) -> Self {
134 self.inner = self.inner.body(input);
135 self
136 }
137 /// <p>Provides input data, in the format specified in the <code>ContentType</code> request header. Amazon SageMaker AI passes all of the data in the body to the model.</p>
138 /// <p>For information about the format of the request body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p>
139 pub fn set_body(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
140 self.inner = self.inner.set_body(input);
141 self
142 }
143 /// <p>Provides input data, in the format specified in the <code>ContentType</code> request header. Amazon SageMaker AI passes all of the data in the body to the model.</p>
144 /// <p>For information about the format of the request body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p>
145 pub fn get_body(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
146 self.inner.get_body()
147 }
148 /// <p>The MIME type of the input data in the request body.</p>
149 pub fn content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
150 self.inner = self.inner.content_type(input.into());
151 self
152 }
153 /// <p>The MIME type of the input data in the request body.</p>
154 pub fn set_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
155 self.inner = self.inner.set_content_type(input);
156 self
157 }
158 /// <p>The MIME type of the input data in the request body.</p>
159 pub fn get_content_type(&self) -> &::std::option::Option<::std::string::String> {
160 self.inner.get_content_type()
161 }
162 /// <p>The desired MIME type of the inference response from the model container.</p>
163 pub fn accept(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
164 self.inner = self.inner.accept(input.into());
165 self
166 }
167 /// <p>The desired MIME type of the inference response from the model container.</p>
168 pub fn set_accept(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
169 self.inner = self.inner.set_accept(input);
170 self
171 }
172 /// <p>The desired MIME type of the inference response from the model container.</p>
173 pub fn get_accept(&self) -> &::std::option::Option<::std::string::String> {
174 self.inner.get_accept()
175 }
176 /// <p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI 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://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1).</p>
177 /// <p>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 <code>Trace ID:</code> in your post-processing function.</p>
178 /// <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.</p>
179 pub fn custom_attributes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
180 self.inner = self.inner.custom_attributes(input.into());
181 self
182 }
183 /// <p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI 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://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1).</p>
184 /// <p>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 <code>Trace ID:</code> in your post-processing function.</p>
185 /// <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.</p>
186 pub fn set_custom_attributes(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
187 self.inner = self.inner.set_custom_attributes(input);
188 self
189 }
190 /// <p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI 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://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1).</p>
191 /// <p>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 <code>Trace ID:</code> in your post-processing function.</p>
192 /// <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.</p>
193 pub fn get_custom_attributes(&self) -> &::std::option::Option<::std::string::String> {
194 self.inner.get_custom_attributes()
195 }
196 /// <p>The model to request for inference when invoking a multi-model endpoint.</p>
197 pub fn target_model(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
198 self.inner = self.inner.target_model(input.into());
199 self
200 }
201 /// <p>The model to request for inference when invoking a multi-model endpoint.</p>
202 pub fn set_target_model(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
203 self.inner = self.inner.set_target_model(input);
204 self
205 }
206 /// <p>The model to request for inference when invoking a multi-model endpoint.</p>
207 pub fn get_target_model(&self) -> &::std::option::Option<::std::string::String> {
208 self.inner.get_target_model()
209 }
210 /// <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>
211 /// <p>For information about how to use variant targeting to perform a/b testing, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html">Test models in production</a></p>
212 pub fn target_variant(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
213 self.inner = self.inner.target_variant(input.into());
214 self
215 }
216 /// <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>
217 /// <p>For information about how to use variant targeting to perform a/b testing, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html">Test models in production</a></p>
218 pub fn set_target_variant(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
219 self.inner = self.inner.set_target_variant(input);
220 self
221 }
222 /// <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>
223 /// <p>For information about how to use variant targeting to perform a/b testing, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html">Test models in production</a></p>
224 pub fn get_target_variant(&self) -> &::std::option::Option<::std::string::String> {
225 self.inner.get_target_variant()
226 }
227 /// <p>If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.</p>
228 pub fn target_container_hostname(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
229 self.inner = self.inner.target_container_hostname(input.into());
230 self
231 }
232 /// <p>If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.</p>
233 pub fn set_target_container_hostname(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
234 self.inner = self.inner.set_target_container_hostname(input);
235 self
236 }
237 /// <p>If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.</p>
238 pub fn get_target_container_hostname(&self) -> &::std::option::Option<::std::string::String> {
239 self.inner.get_target_container_hostname()
240 }
241 /// <p>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 <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html">Capture Data</a>.</p>
242 pub fn inference_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
243 self.inner = self.inner.inference_id(input.into());
244 self
245 }
246 /// <p>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 <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html">Capture Data</a>.</p>
247 pub fn set_inference_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
248 self.inner = self.inner.set_inference_id(input);
249 self
250 }
251 /// <p>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 <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html">Capture Data</a>.</p>
252 pub fn get_inference_id(&self) -> &::std::option::Option<::std::string::String> {
253 self.inner.get_inference_id()
254 }
255 /// <p>An optional JMESPath expression used to override the <code>EnableExplanations</code> parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html#clarify-online-explainability-create-endpoint-enable">EnableExplanations</a> section in the developer guide for more information.</p>
256 pub fn enable_explanations(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
257 self.inner = self.inner.enable_explanations(input.into());
258 self
259 }
260 /// <p>An optional JMESPath expression used to override the <code>EnableExplanations</code> parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html#clarify-online-explainability-create-endpoint-enable">EnableExplanations</a> section in the developer guide for more information.</p>
261 pub fn set_enable_explanations(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
262 self.inner = self.inner.set_enable_explanations(input);
263 self
264 }
265 /// <p>An optional JMESPath expression used to override the <code>EnableExplanations</code> parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html#clarify-online-explainability-create-endpoint-enable">EnableExplanations</a> section in the developer guide for more information.</p>
266 pub fn get_enable_explanations(&self) -> &::std::option::Option<::std::string::String> {
267 self.inner.get_enable_explanations()
268 }
269 /// <p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.</p>
270 pub fn inference_component_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
271 self.inner = self.inner.inference_component_name(input.into());
272 self
273 }
274 /// <p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.</p>
275 pub fn set_inference_component_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
276 self.inner = self.inner.set_inference_component_name(input);
277 self
278 }
279 /// <p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.</p>
280 pub fn get_inference_component_name(&self) -> &::std::option::Option<::std::string::String> {
281 self.inner.get_inference_component_name()
282 }
283 /// <p>Creates a stateful session or identifies an existing one. You can do one of the following:</p>
284 /// <ul>
285 /// <li>
286 /// <p>Create a stateful session by specifying the value <code>NEW_SESSION</code>.</p></li>
287 /// <li>
288 /// <p>Send your request to an existing stateful session by specifying the ID of that session.</p></li>
289 /// </ul>
290 /// <p>With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the <code>NewSessionId</code> response parameter. For any subsequent request where you specify that session ID, SageMaker AI routes the request to the same instance that supports the session.</p>
291 pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
292 self.inner = self.inner.session_id(input.into());
293 self
294 }
295 /// <p>Creates a stateful session or identifies an existing one. You can do one of the following:</p>
296 /// <ul>
297 /// <li>
298 /// <p>Create a stateful session by specifying the value <code>NEW_SESSION</code>.</p></li>
299 /// <li>
300 /// <p>Send your request to an existing stateful session by specifying the ID of that session.</p></li>
301 /// </ul>
302 /// <p>With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the <code>NewSessionId</code> response parameter. For any subsequent request where you specify that session ID, SageMaker AI routes the request to the same instance that supports the session.</p>
303 pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
304 self.inner = self.inner.set_session_id(input);
305 self
306 }
307 /// <p>Creates a stateful session or identifies an existing one. You can do one of the following:</p>
308 /// <ul>
309 /// <li>
310 /// <p>Create a stateful session by specifying the value <code>NEW_SESSION</code>.</p></li>
311 /// <li>
312 /// <p>Send your request to an existing stateful session by specifying the ID of that session.</p></li>
313 /// </ul>
314 /// <p>With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the <code>NewSessionId</code> response parameter. For any subsequent request where you specify that session ID, SageMaker AI routes the request to the same instance that supports the session.</p>
315 pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
316 self.inner.get_session_id()
317 }
318}