Skip to main content

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