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