aws_sdk_s3/operation/
get_object.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetObject`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetObject;
6impl GetObject {
7    /// Creates a new `GetObject`
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::get_object::GetObjectInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_object::GetObjectOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_object::GetObjectError,
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::get_object::GetObjectError>()
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::get_object::GetObjectOutput>()
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::get_object::GetObjectInput,
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        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("s3", "GetObject", input, runtime_plugins, stop_point).await
54    }
55
56    pub(crate) fn operation_runtime_plugins(
57        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
58        client_config: &crate::config::Config,
59        config_override: ::std::option::Option<crate::config::Builder>,
60    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
61        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
62        runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
63            ::aws_runtime::auth::sigv4::SCHEME_ID,
64            #[cfg(feature = "sigv4a")]
65            {
66                ::aws_runtime::auth::sigv4a::SCHEME_ID
67            },
68            crate::s3_express::auth::SCHEME_ID,
69            ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
70        ]));
71        if let ::std::option::Option::Some(config_override) = config_override {
72            for plugin in config_override.runtime_plugins.iter().cloned() {
73                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
74            }
75            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
76                config_override,
77                client_config.config.clone(),
78                &client_config.runtime_components,
79            ));
80        }
81        runtime_plugins
82    }
83}
84impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetObject {
85    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
86        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetObject");
87
88        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
89            GetObjectRequestSerializer,
90        ));
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
92            GetObjectResponseDeserializer,
93        ));
94
95        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
96            ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
97        ));
98
99        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
100        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetObject", "s3"));
101        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
102        signing_options.double_uri_encode = false;
103        signing_options.content_sha256_header = true;
104        signing_options.normalize_uri_path = false;
105        signing_options.payload_override = None;
106
107        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
108            signing_options,
109            ..::std::default::Default::default()
110        });
111
112        ::std::option::Option::Some(cfg.freeze())
113    }
114
115    fn runtime_components(
116        &self,
117        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
118    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
119        #[allow(unused_mut)]
120        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetObject")
121            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
122            .with_interceptor(GetObjectEndpointParamsInterceptor)
123            .with_interceptor(crate::s3_expires_interceptor::S3ExpiresInterceptor)
124            .with_interceptor(crate::http_response_checksum::ResponseChecksumInterceptor::new(
125                ["crc32", "crc32c", "sha256", "sha1"].as_slice(),
126                |input: &::aws_smithy_runtime_api::client::interceptors::context::Input| {
127                    let input: &crate::operation::get_object::GetObjectInput = input.downcast_ref().expect("correct type");
128                    matches!(input.checksum_mode(), ::std::option::Option::Some(crate::types::ChecksumMode::Enabled))
129                },
130            ))
131            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
132                crate::operation::get_object::GetObjectError,
133            >::new())
134            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
135                crate::operation::get_object::GetObjectError,
136            >::new())
137            .with_retry_classifier(
138                ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::get_object::GetObjectError>::builder()
139                    .transient_errors({
140                        let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
141                        transient_errors.push("InternalError");
142                        ::std::borrow::Cow::Owned(transient_errors)
143                    })
144                    .build(),
145            );
146
147        ::std::borrow::Cow::Owned(rcb)
148    }
149}
150
151#[derive(Debug)]
152struct GetObjectResponseDeserializer;
153impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetObjectResponseDeserializer {
154    fn deserialize_streaming(
155        &self,
156        response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
157    ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
158        #[allow(unused_mut)]
159        let mut force_error = false;
160        ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
161        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
162
163        // If this is an error, defer to the non-streaming parser
164        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
165            return ::std::option::Option::None;
166        }
167        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
168            crate::protocol_serde::shape_get_object::de_get_object_http_response(response),
169        ))
170    }
171
172    fn deserialize_nonstreaming(
173        &self,
174        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
175    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
176        // For streaming operations, we only hit this case if its an error
177        let body = response.body().bytes().expect("body loaded");
178        crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_get_object::de_get_object_http_error(
179            response.status().as_u16(),
180            response.headers(),
181            body,
182        ))
183    }
184}
185#[derive(Debug)]
186struct GetObjectRequestSerializer;
187impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetObjectRequestSerializer {
188    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
189    fn serialize_input(
190        &self,
191        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
192        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
193    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
194        let input = input.downcast::<crate::operation::get_object::GetObjectInput>().expect("correct type");
195        let _header_serialization_settings = _cfg
196            .load::<crate::serialization_settings::HeaderSerializationSettings>()
197            .cloned()
198            .unwrap_or_default();
199        let mut request_builder = {
200            fn uri_base(
201                _input: &crate::operation::get_object::GetObjectInput,
202                output: &mut ::std::string::String,
203            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
204                use ::std::fmt::Write as _;
205                let input_1 = &_input.key;
206                let input_1 = input_1
207                    .as_ref()
208                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
209                let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
210                if key.is_empty() {
211                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
212                        "key",
213                        "cannot be empty or unset",
214                    ));
215                }
216                ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
217                ::std::result::Result::Ok(())
218            }
219            fn uri_query(
220                _input: &crate::operation::get_object::GetObjectInput,
221                mut output: &mut ::std::string::String,
222            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
223                let mut query = ::aws_smithy_http::query::Writer::new(output);
224                query.push_kv("x-id", "GetObject");
225                if let ::std::option::Option::Some(inner_2) = &_input.response_cache_control {
226                    {
227                        query.push_kv("response-cache-control", &::aws_smithy_http::query::fmt_string(inner_2));
228                    }
229                }
230                if let ::std::option::Option::Some(inner_3) = &_input.response_content_disposition {
231                    {
232                        query.push_kv("response-content-disposition", &::aws_smithy_http::query::fmt_string(inner_3));
233                    }
234                }
235                if let ::std::option::Option::Some(inner_4) = &_input.response_content_encoding {
236                    {
237                        query.push_kv("response-content-encoding", &::aws_smithy_http::query::fmt_string(inner_4));
238                    }
239                }
240                if let ::std::option::Option::Some(inner_5) = &_input.response_content_language {
241                    {
242                        query.push_kv("response-content-language", &::aws_smithy_http::query::fmt_string(inner_5));
243                    }
244                }
245                if let ::std::option::Option::Some(inner_6) = &_input.response_content_type {
246                    {
247                        query.push_kv("response-content-type", &::aws_smithy_http::query::fmt_string(inner_6));
248                    }
249                }
250                if let ::std::option::Option::Some(inner_7) = &_input.response_expires {
251                    {
252                        query.push_kv(
253                            "response-expires",
254                            &::aws_smithy_http::query::fmt_timestamp(inner_7, ::aws_smithy_types::date_time::Format::HttpDate)?,
255                        );
256                    }
257                }
258                if let ::std::option::Option::Some(inner_8) = &_input.version_id {
259                    {
260                        query.push_kv("versionId", &::aws_smithy_http::query::fmt_string(inner_8));
261                    }
262                }
263                if let ::std::option::Option::Some(inner_9) = &_input.part_number {
264                    {
265                        query.push_kv("partNumber", ::aws_smithy_types::primitive::Encoder::from(*inner_9).encode());
266                    }
267                }
268                ::std::result::Result::Ok(())
269            }
270            #[allow(clippy::unnecessary_wraps)]
271            fn update_http_builder(
272                input: &crate::operation::get_object::GetObjectInput,
273                builder: ::http::request::Builder,
274            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
275                let mut uri = ::std::string::String::new();
276                uri_base(input, &mut uri)?;
277                uri_query(input, &mut uri)?;
278                let builder = crate::protocol_serde::shape_get_object::ser_get_object_headers(input, builder)?;
279                ::std::result::Result::Ok(builder.method("GET").uri(uri))
280            }
281            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
282            builder
283        };
284        let body = ::aws_smithy_types::body::SdkBody::from("");
285
286        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
287    }
288}
289#[derive(Debug)]
290struct GetObjectEndpointParamsInterceptor;
291
292impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetObjectEndpointParamsInterceptor {
293    fn name(&self) -> &'static str {
294        "GetObjectEndpointParamsInterceptor"
295    }
296
297    fn read_before_execution(
298        &self,
299        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
300            '_,
301            ::aws_smithy_runtime_api::client::interceptors::context::Input,
302            ::aws_smithy_runtime_api::client::interceptors::context::Output,
303            ::aws_smithy_runtime_api::client::interceptors::context::Error,
304        >,
305        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
306    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
307        let _input = context
308            .input()
309            .downcast_ref::<GetObjectInput>()
310            .ok_or("failed to downcast to GetObjectInput")?;
311
312        let params = crate::config::endpoint::Params::builder()
313            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
314            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
315            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
316            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
317            .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
318            .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
319            .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
320            .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
321            .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
322            .set_bucket(Some(
323                _input
324                    .bucket
325                    .clone()
326                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
327                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
328            ))
329            .set_key(Some(
330                _input
331                    .key
332                    .clone()
333                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
334                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
335            ))
336            .build()
337            .map_err(|err| {
338                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
339            })?;
340        cfg.interceptor_state()
341            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
342        ::std::result::Result::Ok(())
343    }
344}
345
346// The get_* functions below are generated from JMESPath expressions in the
347// operationContextParams trait. They target the operation's input shape.
348
349#[allow(unreachable_code, unused_variables)]
350#[cfg(test)]
351mod get_object_test {
352
353    /// https://github.com/awslabs/aws-sdk-rust/issues/818
354    /// Test ID: GetObjectIfModifiedSince
355    #[::tokio::test]
356    #[::tracing_test::traced_test]
357    async fn get_object_if_modified_since_request() {
358        let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
359        let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
360        let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
361        let mut config_builder = config_builder;
362        config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
363
364        let config = config_builder.http_client(http_client).build();
365        let client = crate::Client::from_conf(config);
366        let result = client
367            .get_object()
368            .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
369            .set_key(::std::option::Option::Some("object.txt".to_owned()))
370            .set_if_modified_since(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
371                1626452453, 0.123_f64,
372            )))
373            .send()
374            .await;
375        let _ = dbg!(result);
376        let http_request = request_receiver.expect_request();
377        let expected_headers = [("if-modified-since", "Fri, 16 Jul 2021 16:20:53 GMT")];
378        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
379        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
380        ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
381        ::pretty_assertions::assert_eq!(uri.path(), "/object.txt", "path was incorrect");
382    }
383
384    /// S3 clients should not remove dot segments from request paths.
385    ///
386    /// Test ID: S3PreservesLeadingDotSegmentInUriLabel
387    #[::tokio::test]
388    #[::tracing_test::traced_test]
389    async fn s3_preserves_leading_dot_segment_in_uri_label_request() {
390        let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
391        let config_builder = crate::config::Config::builder()
392            .with_test_defaults()
393            .endpoint_url("https://s3.us-west-2.amazonaws.com");
394
395        let mut config_builder = config_builder;
396        config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
397
398        let config = config_builder.http_client(http_client).build();
399        let client = crate::Client::from_conf(config);
400        let result = client
401            .get_object()
402            .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
403            .set_key(::std::option::Option::Some("../key.txt".to_owned()))
404            .send()
405            .await;
406        let _ = dbg!(result);
407        let http_request = request_receiver.expect_request();
408        let body = http_request.body().bytes().expect("body should be strict");
409        // No body.
410        ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
411        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
412        ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
413        ::pretty_assertions::assert_eq!(uri.path(), "/../key.txt", "path was incorrect");
414        ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
415    }
416
417    /// S3 clients should not remove dot segments from request paths.
418    ///
419    /// Test ID: S3PreservesEmbeddedDotSegmentInUriLabel
420    #[::tokio::test]
421    #[::tracing_test::traced_test]
422    async fn s3_preserves_embedded_dot_segment_in_uri_label_request() {
423        let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
424        let config_builder = crate::config::Config::builder()
425            .with_test_defaults()
426            .endpoint_url("https://s3.us-west-2.amazonaws.com");
427
428        let mut config_builder = config_builder;
429        config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
430
431        let config = config_builder.http_client(http_client).build();
432        let client = crate::Client::from_conf(config);
433        let result = client
434            .get_object()
435            .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
436            .set_key(::std::option::Option::Some("foo/../key.txt".to_owned()))
437            .send()
438            .await;
439        let _ = dbg!(result);
440        let http_request = request_receiver.expect_request();
441        let body = http_request.body().bytes().expect("body should be strict");
442        // No body.
443        ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
444        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
445        ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
446        ::pretty_assertions::assert_eq!(uri.path(), "/foo/../key.txt", "path was incorrect");
447        ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
448    }
449}
450
451/// Error type for the `GetObjectError` operation.
452#[non_exhaustive]
453#[derive(::std::fmt::Debug)]
454pub enum GetObjectError {
455    /// <p>Object is archived and inaccessible until restored.</p>
456    /// <p>If the object you are retrieving is stored in the S3 Glacier Flexible Retrieval storage class, the S3 Glacier Deep Archive storage class, the S3 Intelligent-Tiering Archive Access tier, or the S3 Intelligent-Tiering Deep Archive Access tier, before you can retrieve the object you must first restore a copy using <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html">RestoreObject</a>. Otherwise, this operation returns an <code>InvalidObjectState</code> error. For information about restoring archived objects, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/restoring-objects.html">Restoring Archived Objects</a> in the <i>Amazon S3 User Guide</i>.</p>
457    InvalidObjectState(crate::types::error::InvalidObjectState),
458    /// <p>The specified key does not exist.</p>
459    NoSuchKey(crate::types::error::NoSuchKey),
460    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
461    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
462    variable wildcard pattern and check `.code()`:
463     \
464    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
465     \
466    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetObjectError) for what information is available for the error.")]
467    Unhandled(crate::error::sealed_unhandled::Unhandled),
468}
469impl GetObjectError {
470    /// Creates the `GetObjectError::Unhandled` variant from any error type.
471    pub fn unhandled(
472        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
473    ) -> Self {
474        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
475            source: err.into(),
476            meta: ::std::default::Default::default(),
477        })
478    }
479
480    /// Creates the `GetObjectError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
481    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
482        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
483            source: err.clone().into(),
484            meta: err,
485        })
486    }
487    ///
488    /// Returns error metadata, which includes the error code, message,
489    /// request ID, and potentially additional information.
490    ///
491    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
492        match self {
493            Self::InvalidObjectState(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
494            Self::NoSuchKey(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
495            Self::Unhandled(e) => &e.meta,
496        }
497    }
498    /// Returns `true` if the error kind is `GetObjectError::InvalidObjectState`.
499    pub fn is_invalid_object_state(&self) -> bool {
500        matches!(self, Self::InvalidObjectState(_))
501    }
502    /// Returns `true` if the error kind is `GetObjectError::NoSuchKey`.
503    pub fn is_no_such_key(&self) -> bool {
504        matches!(self, Self::NoSuchKey(_))
505    }
506}
507impl ::std::error::Error for GetObjectError {
508    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
509        match self {
510            Self::InvalidObjectState(_inner) => ::std::option::Option::Some(_inner),
511            Self::NoSuchKey(_inner) => ::std::option::Option::Some(_inner),
512            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
513        }
514    }
515}
516impl ::std::fmt::Display for GetObjectError {
517    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
518        match self {
519            Self::InvalidObjectState(_inner) => _inner.fmt(f),
520            Self::NoSuchKey(_inner) => _inner.fmt(f),
521            Self::Unhandled(_inner) => {
522                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
523                    write!(f, "unhandled error ({code})")
524                } else {
525                    f.write_str("unhandled error")
526                }
527            }
528        }
529    }
530}
531impl ::aws_smithy_types::retry::ProvideErrorKind for GetObjectError {
532    fn code(&self) -> ::std::option::Option<&str> {
533        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
534    }
535    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
536        ::std::option::Option::None
537    }
538}
539impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetObjectError {
540    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
541        match self {
542            Self::InvalidObjectState(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
543            Self::NoSuchKey(_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 GetObjectError {
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 crate::s3_request_id::RequestIdExt for crate::operation::get_object::GetObjectError {
560    fn extended_request_id(&self) -> Option<&str> {
561        self.meta().extended_request_id()
562    }
563}
564impl ::aws_types::request_id::RequestId for crate::operation::get_object::GetObjectError {
565    fn request_id(&self) -> Option<&str> {
566        self.meta().request_id()
567    }
568}
569
570pub use crate::operation::get_object::_get_object_output::GetObjectOutput;
571
572pub use crate::operation::get_object::_get_object_input::GetObjectInput;
573
574mod _get_object_input;
575
576mod _get_object_output;
577
578/// Builders
579pub mod builders;