1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct HeadObject;
6impl HeadObject {
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::head_object::HeadObjectInput,
14 ) -> ::std::result::Result<
15 crate::operation::head_object::HeadObjectOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::head_object::HeadObjectError,
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::head_object::HeadObjectError>()
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::head_object::HeadObjectOutput>()
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::head_object::HeadObjectInput,
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", "HeadObject", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "S3.HeadObject",
59 "rpc.service" = "S3",
60 "rpc.method" = "HeadObject",
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 HeadObject {
88 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("HeadObject");
90
91 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92 HeadObjectRequestSerializer,
93 ));
94 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95 HeadObjectResponseDeserializer,
96 ));
97
98 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99 crate::config::auth::Params::builder()
100 .operation_name("HeadObject")
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("HeadObject", "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("HeadObject")
127 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
128 HeadObjectTelemetryInputCaptureInterceptor,
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 HeadObjectEndpointParamsInterceptor,
135 ))
136 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
137 crate::s3_expires_interceptor::S3ExpiresInterceptor,
138 ))
139 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
140 crate::operation::head_object::HeadObjectError,
141 >::new())
142 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
143 crate::operation::head_object::HeadObjectError,
144 >::new())
145 .with_retry_classifier(
146 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::head_object::HeadObjectError>::builder()
147 .transient_errors({
148 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
149 transient_errors.push("InternalError");
150 ::std::borrow::Cow::Owned(transient_errors)
151 })
152 .build(),
153 )
154 .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
155 crate::operation::head_object::HeadObjectError,
156 >::new());
157
158 ::std::borrow::Cow::Owned(rcb)
159 }
160}
161
162#[derive(Debug)]
163struct HeadObjectTelemetryInputCaptureInterceptor;
164
165#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
166impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HeadObjectTelemetryInputCaptureInterceptor {
167 fn name(&self) -> &'static str {
168 "HeadObjectTelemetryInputCaptureInterceptor"
169 }
170
171 fn read_before_execution(
172 &self,
173 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
174 '_,
175 ::aws_smithy_runtime_api::client::interceptors::context::Input,
176 ::aws_smithy_runtime_api::client::interceptors::context::Output,
177 ::aws_smithy_runtime_api::client::interceptors::context::Error,
178 >,
179 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
180 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
181 let ::std::option::Option::Some(requested) = cfg
183 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
184 .filter(|r| !r.is_empty())
185 else {
186 return ::std::result::Result::Ok(());
187 };
188
189 let ::std::option::Option::Some(input) = context.input().downcast_ref::<HeadObjectInput>() else {
190 return ::std::result::Result::Ok(());
192 };
193
194 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
195 if requested.should_capture("Bucket") {
196 if let ::std::option::Option::Some(value) = input.bucket.as_deref() {
197 captured.insert("Bucket", value);
198 }
199 }
200 if requested.should_capture("IfMatch") {
201 if let ::std::option::Option::Some(value) = input.if_match.as_deref() {
202 captured.insert("IfMatch", value);
203 }
204 }
205 if requested.should_capture("IfNoneMatch") {
206 if let ::std::option::Option::Some(value) = input.if_none_match.as_deref() {
207 captured.insert("IfNoneMatch", value);
208 }
209 }
210 if requested.should_capture("Key") {
211 if let ::std::option::Option::Some(value) = input.key.as_deref() {
212 captured.insert("Key", value);
213 }
214 }
215 if requested.should_capture("Range") {
216 if let ::std::option::Option::Some(value) = input.range.as_deref() {
217 captured.insert("Range", value);
218 }
219 }
220 if requested.should_capture("ResponseCacheControl") {
221 if let ::std::option::Option::Some(value) = input.response_cache_control.as_deref() {
222 captured.insert("ResponseCacheControl", value);
223 }
224 }
225 if requested.should_capture("ResponseContentDisposition") {
226 if let ::std::option::Option::Some(value) = input.response_content_disposition.as_deref() {
227 captured.insert("ResponseContentDisposition", value);
228 }
229 }
230 if requested.should_capture("ResponseContentEncoding") {
231 if let ::std::option::Option::Some(value) = input.response_content_encoding.as_deref() {
232 captured.insert("ResponseContentEncoding", value);
233 }
234 }
235 if requested.should_capture("ResponseContentLanguage") {
236 if let ::std::option::Option::Some(value) = input.response_content_language.as_deref() {
237 captured.insert("ResponseContentLanguage", value);
238 }
239 }
240 if requested.should_capture("ResponseContentType") {
241 if let ::std::option::Option::Some(value) = input.response_content_type.as_deref() {
242 captured.insert("ResponseContentType", value);
243 }
244 }
245 if requested.should_capture("VersionId") {
246 if let ::std::option::Option::Some(value) = input.version_id.as_deref() {
247 captured.insert("VersionId", value);
248 }
249 }
250 if requested.should_capture("SSECustomerAlgorithm") {
251 if let ::std::option::Option::Some(value) = input.sse_customer_algorithm.as_deref() {
252 captured.insert("SSECustomerAlgorithm", value);
253 }
254 }
255 if requested.should_capture("SSECustomerKeyMD5") {
256 if let ::std::option::Option::Some(value) = input.sse_customer_key_md5.as_deref() {
257 captured.insert("SSECustomerKeyMD5", value);
258 }
259 }
260 if requested.should_capture("ExpectedBucketOwner") {
261 if let ::std::option::Option::Some(value) = input.expected_bucket_owner.as_deref() {
262 captured.insert("ExpectedBucketOwner", value);
263 }
264 }
265
266 cfg.interceptor_state().store_put(captured);
267 ::std::result::Result::Ok(())
268 }
269}
270#[derive(Debug)]
271struct HeadObjectResponseDeserializer;
272impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HeadObjectResponseDeserializer {
273 fn deserialize_nonstreaming_with_config(
274 &self,
275 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
276 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
277 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
278 let (success, status) = (response.status().is_success(), response.status().as_u16());
279 let headers = response.headers();
280 let body = response.body().bytes().expect("body loaded");
281 #[allow(unused_mut)]
282 let mut force_error = false;
283 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
284 if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
285 force_error = true;
286 }
287 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
288 let parse_result = if !success && status != 200 || force_error {
289 crate::protocol_serde::shape_head_object::de_head_object_http_error(status, headers, body)
290 } else {
291 crate::protocol_serde::shape_head_object::de_head_object_http_response(status, headers, body)
292 };
293 crate::protocol_serde::type_erase_result(parse_result)
294 }
295}
296#[derive(Debug)]
297struct HeadObjectRequestSerializer;
298impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HeadObjectRequestSerializer {
299 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
300 fn serialize_input(
301 &self,
302 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
303 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
304 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
305 let input = input.downcast::<crate::operation::head_object::HeadObjectInput>().expect("correct type");
306 let _header_serialization_settings = _cfg
307 .load::<crate::serialization_settings::HeaderSerializationSettings>()
308 .cloned()
309 .unwrap_or_default();
310 let mut request_builder = {
311 #[allow(clippy::uninlined_format_args)]
312 fn uri_base(
313 _input: &crate::operation::head_object::HeadObjectInput,
314 output: &mut ::std::string::String,
315 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
316 use ::std::fmt::Write as _;
317 let input_1 = &_input.key;
318 let input_1 = input_1
319 .as_ref()
320 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
321 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
322 if key.is_empty() {
323 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
324 "key",
325 "cannot be empty or unset",
326 ));
327 }
328 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
329 ::std::result::Result::Ok(())
330 }
331 fn uri_query(
332 _input: &crate::operation::head_object::HeadObjectInput,
333 mut output: &mut ::std::string::String,
334 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
335 let mut query = ::aws_smithy_http::query::Writer::new(output);
336 if let ::std::option::Option::Some(inner_2) = &_input.response_cache_control {
337 {
338 query.push_kv("response-cache-control", &::aws_smithy_http::query::fmt_string(inner_2));
339 }
340 }
341 if let ::std::option::Option::Some(inner_3) = &_input.response_content_disposition {
342 {
343 query.push_kv("response-content-disposition", &::aws_smithy_http::query::fmt_string(inner_3));
344 }
345 }
346 if let ::std::option::Option::Some(inner_4) = &_input.response_content_encoding {
347 {
348 query.push_kv("response-content-encoding", &::aws_smithy_http::query::fmt_string(inner_4));
349 }
350 }
351 if let ::std::option::Option::Some(inner_5) = &_input.response_content_language {
352 {
353 query.push_kv("response-content-language", &::aws_smithy_http::query::fmt_string(inner_5));
354 }
355 }
356 if let ::std::option::Option::Some(inner_6) = &_input.response_content_type {
357 {
358 query.push_kv("response-content-type", &::aws_smithy_http::query::fmt_string(inner_6));
359 }
360 }
361 if let ::std::option::Option::Some(inner_7) = &_input.response_expires {
362 {
363 query.push_kv(
364 "response-expires",
365 &::aws_smithy_http::query::fmt_timestamp(inner_7, ::aws_smithy_types::date_time::Format::HttpDate)?,
366 );
367 }
368 }
369 if let ::std::option::Option::Some(inner_8) = &_input.version_id {
370 {
371 query.push_kv("versionId", &::aws_smithy_http::query::fmt_string(inner_8));
372 }
373 }
374 if let ::std::option::Option::Some(inner_9) = &_input.part_number {
375 {
376 query.push_kv("partNumber", ::aws_smithy_types::primitive::Encoder::from(*inner_9).encode());
377 }
378 }
379 ::std::result::Result::Ok(())
380 }
381 #[allow(clippy::unnecessary_wraps)]
382 fn update_http_builder(
383 input: &crate::operation::head_object::HeadObjectInput,
384 builder: ::http_1x::request::Builder,
385 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
386 let mut uri = ::std::string::String::new();
387 uri_base(input, &mut uri)?;
388 uri_query(input, &mut uri)?;
389 let builder = crate::protocol_serde::shape_head_object::ser_head_object_headers(input, builder)?;
390 ::std::result::Result::Ok(builder.method("HEAD").uri(uri))
391 }
392 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
393 builder
394 };
395 let body = ::aws_smithy_types::body::SdkBody::from("");
396
397 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
398 }
399}
400#[derive(Debug)]
401struct HeadObjectEndpointParamsInterceptor;
402
403#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
404impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HeadObjectEndpointParamsInterceptor {
405 fn name(&self) -> &'static str {
406 "HeadObjectEndpointParamsInterceptor"
407 }
408
409 fn read_before_execution(
410 &self,
411 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
412 '_,
413 ::aws_smithy_runtime_api::client::interceptors::context::Input,
414 ::aws_smithy_runtime_api::client::interceptors::context::Output,
415 ::aws_smithy_runtime_api::client::interceptors::context::Error,
416 >,
417 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
418 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
419 let _input = context
420 .input()
421 .downcast_ref::<HeadObjectInput>()
422 .ok_or("failed to downcast to HeadObjectInput")?;
423
424 let params = crate::config::endpoint::Params::builder()
425 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
426 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
427 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
428 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
429 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
430 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
431 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
432 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
433 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
434 .set_bucket(Some(
435 _input
436 .bucket
437 .clone()
438 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
439 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
440 ))
441 .set_key(Some(
442 _input
443 .key
444 .clone()
445 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
446 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
447 ))
448 .build()
449 .map_err(|err| {
450 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
451 })?;
452 cfg.interceptor_state()
453 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
454 ::std::result::Result::Ok(())
455 }
456}
457
458#[allow(unreachable_code, unused_variables)]
462#[cfg(test)]
463mod head_object_test {
464
465 #[::tokio::test]
468 #[::tracing_test::traced_test]
469 async fn head_object_uri_encoding_request() {
470 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
471 let config_builder = crate::config::Config::builder()
472 .with_test_defaults()
473 .allow_no_auth()
476 .endpoint_url("https://example.com");
477 let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
478 let mut config_builder = config_builder;
479 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
480
481 let config = config_builder.http_client(http_client).build();
482 let client = crate::Client::from_conf(config);
483 let result = client
484 .head_object()
485 .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
486 .set_key(::std::option::Option::Some("<> `?🐱".to_owned()))
487 .send()
488 .await;
489 let _ = dbg!(result);
490 let http_request = request_receiver.expect_request();
491 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
492 ::pretty_assertions::assert_eq!(http_request.method(), "HEAD", "method was incorrect");
493 ::pretty_assertions::assert_eq!(uri.path(), "/%3C%3E%20%60%3F%F0%9F%90%B1", "path was incorrect");
494 }
495
496 #[::tokio::test]
499 #[::tracing_test::traced_test]
500 async fn head_object_empty_body_response() {
501 let expected_output = crate::types::error::NotFound::builder().build();
502 let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
503 ::http_1x::response::Builder::new()
504 .header("content-type", "application/xml")
505 .header("date", "Thu, 03 Jun 2021 04:05:52 GMT")
506 .header("server", "AmazonS3")
507 .header(
508 "x-amz-id-2",
509 "UTniwu6QmCIjVeuK2ZfeWBOnu7SqMQOS3Vac6B/K4H2ZCawYUl+nDbhGTImuyhZ5DFiojR3Kcz4=",
510 )
511 .header("x-amz-request-id", "GRZ6BZ468DF52F2E")
512 .status(404)
513 .body(::aws_smithy_types::body::SdkBody::from(""))
514 .unwrap(),
515 )
516 .unwrap();
517 use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
518 use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
519
520 let op = crate::operation::head_object::HeadObject::new();
521 let config = op.config().expect("the operation has config");
522 let de = config
523 .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
524 .expect("the config must have a deserializer");
525
526 #[allow(unused_mut)]
528 let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
529
530 let parsed = de.deserialize_streaming(&mut http_response);
531 let parsed = parsed.unwrap_or_else(|| {
532 let http_response = http_response.map(|body| {
533 ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
534 body.bytes().unwrap(),
535 ::aws_smithy_protocol_test::MediaType::from("application/xml"),
536 )))
537 });
538 de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
539 });
540 let parsed = parsed.expect_err("should be error response");
541 let parsed: &crate::operation::head_object::HeadObjectError = parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
542 if let crate::operation::head_object::HeadObjectError::NotFound(parsed) = parsed {
543 ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
544 } else {
545 panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
546 }
547 }
548}
549
550#[non_exhaustive]
552#[derive(::std::fmt::Debug)]
553pub enum HeadObjectError {
554 NotFound(crate::types::error::NotFound),
556 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
558 variable wildcard pattern and check `.code()`:
559 \
560 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
561 \
562 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-HeadObjectError) for what information is available for the error.")]
563 Unhandled(crate::error::sealed_unhandled::Unhandled),
564}
565impl HeadObjectError {
566 pub fn unhandled(
568 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
569 ) -> Self {
570 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
571 source: err.into(),
572 meta: ::std::default::Default::default(),
573 })
574 }
575
576 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
578 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
579 source: err.clone().into(),
580 meta: err,
581 })
582 }
583 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
588 match self {
589 Self::NotFound(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
590 Self::Unhandled(e) => &e.meta,
591 }
592 }
593 pub fn is_not_found(&self) -> bool {
595 matches!(self, Self::NotFound(_))
596 }
597}
598impl ::std::error::Error for HeadObjectError {
599 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
600 match self {
601 Self::NotFound(_inner) => ::std::option::Option::Some(_inner),
602 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
603 }
604 }
605}
606impl ::std::fmt::Display for HeadObjectError {
607 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
608 match self {
609 Self::NotFound(_inner) => _inner.fmt(f),
610 Self::Unhandled(_inner) => {
611 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
612 write!(f, "unhandled error ({code})")
613 } else {
614 f.write_str("unhandled error")
615 }
616 }
617 }
618 }
619}
620impl ::aws_smithy_types::retry::ProvideErrorKind for HeadObjectError {
621 fn code(&self) -> ::std::option::Option<&str> {
622 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
623 }
624 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
625 ::std::option::Option::None
626 }
627}
628impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for HeadObjectError {
629 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
630 match self {
631 Self::NotFound(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
632 Self::Unhandled(_inner) => &_inner.meta,
633 }
634 }
635}
636impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for HeadObjectError {
637 fn create_unhandled_error(
638 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
639 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
640 ) -> Self {
641 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
642 source,
643 meta: meta.unwrap_or_default(),
644 })
645 }
646}
647impl crate::s3_request_id::RequestIdExt for crate::operation::head_object::HeadObjectError {
648 fn extended_request_id(&self) -> Option<&str> {
649 self.meta().extended_request_id()
650 }
651}
652impl ::aws_types::request_id::RequestId for crate::operation::head_object::HeadObjectError {
653 fn request_id(&self) -> Option<&str> {
654 self.meta().request_id()
655 }
656}
657
658pub use crate::operation::head_object::_head_object_input::HeadObjectInput;
659
660pub use crate::operation::head_object::_head_object_output::HeadObjectOutput;
661
662mod _head_object_input;
663
664mod _head_object_output;
665
666pub mod builders;