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