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