Skip to main content

aws_sdk_bedrockruntime/operation/
invoke_model_with_response_stream.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `InvokeModelWithResponseStream`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct InvokeModelWithResponseStream;
6impl InvokeModelWithResponseStream {
7    /// Creates a new `InvokeModelWithResponseStream`
8    pub fn new() -> Self {
9        Self
10    }
11    pub(crate) async fn orchestrate(
12        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13        input: crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamInput,
14    ) -> ::std::result::Result<
15        crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        use ::tracing::Instrument;
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
55            "Bedrock Runtime",
56            "InvokeModelWithResponseStream",
57            input,
58            runtime_plugins,
59            stop_point,
60        )
61        // Create a parent span for the entire operation. Includes a random, internal-only,
62        // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
63        .instrument(::tracing::debug_span!(
64            "Bedrock Runtime.InvokeModelWithResponseStream",
65            "rpc.service" = "Bedrock Runtime",
66            "rpc.method" = "InvokeModelWithResponseStream",
67            "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
68            "rpc.system" = "aws-api",
69        ))
70        .await
71    }
72
73    pub(crate) fn operation_runtime_plugins(
74        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
75        client_config: &crate::config::Config,
76        config_override: ::std::option::Option<crate::config::Builder>,
77    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
78        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
79
80        if let ::std::option::Option::Some(config_override) = config_override {
81            for plugin in config_override.runtime_plugins.iter().cloned() {
82                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
83            }
84            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
85                config_override,
86                client_config.config.clone(),
87                &client_config.runtime_components,
88            ));
89        }
90        runtime_plugins
91    }
92}
93impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for InvokeModelWithResponseStream {
94    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
95        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("InvokeModelWithResponseStream");
96
97        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
98            InvokeModelWithResponseStreamRequestSerializer,
99        ));
100        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
101            InvokeModelWithResponseStreamResponseDeserializer,
102        ));
103
104        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
105            crate::config::auth::Params::builder()
106                .operation_name("InvokeModelWithResponseStream")
107                .build()
108                .expect("required fields set"),
109        ));
110
111        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
112        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
113            "InvokeModelWithResponseStream",
114            "Bedrock Runtime",
115        ));
116        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
117        signing_options.double_uri_encode = true;
118        signing_options.content_sha256_header = false;
119        signing_options.normalize_uri_path = true;
120        signing_options.payload_override = None;
121
122        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
123            signing_options,
124            ..::std::default::Default::default()
125        });
126
127        ::std::option::Option::Some(cfg.freeze())
128    }
129
130    fn runtime_components(
131        &self,
132        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
133    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
134        #[allow(unused_mut)]
135        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("InvokeModelWithResponseStream")
136            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
137                InvokeModelWithResponseStreamTelemetryInputCaptureInterceptor,
138            ))
139            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
140                InvokeModelWithResponseStreamEndpointParamsInterceptor,
141            ))
142            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
143                crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError,
144            >::new())
145            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
146                crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError,
147            >::new())
148            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
149                crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError,
150            >::new());
151
152        ::std::borrow::Cow::Owned(rcb)
153    }
154}
155
156#[derive(Debug)]
157struct InvokeModelWithResponseStreamTelemetryInputCaptureInterceptor;
158
159#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
160impl ::aws_smithy_runtime_api::client::interceptors::Intercept for InvokeModelWithResponseStreamTelemetryInputCaptureInterceptor {
161    fn name(&self) -> &'static str {
162        "InvokeModelWithResponseStreamTelemetryInputCaptureInterceptor"
163    }
164
165    fn read_before_execution(
166        &self,
167        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
168            '_,
169            ::aws_smithy_runtime_api::client::interceptors::context::Input,
170            ::aws_smithy_runtime_api::client::interceptors::context::Output,
171            ::aws_smithy_runtime_api::client::interceptors::context::Error,
172        >,
173        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
174    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
175        // Nothing to do unless the customer opted in by naming members to record.
176        let ::std::option::Option::Some(requested) = cfg
177            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
178            .filter(|r| !r.is_empty())
179        else {
180            return ::std::result::Result::Ok(());
181        };
182
183        let ::std::option::Option::Some(input) = context.input().downcast_ref::<InvokeModelWithResponseStreamInput>() else {
184            // A mismatched input is not this interceptor's concern; skip quietly.
185            return ::std::result::Result::Ok(());
186        };
187
188        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
189        if requested.should_capture("contentType") {
190            if let ::std::option::Option::Some(value) = input.content_type.as_deref() {
191                captured.insert("contentType", value);
192            }
193        }
194        if requested.should_capture("accept") {
195            if let ::std::option::Option::Some(value) = input.accept.as_deref() {
196                captured.insert("accept", value);
197            }
198        }
199        if requested.should_capture("modelId") {
200            if let ::std::option::Option::Some(value) = input.model_id.as_deref() {
201                captured.insert("modelId", value);
202            }
203        }
204        if requested.should_capture("guardrailIdentifier") {
205            if let ::std::option::Option::Some(value) = input.guardrail_identifier.as_deref() {
206                captured.insert("guardrailIdentifier", value);
207            }
208        }
209        if requested.should_capture("guardrailVersion") {
210            if let ::std::option::Option::Some(value) = input.guardrail_version.as_deref() {
211                captured.insert("guardrailVersion", value);
212            }
213        }
214
215        cfg.interceptor_state().store_put(captured);
216        ::std::result::Result::Ok(())
217    }
218}
219#[derive(Debug)]
220struct InvokeModelWithResponseStreamResponseDeserializer;
221impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for InvokeModelWithResponseStreamResponseDeserializer {
222    fn deserialize_streaming(
223        &self,
224        response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
225    ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
226        #[allow(unused_mut)]
227        let mut force_error = false;
228        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
229
230        // If this is an error, defer to the non-streaming parser
231        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
232            return ::std::option::Option::None;
233        }
234        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
235            crate::protocol_serde::shape_invoke_model_with_response_stream::de_invoke_model_with_response_stream_http_response(response),
236        ))
237    }
238
239    fn deserialize_nonstreaming_with_config(
240        &self,
241        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
242        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
243    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
244        // For streaming operations, we only hit this case if its an error
245        let body = response.body().bytes().expect("body loaded");
246        crate::protocol_serde::type_erase_result(
247            crate::protocol_serde::shape_invoke_model_with_response_stream::de_invoke_model_with_response_stream_http_error(
248                response.status().as_u16(),
249                response.headers(),
250                body,
251            ),
252        )
253    }
254}
255#[derive(Debug)]
256struct InvokeModelWithResponseStreamRequestSerializer;
257impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for InvokeModelWithResponseStreamRequestSerializer {
258    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
259    fn serialize_input(
260        &self,
261        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
262        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
263    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
264        let input = input
265            .downcast::<crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamInput>()
266            .expect("correct type");
267        let _header_serialization_settings = _cfg
268            .load::<crate::serialization_settings::HeaderSerializationSettings>()
269            .cloned()
270            .unwrap_or_default();
271        let mut request_builder = {
272            #[allow(clippy::uninlined_format_args)]
273            fn uri_base(
274                _input: &crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamInput,
275                output: &mut ::std::string::String,
276            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
277                use ::std::fmt::Write as _;
278                let input_1 = &_input.model_id;
279                let input_1 = input_1
280                    .as_ref()
281                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("model_id", "cannot be empty or unset"))?;
282                let model_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
283                if model_id.is_empty() {
284                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
285                        "model_id",
286                        "cannot be empty or unset",
287                    ));
288                }
289                ::std::write!(output, "/model/{modelId}/invoke-with-response-stream", modelId = model_id).expect("formatting should succeed");
290                ::std::result::Result::Ok(())
291            }
292            #[allow(clippy::unnecessary_wraps)]
293            fn update_http_builder(
294                input: &crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamInput,
295                builder: ::http_1x::request::Builder,
296            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
297                let mut uri = ::std::string::String::new();
298                uri_base(input, &mut uri)?;
299                let builder =
300                    crate::protocol_serde::shape_invoke_model_with_response_stream::ser_invoke_model_with_response_stream_headers(input, builder)?;
301                ::std::result::Result::Ok(builder.method("POST").uri(uri))
302            }
303            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
304            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/octet-stream");
305            builder
306        };
307        let body = ::aws_smithy_types::body::SdkBody::from(
308            crate::protocol_serde::shape_invoke_model_with_response_stream_input::ser_body_http_payload(input.body)?,
309        );
310        if let Some(content_length) = body.content_length() {
311            let content_length = content_length.to_string();
312            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
313        }
314        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
315    }
316}
317#[derive(Debug)]
318struct InvokeModelWithResponseStreamEndpointParamsInterceptor;
319
320#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
321impl ::aws_smithy_runtime_api::client::interceptors::Intercept for InvokeModelWithResponseStreamEndpointParamsInterceptor {
322    fn name(&self) -> &'static str {
323        "InvokeModelWithResponseStreamEndpointParamsInterceptor"
324    }
325
326    fn read_before_execution(
327        &self,
328        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
329            '_,
330            ::aws_smithy_runtime_api::client::interceptors::context::Input,
331            ::aws_smithy_runtime_api::client::interceptors::context::Output,
332            ::aws_smithy_runtime_api::client::interceptors::context::Error,
333        >,
334        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
335    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
336        let _input = context
337            .input()
338            .downcast_ref::<InvokeModelWithResponseStreamInput>()
339            .ok_or("failed to downcast to InvokeModelWithResponseStreamInput")?;
340
341        let params = crate::config::endpoint::Params::builder()
342            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
343            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
344            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
345            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
346            .build()
347            .map_err(|err| {
348                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
349            })?;
350        cfg.interceptor_state()
351            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
352        ::std::result::Result::Ok(())
353    }
354}
355
356// The get_* functions below are generated from JMESPath expressions in the
357// operationContextParams trait. They target the operation's input shape.
358
359/// Error type for the `InvokeModelWithResponseStreamError` operation.
360#[non_exhaustive]
361#[derive(::std::fmt::Debug)]
362pub enum InvokeModelWithResponseStreamError {
363    /// <p>The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-access-denied">AccessDeniedException</a> in the Amazon Bedrock User Guide</p>
364    AccessDeniedException(crate::types::error::AccessDeniedException),
365    /// <p>An internal server error occurred. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-internal-failure">InternalFailure</a> in the Amazon Bedrock User Guide</p>
366    InternalServerException(crate::types::error::InternalServerException),
367    /// <p>The request failed due to an error while processing the model.</p>
368    ModelErrorException(crate::types::error::ModelErrorException),
369    /// <p>The model specified in the request is not ready to serve inference requests. The AWS SDK will automatically retry the operation up to 5 times. For information about configuring automatic retries, see <a href="https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html">Retry behavior</a> in the <i>AWS SDKs and Tools</i> reference guide.</p>
370    ModelNotReadyException(crate::types::error::ModelNotReadyException),
371    /// <p>An error occurred while streaming the response. Retry your request.</p>
372    ModelStreamErrorException(crate::types::error::ModelStreamErrorException),
373    /// <p>The request took too long to process. Processing time exceeded the model timeout length.</p>
374    ModelTimeoutException(crate::types::error::ModelTimeoutException),
375    /// <p>The specified resource ARN was not found. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-resource-not-found">ResourceNotFound</a> in the Amazon Bedrock User Guide</p>
376    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
377    /// <p>Your request exceeds the service quota for your account. You can view your quotas at <a href="https://docs.aws.amazon.com/servicequotas/latest/userguide/gs-request-quota.html">Viewing service quotas</a>. You can resubmit your request later.</p>
378    ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
379    /// <p>The service isn't currently available. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-service-unavailable">ServiceUnavailable</a> in the Amazon Bedrock User Guide</p>
380    ServiceUnavailableException(crate::types::error::ServiceUnavailableException),
381    /// <p>Your request was denied due to exceeding the account quotas for <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-throttling-exception">ThrottlingException</a> in the Amazon Bedrock User Guide</p>
382    ThrottlingException(crate::types::error::ThrottlingException),
383    /// <p>The input fails to satisfy the constraints specified by <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-validation-error">ValidationError</a> in the Amazon Bedrock User Guide</p>
384    ValidationException(crate::types::error::ValidationException),
385    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
386    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
387    variable wildcard pattern and check `.code()`:
388     \
389    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
390     \
391    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-InvokeModelWithResponseStreamError) for what information is available for the error.")]
392    Unhandled(crate::error::sealed_unhandled::Unhandled),
393}
394impl InvokeModelWithResponseStreamError {
395    /// Creates the `InvokeModelWithResponseStreamError::Unhandled` variant from any error type.
396    pub fn unhandled(
397        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
398    ) -> Self {
399        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
400            source: err.into(),
401            meta: ::std::default::Default::default(),
402        })
403    }
404
405    /// Creates the `InvokeModelWithResponseStreamError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
406    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
407        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
408            source: err.clone().into(),
409            meta: err,
410        })
411    }
412    ///
413    /// Returns error metadata, which includes the error code, message,
414    /// request ID, and potentially additional information.
415    ///
416    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
417        match self {
418            Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
419            Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
420            Self::ModelErrorException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
421            Self::ModelNotReadyException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
422            Self::ModelStreamErrorException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
423            Self::ModelTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
424            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
425            Self::ServiceQuotaExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
426            Self::ServiceUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
427            Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
428            Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
429            Self::Unhandled(e) => &e.meta,
430        }
431    }
432    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::AccessDeniedException`.
433    pub fn is_access_denied_exception(&self) -> bool {
434        matches!(self, Self::AccessDeniedException(_))
435    }
436    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::InternalServerException`.
437    pub fn is_internal_server_exception(&self) -> bool {
438        matches!(self, Self::InternalServerException(_))
439    }
440    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ModelErrorException`.
441    pub fn is_model_error_exception(&self) -> bool {
442        matches!(self, Self::ModelErrorException(_))
443    }
444    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ModelNotReadyException`.
445    pub fn is_model_not_ready_exception(&self) -> bool {
446        matches!(self, Self::ModelNotReadyException(_))
447    }
448    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ModelStreamErrorException`.
449    pub fn is_model_stream_error_exception(&self) -> bool {
450        matches!(self, Self::ModelStreamErrorException(_))
451    }
452    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ModelTimeoutException`.
453    pub fn is_model_timeout_exception(&self) -> bool {
454        matches!(self, Self::ModelTimeoutException(_))
455    }
456    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ResourceNotFoundException`.
457    pub fn is_resource_not_found_exception(&self) -> bool {
458        matches!(self, Self::ResourceNotFoundException(_))
459    }
460    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ServiceQuotaExceededException`.
461    pub fn is_service_quota_exceeded_exception(&self) -> bool {
462        matches!(self, Self::ServiceQuotaExceededException(_))
463    }
464    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ServiceUnavailableException`.
465    pub fn is_service_unavailable_exception(&self) -> bool {
466        matches!(self, Self::ServiceUnavailableException(_))
467    }
468    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ThrottlingException`.
469    pub fn is_throttling_exception(&self) -> bool {
470        matches!(self, Self::ThrottlingException(_))
471    }
472    /// Returns `true` if the error kind is `InvokeModelWithResponseStreamError::ValidationException`.
473    pub fn is_validation_exception(&self) -> bool {
474        matches!(self, Self::ValidationException(_))
475    }
476}
477impl ::std::error::Error for InvokeModelWithResponseStreamError {
478    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
479        match self {
480            Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
481            Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
482            Self::ModelErrorException(_inner) => ::std::option::Option::Some(_inner),
483            Self::ModelNotReadyException(_inner) => ::std::option::Option::Some(_inner),
484            Self::ModelStreamErrorException(_inner) => ::std::option::Option::Some(_inner),
485            Self::ModelTimeoutException(_inner) => ::std::option::Option::Some(_inner),
486            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
487            Self::ServiceQuotaExceededException(_inner) => ::std::option::Option::Some(_inner),
488            Self::ServiceUnavailableException(_inner) => ::std::option::Option::Some(_inner),
489            Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
490            Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
491            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
492        }
493    }
494}
495impl ::std::fmt::Display for InvokeModelWithResponseStreamError {
496    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
497        match self {
498            Self::AccessDeniedException(_inner) => _inner.fmt(f),
499            Self::InternalServerException(_inner) => _inner.fmt(f),
500            Self::ModelErrorException(_inner) => _inner.fmt(f),
501            Self::ModelNotReadyException(_inner) => _inner.fmt(f),
502            Self::ModelStreamErrorException(_inner) => _inner.fmt(f),
503            Self::ModelTimeoutException(_inner) => _inner.fmt(f),
504            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
505            Self::ServiceQuotaExceededException(_inner) => _inner.fmt(f),
506            Self::ServiceUnavailableException(_inner) => _inner.fmt(f),
507            Self::ThrottlingException(_inner) => _inner.fmt(f),
508            Self::ValidationException(_inner) => _inner.fmt(f),
509            Self::Unhandled(_inner) => {
510                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
511                    write!(f, "unhandled error ({code})")
512                } else {
513                    f.write_str("unhandled error")
514                }
515            }
516        }
517    }
518}
519impl ::aws_smithy_types::retry::ProvideErrorKind for InvokeModelWithResponseStreamError {
520    fn code(&self) -> ::std::option::Option<&str> {
521        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
522    }
523    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
524        match self {
525            Self::ModelNotReadyException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
526            _ => ::std::option::Option::None,
527        }
528    }
529}
530impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for InvokeModelWithResponseStreamError {
531    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
532        match self {
533            Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
534            Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
535            Self::ModelErrorException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
536            Self::ModelNotReadyException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
537            Self::ModelStreamErrorException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
538            Self::ModelTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
539            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
540            Self::ServiceQuotaExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
541            Self::ServiceUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
542            Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
543            Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
544            Self::Unhandled(_inner) => &_inner.meta,
545        }
546    }
547}
548impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for InvokeModelWithResponseStreamError {
549    fn create_unhandled_error(
550        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
551        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
552    ) -> Self {
553        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
554            source,
555            meta: meta.unwrap_or_default(),
556        })
557    }
558}
559impl ::aws_types::request_id::RequestId for crate::operation::invoke_model_with_response_stream::InvokeModelWithResponseStreamError {
560    fn request_id(&self) -> Option<&str> {
561        self.meta().request_id()
562    }
563}
564
565pub use crate::operation::invoke_model_with_response_stream::_invoke_model_with_response_stream_input::InvokeModelWithResponseStreamInput;
566
567pub use crate::operation::invoke_model_with_response_stream::_invoke_model_with_response_stream_output::InvokeModelWithResponseStreamOutput;
568
569mod _invoke_model_with_response_stream_input;
570
571mod _invoke_model_with_response_stream_output;
572
573/// Builders
574pub mod builders;