aws-sdk-sagemakerinferencerouterruntime 1.2.0

AWS SDK for Amazon SageMaker Inference Router Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::invoke_inference_router::_invoke_inference_router_input::InvokeInferenceRouterInputBuilder;

pub use crate::operation::invoke_inference_router::_invoke_inference_router_output::InvokeInferenceRouterOutputBuilder;

impl crate::operation::invoke_inference_router::builders::InvokeInferenceRouterInputBuilder {
    /// Sends a request with this input using the given client.
    pub async fn send_with(
        self,
        client: &crate::Client,
    ) -> ::std::result::Result<
        crate::operation::invoke_inference_router::InvokeInferenceRouterOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_inference_router::InvokeInferenceRouterError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.invoke_inference_router();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `InvokeInferenceRouter`.
///
/// <p>Sends a real-time inference request to an inference router. In the request, you name the routing target, and the router sends the request to one of the routing target's destinations. The response includes the destination that served the request and the reason that the router chose it.</p>
/// <p>The following limits apply:</p>
/// <ul>
/// <li>
/// <p>The maximum request payload is 6 MB. A request with a larger body fails with HTTP status code 413.</p></li>
/// <li>
/// <p>Your model has up to 60 seconds for each attempt, the same limit as <code>InvokeEndpoint</code>. If your account has a higher model execution timeout for <code>InvokeEndpoint</code>, it doesn't apply through an inference router. For models that take longer, use <code>InvokeInferenceRouterAsync</code>.</p></li>
/// </ul>
/// <p>If a destination returns an error that the router can retry, such as a throttling error, before your model produces a response, the router retries the request once on another destination. A request that times out on a destination isn't retried. Because a request can make two attempts, set your client read timeout to at least 170 seconds.</p>
/// <p>The caller needs permission to invoke the inference router and every destination of the routing target. For information about permissions, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/inference-router.html">Route requests across Regions with inference routers</a>.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct InvokeInferenceRouterFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::invoke_inference_router::builders::InvokeInferenceRouterInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::invoke_inference_router::InvokeInferenceRouterOutput,
        crate::operation::invoke_inference_router::InvokeInferenceRouterError,
    > for InvokeInferenceRouterFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::invoke_inference_router::InvokeInferenceRouterOutput,
            crate::operation::invoke_inference_router::InvokeInferenceRouterError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl InvokeInferenceRouterFluentBuilder {
    /// Creates a new `InvokeInferenceRouterFluentBuilder`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
            config_override: ::std::option::Option::None,
        }
    }
    /// Access the InvokeInferenceRouter as a reference.
    pub fn as_input(&self) -> &crate::operation::invoke_inference_router::builders::InvokeInferenceRouterInputBuilder {
        &self.inner
    }
    /// Sends the request and returns the response.
    ///
    /// If an error occurs, an `SdkError` will be returned with additional details that
    /// can be matched against.
    ///
    /// By default, any retryable failures will be retried twice. Retry behavior
    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
    /// set when configuring the client.
    pub async fn send(
        self,
    ) -> ::std::result::Result<
        crate::operation::invoke_inference_router::InvokeInferenceRouterOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_inference_router::InvokeInferenceRouterError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let input = self
            .inner
            .build()
            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
        let runtime_plugins = crate::operation::invoke_inference_router::InvokeInferenceRouter::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        crate::operation::invoke_inference_router::InvokeInferenceRouter::orchestrate(&runtime_plugins, input).await
    }

    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
    pub fn customize(
        self,
    ) -> crate::client::customize::CustomizableOperation<
        crate::operation::invoke_inference_router::InvokeInferenceRouterOutput,
        crate::operation::invoke_inference_router::InvokeInferenceRouterError,
        Self,
    > {
        crate::client::customize::CustomizableOperation::new(self)
    }
    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
        self.set_config_override(::std::option::Option::Some(config_override.into()));
        self
    }

    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
        self.config_override = config_override;
        self
    }
    /// <p>The name of the inference router to invoke.</p>
    pub fn inference_router_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.inference_router_name(input.into());
        self
    }
    /// <p>The name of the inference router to invoke.</p>
    pub fn set_inference_router_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_inference_router_name(input);
        self
    }
    /// <p>The name of the inference router to invoke.</p>
    pub fn get_inference_router_name(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_inference_router_name()
    }
    /// <p>The name of the routing target in the inference router. The routing target lists the destinations that can serve the request.</p>
    pub fn routing_target_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.routing_target_name(input.into());
        self
    }
    /// <p>The name of the routing target in the inference router. The routing target lists the destinations that can serve the request.</p>
    pub fn set_routing_target_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_routing_target_name(input);
        self
    }
    /// <p>The name of the routing target in the inference router. The routing target lists the destinations that can serve the request.</p>
    pub fn get_routing_target_name(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_routing_target_name()
    }
    /// <p>The MIME type of the input data in the request body. The router passes it to the destination.</p>
    pub fn content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.content_type(input.into());
        self
    }
    /// <p>The MIME type of the input data in the request body. The router passes it to the destination.</p>
    pub fn set_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_content_type(input);
        self
    }
    /// <p>The MIME type of the input data in the request body. The router passes it to the destination.</p>
    pub fn get_content_type(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_content_type()
    }
    /// <p>The MIME type that you want for the inference response. The router passes it to the destination.</p>
    pub fn accept(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.accept(input.into());
        self
    }
    /// <p>The MIME type that you want for the inference response. The router passes it to the destination.</p>
    pub fn set_accept(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_accept(input);
        self
    }
    /// <p>The MIME type that you want for the inference response. The router passes it to the destination.</p>
    pub fn get_accept(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_accept()
    }
    /// <p>An identifier for the inference request. The router passes it to the destination.</p>
    pub fn inference_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.inference_id(input.into());
        self
    }
    /// <p>An identifier for the inference request. The router passes it to the destination.</p>
    pub fn set_inference_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_inference_id(input);
        self
    }
    /// <p>An identifier for the inference request. The router passes it to the destination.</p>
    pub fn get_inference_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_inference_id()
    }
    /// <p>An optional, stable identifier that serves as a routing hint for prefix-aware routing. The router passes it to the destination that serves the request. Within that destination, requests with the same prefix and the same identifier go to the same instance. If requests from different applications might have the same prompt prefix, set a different identifier for each application to differentiate their routing decisions.</p>
    /// <p>Applies only to destination endpoints configured with a <code>RoutingStrategy</code> of <code>PREFIX_AWARE</code>.</p>
    pub fn prefix_aware_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.prefix_aware_id(input.into());
        self
    }
    /// <p>An optional, stable identifier that serves as a routing hint for prefix-aware routing. The router passes it to the destination that serves the request. Within that destination, requests with the same prefix and the same identifier go to the same instance. If requests from different applications might have the same prompt prefix, set a different identifier for each application to differentiate their routing decisions.</p>
    /// <p>Applies only to destination endpoints configured with a <code>RoutingStrategy</code> of <code>PREFIX_AWARE</code>.</p>
    pub fn set_prefix_aware_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_prefix_aware_id(input);
        self
    }
    /// <p>An optional, stable identifier that serves as a routing hint for prefix-aware routing. The router passes it to the destination that serves the request. Within that destination, requests with the same prefix and the same identifier go to the same instance. If requests from different applications might have the same prompt prefix, set a different identifier for each application to differentiate their routing decisions.</p>
    /// <p>Applies only to destination endpoints configured with a <code>RoutingStrategy</code> of <code>PREFIX_AWARE</code>.</p>
    pub fn get_prefix_aware_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_prefix_aware_id()
    }
    /// <p>Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.</p>
    pub fn custom_attributes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.custom_attributes(input.into());
        self
    }
    /// <p>Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.</p>
    pub fn set_custom_attributes(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_custom_attributes(input);
        self
    }
    /// <p>Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.</p>
    pub fn get_custom_attributes(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_custom_attributes()
    }
    /// <p>The input data for the inference, in the format that your model expects. The body can't be empty.</p>
    pub fn body(mut self, input: ::aws_smithy_types::Blob) -> Self {
        self.inner = self.inner.body(input);
        self
    }
    /// <p>The input data for the inference, in the format that your model expects. The body can't be empty.</p>
    pub fn set_body(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
        self.inner = self.inner.set_body(input);
        self
    }
    /// <p>The input data for the inference, in the format that your model expects. The body can't be empty.</p>
    pub fn get_body(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
        self.inner.get_body()
    }
}