aws-sdk-sagemakergatewayruntime 1.0.0

AWS SDK for Amazon SageMaker Gateway Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::invoke_global_inference_gateway::_invoke_global_inference_gateway_input::InvokeGlobalInferenceGatewayInputBuilder;

pub use crate::operation::invoke_global_inference_gateway::_invoke_global_inference_gateway_output::InvokeGlobalInferenceGatewayOutputBuilder;

impl crate::operation::invoke_global_inference_gateway::builders::InvokeGlobalInferenceGatewayInputBuilder {
    /// 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_global_inference_gateway::InvokeGlobalInferenceGatewayOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.invoke_global_inference_gateway();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `InvokeGlobalInferenceGateway`.
///
/// Buffered (non-streaming) inference. Returns the full OpenAI completion body. Errors carry their origin in the `Message` prefix. Every typed error's text is in the `Message` member (JSON key `Message`), and starts with one of these prefixes: * `Global Inference Gateway: ` -- the gateway rejected or failed the request itself: validation, authorization, throttling, routing (the gateway or model was not found, or no capacity is available), a gateway limit or time limit, or failing to reach the inference gateway (`Global Inference Gateway: could not reach the inference gateway: <reason>
/// `, or `Global Inference Gateway: timed out waiting for the inference gateway`). This includes the 400 for an invalid request and the 413 for a request body that is too large. * `inference gateway: ` -- the inference gateway serving the model returned an error status. The message gives that status code and up to 256 bytes of its error message, for example `inference gateway: 503
/// <message>
/// `. A BadGatewayException can instead read `inference gateway: response ended unexpectedly`, with no status, when the inference gateway's connection failed while it was sending the response. * `inference gateway (
/// <component>
/// ): ` -- the same, when the inference gateway reports which of its components produced the error, for example `inference gateway (model server): 502
/// <message>
/// `. The component is one of: * `config` -- the inference gateway's configuration and proxy layer. * `scheduler` -- the inference gateway's request scheduler. * `model selector` -- the inference gateway's model selector. * `model server` -- the model server. Every error status the inference gateway returns is a typed error, chosen by that status: * 400 and any other 4xx not listed here -- a 400 validation error. * 401 and 403 -- AccessDeniedException (403). * 404 -- ResourceNotFoundException. * 408 -- GatewayTimeoutException (504). * 429 -- ThrottlingException, with the `Retry-After` header. * 502, and 500, 503 or any other 5xx not listed here -- BadGatewayException (502). A 500 or 503 from the inference gateway comes after the request was dispatched, so it is not modeled as retryable, and the gateway may already have tried another inference gateway. Standard SDK retry modes may still retry a 5xx status; set max attempts to 1 if a repeated inference is unacceptable. * 504 -- GatewayTimeoutException.
/// </message>
/// </component>
/// </message>
/// </reason>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct InvokeGlobalInferenceGatewayFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::invoke_global_inference_gateway::builders::InvokeGlobalInferenceGatewayInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayOutput,
        crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
    > for InvokeGlobalInferenceGatewayFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayOutput,
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl InvokeGlobalInferenceGatewayFluentBuilder {
    /// Creates a new `InvokeGlobalInferenceGatewayFluentBuilder`.
    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 InvokeGlobalInferenceGateway as a reference.
    pub fn as_input(&self) -> &crate::operation::invoke_global_inference_gateway::builders::InvokeGlobalInferenceGatewayInputBuilder {
        &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_global_inference_gateway::InvokeGlobalInferenceGatewayOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
            ::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_global_inference_gateway::InvokeGlobalInferenceGateway::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGateway::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_global_inference_gateway::InvokeGlobalInferenceGatewayOutput,
        crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
        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
    }
    /// The ID of the Global Inference Gateway to invoke. IAM policies refer to the gateway by its ARN, `arn:<partition>
    /// :sagemaker:
    /// <region>
    /// :
    /// <account>
    /// :global-inference-gateway/
    /// <id>
    /// `.
    /// </id>
    /// </account>
    /// </region>
    /// </partition>
    pub fn gateway_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.gateway_id(input.into());
        self
    }
    /// The ID of the Global Inference Gateway to invoke. IAM policies refer to the gateway by its ARN, `arn:<partition>
    /// :sagemaker:
    /// <region>
    /// :
    /// <account>
    /// :global-inference-gateway/
    /// <id>
    /// `.
    /// </id>
    /// </account>
    /// </region>
    /// </partition>
    pub fn set_gateway_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_gateway_id(input);
        self
    }
    /// The ID of the Global Inference Gateway to invoke. IAM policies refer to the gateway by its ARN, `arn:<partition>
    /// :sagemaker:
    /// <region>
    /// :
    /// <account>
    /// :global-inference-gateway/
    /// <id>
    /// `.
    /// </id>
    /// </account>
    /// </region>
    /// </partition>
    pub fn get_gateway_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_gateway_id()
    }
    /// The MIME type you want for the response. It is passed to the model server.
    pub fn accept(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.accept(input.into());
        self
    }
    /// The MIME type you want for the response. It is passed to the model server.
    pub fn set_accept(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_accept(input);
        self
    }
    /// The MIME type you want for the response. It is passed to the model server.
    pub fn get_accept(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_accept()
    }
    /// The MIME type of the request body. Pass `application/json` (parameters such as `charset=utf-8` are allowed): the body is one OpenAI JSON object. The Global Inference Gateway rejects other content types with a 415 error.
    pub fn content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.content_type(input.into());
        self
    }
    /// The MIME type of the request body. Pass `application/json` (parameters such as `charset=utf-8` are allowed): the body is one OpenAI JSON object. The Global Inference Gateway rejects other content types with a 415 error.
    pub fn set_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_content_type(input);
        self
    }
    /// The MIME type of the request body. Pass `application/json` (parameters such as `charset=utf-8` are allowed): the body is one OpenAI JSON object. The Global Inference Gateway rejects other content types with a 415 error.
    pub fn get_content_type(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_content_type()
    }
    /// Per-caller customer identity token (a JWT), forwarded unchanged to the inference gateway, which validates it. The gateway does not use it to authorize the request. Include it in the SigV4 signed headers so it cannot be altered in transit. Redacted from logs, metrics and traces.
    pub fn customer_identity_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.customer_identity_token(input.into());
        self
    }
    /// Per-caller customer identity token (a JWT), forwarded unchanged to the inference gateway, which validates it. The gateway does not use it to authorize the request. Include it in the SigV4 signed headers so it cannot be altered in transit. Redacted from logs, metrics and traces.
    pub fn set_customer_identity_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_customer_identity_token(input);
        self
    }
    /// Per-caller customer identity token (a JWT), forwarded unchanged to the inference gateway, which validates it. The gateway does not use it to authorize the request. Include it in the SigV4 signed headers so it cannot be altered in transit. Redacted from logs, metrics and traces.
    pub fn get_customer_identity_token(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_customer_identity_token()
    }
    /// The inference request body: one OpenAI JSON object, at most 10 MiB. Its content is passed to the model server unchanged, except that the request is always sent with `"stream": false`: this operation returns one JSON document, so a `"stream": true` in the body is overridden (use InvokeGlobalInferenceGatewayWithResponseStream to stream). A body that is not one JSON object, or that repeats the top-level `model` key with different values, is rejected with a 400 validation error. A body larger than 10 MiB is rejected with PayloadTooLargeException (413). The gateway reads only `model` and `stream`, and does not store the body.
    pub fn body(mut self, input: ::aws_smithy_types::Blob) -> Self {
        self.inner = self.inner.body(input);
        self
    }
    /// The inference request body: one OpenAI JSON object, at most 10 MiB. Its content is passed to the model server unchanged, except that the request is always sent with `"stream": false`: this operation returns one JSON document, so a `"stream": true` in the body is overridden (use InvokeGlobalInferenceGatewayWithResponseStream to stream). A body that is not one JSON object, or that repeats the top-level `model` key with different values, is rejected with a 400 validation error. A body larger than 10 MiB is rejected with PayloadTooLargeException (413). The gateway reads only `model` and `stream`, and does not store the body.
    pub fn set_body(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
        self.inner = self.inner.set_body(input);
        self
    }
    /// The inference request body: one OpenAI JSON object, at most 10 MiB. Its content is passed to the model server unchanged, except that the request is always sent with `"stream": false`: this operation returns one JSON document, so a `"stream": true` in the body is overridden (use InvokeGlobalInferenceGatewayWithResponseStream to stream). A body that is not one JSON object, or that repeats the top-level `model` key with different values, is rejected with a 400 validation error. A body larger than 10 MiB is rejected with PayloadTooLargeException (413). The gateway reads only `model` and `stream`, and does not store the body.
    pub fn get_body(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
        self.inner.get_body()
    }
}