1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetObject;
6impl GetObject {
7 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 .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 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 if is_presigned_req {
175 return ::std::result::Result::Ok(());
176 }
177
178 #[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
210 ::std::borrow::Cow::Owned(rcb)
211 }
212}
213
214#[derive(Debug)]
215struct GetObjectTelemetryInputCaptureInterceptor;
216
217#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
218impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetObjectTelemetryInputCaptureInterceptor {
219 fn name(&self) -> &'static str {
220 "GetObjectTelemetryInputCaptureInterceptor"
221 }
222
223 fn read_before_execution(
224 &self,
225 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
226 '_,
227 ::aws_smithy_runtime_api::client::interceptors::context::Input,
228 ::aws_smithy_runtime_api::client::interceptors::context::Output,
229 ::aws_smithy_runtime_api::client::interceptors::context::Error,
230 >,
231 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
232 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
233 let ::std::option::Option::Some(requested) = cfg
235 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
236 .filter(|r| !r.is_empty())
237 else {
238 return ::std::result::Result::Ok(());
239 };
240
241 let ::std::option::Option::Some(input) = context.input().downcast_ref::<GetObjectInput>() else {
242 return ::std::result::Result::Ok(());
244 };
245
246 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
247 if requested.should_capture("Bucket") {
248 if let ::std::option::Option::Some(value) = input.bucket.as_deref() {
249 captured.insert("Bucket", value);
250 }
251 }
252 if requested.should_capture("IfMatch") {
253 if let ::std::option::Option::Some(value) = input.if_match.as_deref() {
254 captured.insert("IfMatch", value);
255 }
256 }
257 if requested.should_capture("IfNoneMatch") {
258 if let ::std::option::Option::Some(value) = input.if_none_match.as_deref() {
259 captured.insert("IfNoneMatch", value);
260 }
261 }
262 if requested.should_capture("Key") {
263 if let ::std::option::Option::Some(value) = input.key.as_deref() {
264 captured.insert("Key", value);
265 }
266 }
267 if requested.should_capture("Range") {
268 if let ::std::option::Option::Some(value) = input.range.as_deref() {
269 captured.insert("Range", value);
270 }
271 }
272 if requested.should_capture("ResponseCacheControl") {
273 if let ::std::option::Option::Some(value) = input.response_cache_control.as_deref() {
274 captured.insert("ResponseCacheControl", value);
275 }
276 }
277 if requested.should_capture("ResponseContentDisposition") {
278 if let ::std::option::Option::Some(value) = input.response_content_disposition.as_deref() {
279 captured.insert("ResponseContentDisposition", value);
280 }
281 }
282 if requested.should_capture("ResponseContentEncoding") {
283 if let ::std::option::Option::Some(value) = input.response_content_encoding.as_deref() {
284 captured.insert("ResponseContentEncoding", value);
285 }
286 }
287 if requested.should_capture("ResponseContentLanguage") {
288 if let ::std::option::Option::Some(value) = input.response_content_language.as_deref() {
289 captured.insert("ResponseContentLanguage", value);
290 }
291 }
292 if requested.should_capture("ResponseContentType") {
293 if let ::std::option::Option::Some(value) = input.response_content_type.as_deref() {
294 captured.insert("ResponseContentType", value);
295 }
296 }
297 if requested.should_capture("VersionId") {
298 if let ::std::option::Option::Some(value) = input.version_id.as_deref() {
299 captured.insert("VersionId", value);
300 }
301 }
302 if requested.should_capture("SSECustomerAlgorithm") {
303 if let ::std::option::Option::Some(value) = input.sse_customer_algorithm.as_deref() {
304 captured.insert("SSECustomerAlgorithm", value);
305 }
306 }
307 if requested.should_capture("SSECustomerKeyMD5") {
308 if let ::std::option::Option::Some(value) = input.sse_customer_key_md5.as_deref() {
309 captured.insert("SSECustomerKeyMD5", value);
310 }
311 }
312 if requested.should_capture("ExpectedBucketOwner") {
313 if let ::std::option::Option::Some(value) = input.expected_bucket_owner.as_deref() {
314 captured.insert("ExpectedBucketOwner", value);
315 }
316 }
317
318 cfg.interceptor_state().store_put(captured);
319 ::std::result::Result::Ok(())
320 }
321}
322#[derive(Debug)]
323struct GetObjectResponseDeserializer;
324impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetObjectResponseDeserializer {
325 fn deserialize_streaming(
326 &self,
327 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
328 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
329 #[allow(unused_mut)]
330 let mut force_error = false;
331 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
332 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
333
334 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
336 return ::std::option::Option::None;
337 }
338 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
339 crate::protocol_serde::shape_get_object::de_get_object_http_response(response),
340 ))
341 }
342
343 fn deserialize_nonstreaming_with_config(
344 &self,
345 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
346 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
347 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
348 let body = response.body().bytes().expect("body loaded");
350 crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_get_object::de_get_object_http_error(
351 response.status().as_u16(),
352 response.headers(),
353 body,
354 ))
355 }
356}
357#[derive(Debug)]
358struct GetObjectRequestSerializer;
359impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetObjectRequestSerializer {
360 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
361 fn serialize_input(
362 &self,
363 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
364 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
365 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
366 let input = input.downcast::<crate::operation::get_object::GetObjectInput>().expect("correct type");
367 let _header_serialization_settings = _cfg
368 .load::<crate::serialization_settings::HeaderSerializationSettings>()
369 .cloned()
370 .unwrap_or_default();
371 let mut request_builder = {
372 #[allow(clippy::uninlined_format_args)]
373 fn uri_base(
374 _input: &crate::operation::get_object::GetObjectInput,
375 output: &mut ::std::string::String,
376 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
377 use ::std::fmt::Write as _;
378 let input_1 = &_input.key;
379 let input_1 = input_1
380 .as_ref()
381 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
382 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
383 if key.is_empty() {
384 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
385 "key",
386 "cannot be empty or unset",
387 ));
388 }
389 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
390 ::std::result::Result::Ok(())
391 }
392 fn uri_query(
393 _input: &crate::operation::get_object::GetObjectInput,
394 mut output: &mut ::std::string::String,
395 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
396 let mut query = ::aws_smithy_http::query::Writer::new(output);
397 query.push_kv("x-id", "GetObject");
398 if let ::std::option::Option::Some(inner_2) = &_input.response_cache_control {
399 {
400 query.push_kv("response-cache-control", &::aws_smithy_http::query::fmt_string(inner_2));
401 }
402 }
403 if let ::std::option::Option::Some(inner_3) = &_input.response_content_disposition {
404 {
405 query.push_kv("response-content-disposition", &::aws_smithy_http::query::fmt_string(inner_3));
406 }
407 }
408 if let ::std::option::Option::Some(inner_4) = &_input.response_content_encoding {
409 {
410 query.push_kv("response-content-encoding", &::aws_smithy_http::query::fmt_string(inner_4));
411 }
412 }
413 if let ::std::option::Option::Some(inner_5) = &_input.response_content_language {
414 {
415 query.push_kv("response-content-language", &::aws_smithy_http::query::fmt_string(inner_5));
416 }
417 }
418 if let ::std::option::Option::Some(inner_6) = &_input.response_content_type {
419 {
420 query.push_kv("response-content-type", &::aws_smithy_http::query::fmt_string(inner_6));
421 }
422 }
423 if let ::std::option::Option::Some(inner_7) = &_input.response_expires {
424 {
425 query.push_kv(
426 "response-expires",
427 &::aws_smithy_http::query::fmt_timestamp(inner_7, ::aws_smithy_types::date_time::Format::HttpDate)?,
428 );
429 }
430 }
431 if let ::std::option::Option::Some(inner_8) = &_input.version_id {
432 {
433 query.push_kv("versionId", &::aws_smithy_http::query::fmt_string(inner_8));
434 }
435 }
436 if let ::std::option::Option::Some(inner_9) = &_input.part_number {
437 {
438 query.push_kv("partNumber", ::aws_smithy_types::primitive::Encoder::from(*inner_9).encode());
439 }
440 }
441 ::std::result::Result::Ok(())
442 }
443 #[allow(clippy::unnecessary_wraps)]
444 fn update_http_builder(
445 input: &crate::operation::get_object::GetObjectInput,
446 builder: ::http_1x::request::Builder,
447 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
448 let mut uri = ::std::string::String::new();
449 uri_base(input, &mut uri)?;
450 uri_query(input, &mut uri)?;
451 let builder = crate::protocol_serde::shape_get_object::ser_get_object_headers(input, builder)?;
452 ::std::result::Result::Ok(builder.method("GET").uri(uri))
453 }
454 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
455 builder
456 };
457 let body = ::aws_smithy_types::body::SdkBody::from("");
458
459 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
460 }
461}
462#[derive(Debug)]
463struct GetObjectEndpointParamsInterceptor;
464
465#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
466impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetObjectEndpointParamsInterceptor {
467 fn name(&self) -> &'static str {
468 "GetObjectEndpointParamsInterceptor"
469 }
470
471 fn read_before_execution(
472 &self,
473 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
474 '_,
475 ::aws_smithy_runtime_api::client::interceptors::context::Input,
476 ::aws_smithy_runtime_api::client::interceptors::context::Output,
477 ::aws_smithy_runtime_api::client::interceptors::context::Error,
478 >,
479 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
480 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
481 let _input = context
482 .input()
483 .downcast_ref::<GetObjectInput>()
484 .ok_or("failed to downcast to GetObjectInput")?;
485
486 let params = crate::config::endpoint::Params::builder()
487 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
488 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
489 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
490 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
491 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
492 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
493 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
494 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
495 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
496 .set_bucket(Some(
497 _input
498 .bucket
499 .clone()
500 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
501 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
502 ))
503 .set_key(Some(
504 _input
505 .key
506 .clone()
507 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
508 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
509 ))
510 .build()
511 .map_err(|err| {
512 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
513 })?;
514 cfg.interceptor_state()
515 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
516 ::std::result::Result::Ok(())
517 }
518}
519
520#[allow(unreachable_code, unused_variables)]
524#[cfg(test)]
525mod get_object_test {
526
527 #[::tokio::test]
530 #[::tracing_test::traced_test]
531 async fn get_object_if_modified_since_request() {
532 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
533 let config_builder = crate::config::Config::builder()
534 .with_test_defaults()
535 .allow_no_auth()
538 .endpoint_url("https://example.com");
539 let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
540 let mut config_builder = config_builder;
541 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
542
543 let config = config_builder.http_client(http_client).build();
544 let client = crate::Client::from_conf(config);
545 let result = client
546 .get_object()
547 .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
548 .set_key(::std::option::Option::Some("object.txt".to_owned()))
549 .set_if_modified_since(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
550 1626452453, 0.123_f64,
551 )))
552 .send()
553 .await;
554 let _ = dbg!(result);
555 let http_request = request_receiver.expect_request();
556 let expected_headers = [("if-modified-since", "Fri, 16 Jul 2021 16:20:53 GMT")];
557 ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
558 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
559 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
560 ::pretty_assertions::assert_eq!(uri.path(), "/object.txt", "path was incorrect");
561 }
562
563 #[::tokio::test]
567 #[::tracing_test::traced_test]
568 async fn s3_preserves_leading_dot_segment_in_uri_label_request() {
569 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
570 let config_builder = crate::config::Config::builder()
571 .with_test_defaults()
572 .allow_no_auth()
575 .endpoint_url("https://s3.us-west-2.amazonaws.com");
576
577 let mut config_builder = config_builder;
578 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
579
580 let config = config_builder.http_client(http_client).build();
581 let client = crate::Client::from_conf(config);
582 let result = client
583 .get_object()
584 .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
585 .set_key(::std::option::Option::Some("../key.txt".to_owned()))
586 .send()
587 .await;
588 let _ = dbg!(result);
589 let http_request = request_receiver.expect_request();
590 let body = http_request.body().bytes().expect("body should be strict");
591 ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
593 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
594 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
595 ::pretty_assertions::assert_eq!(uri.path(), "/../key.txt", "path was incorrect");
596 ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
597 }
598
599 #[::tokio::test]
603 #[::tracing_test::traced_test]
604 async fn s3_preserves_embedded_dot_segment_in_uri_label_request() {
605 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
606 let config_builder = crate::config::Config::builder()
607 .with_test_defaults()
608 .allow_no_auth()
611 .endpoint_url("https://s3.us-west-2.amazonaws.com");
612
613 let mut config_builder = config_builder;
614 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
615
616 let config = config_builder.http_client(http_client).build();
617 let client = crate::Client::from_conf(config);
618 let result = client
619 .get_object()
620 .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
621 .set_key(::std::option::Option::Some("foo/../key.txt".to_owned()))
622 .send()
623 .await;
624 let _ = dbg!(result);
625 let http_request = request_receiver.expect_request();
626 let body = http_request.body().bytes().expect("body should be strict");
627 ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
629 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
630 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
631 ::pretty_assertions::assert_eq!(uri.path(), "/foo/../key.txt", "path was incorrect");
632 ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
633 }
634}
635
636#[non_exhaustive]
638#[derive(::std::fmt::Debug)]
639pub enum GetObjectError {
640 InvalidObjectState(crate::types::error::InvalidObjectState),
643 NoSuchKey(crate::types::error::NoSuchKey),
645 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
647 variable wildcard pattern and check `.code()`:
648 \
649 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
650 \
651 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetObjectError) for what information is available for the error.")]
652 Unhandled(crate::error::sealed_unhandled::Unhandled),
653}
654impl GetObjectError {
655 pub fn unhandled(
657 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
658 ) -> Self {
659 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
660 source: err.into(),
661 meta: ::std::default::Default::default(),
662 })
663 }
664
665 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
667 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
668 source: err.clone().into(),
669 meta: err,
670 })
671 }
672 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
677 match self {
678 Self::InvalidObjectState(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
679 Self::NoSuchKey(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
680 Self::Unhandled(e) => &e.meta,
681 }
682 }
683 pub fn is_invalid_object_state(&self) -> bool {
685 matches!(self, Self::InvalidObjectState(_))
686 }
687 pub fn is_no_such_key(&self) -> bool {
689 matches!(self, Self::NoSuchKey(_))
690 }
691}
692impl ::std::error::Error for GetObjectError {
693 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
694 match self {
695 Self::InvalidObjectState(_inner) => ::std::option::Option::Some(_inner),
696 Self::NoSuchKey(_inner) => ::std::option::Option::Some(_inner),
697 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
698 }
699 }
700}
701impl ::std::fmt::Display for GetObjectError {
702 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
703 match self {
704 Self::InvalidObjectState(_inner) => _inner.fmt(f),
705 Self::NoSuchKey(_inner) => _inner.fmt(f),
706 Self::Unhandled(_inner) => {
707 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
708 write!(f, "unhandled error ({code})")
709 } else {
710 f.write_str("unhandled error")
711 }
712 }
713 }
714 }
715}
716impl ::aws_smithy_types::retry::ProvideErrorKind for GetObjectError {
717 fn code(&self) -> ::std::option::Option<&str> {
718 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
719 }
720 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
721 ::std::option::Option::None
722 }
723}
724impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetObjectError {
725 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
726 match self {
727 Self::InvalidObjectState(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
728 Self::NoSuchKey(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
729 Self::Unhandled(_inner) => &_inner.meta,
730 }
731 }
732}
733impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetObjectError {
734 fn create_unhandled_error(
735 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
736 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
737 ) -> Self {
738 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
739 source,
740 meta: meta.unwrap_or_default(),
741 })
742 }
743}
744impl crate::s3_request_id::RequestIdExt for crate::operation::get_object::GetObjectError {
745 fn extended_request_id(&self) -> Option<&str> {
746 self.meta().extended_request_id()
747 }
748}
749impl ::aws_types::request_id::RequestId for crate::operation::get_object::GetObjectError {
750 fn request_id(&self) -> Option<&str> {
751 self.meta().request_id()
752 }
753}
754
755pub use crate::operation::get_object::_get_object_input::GetObjectInput;
756
757pub use crate::operation::get_object::_get_object_output::GetObjectOutput;
758
759mod _get_object_input;
760
761mod _get_object_output;
762
763pub mod builders;