Skip to main content

aws_sdk_s3/operation/
list_objects.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `ListObjects`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ListObjects;
6impl ListObjects {
7    /// Creates a new `ListObjects`
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::list_objects::ListObjectsInput,
14    ) -> ::std::result::Result<
15        crate::operation::list_objects::ListObjectsOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::list_objects::ListObjectsError,
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::list_objects::ListObjectsError>()
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::list_objects::ListObjectsOutput>()
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::list_objects::ListObjectsInput,
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", "ListObjects", 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.ListObjects",
59                "rpc.service" = "S3",
60                "rpc.method" = "ListObjects",
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 ListObjects {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ListObjects");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            ListObjectsRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            ListObjectsResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("ListObjects")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("ListObjects", "S3"));
106        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
107        signing_options.double_uri_encode = false;
108        signing_options.content_sha256_header = true;
109        signing_options.normalize_uri_path = false;
110        signing_options.payload_override = None;
111
112        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
113            signing_options,
114            ..::std::default::Default::default()
115        });
116
117        ::std::option::Option::Some(cfg.freeze())
118    }
119
120    fn runtime_components(
121        &self,
122        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
123    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
124        #[allow(unused_mut)]
125        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ListObjects")
126            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
127                ListObjectsTelemetryInputCaptureInterceptor,
128            ))
129            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
130                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
131            ))
132            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
133                ListObjectsEndpointParamsInterceptor,
134            ))
135            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
136                crate::operation::list_objects::ListObjectsError,
137            >::new())
138            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
139                crate::operation::list_objects::ListObjectsError,
140            >::new())
141            .with_retry_classifier(
142                ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::list_objects::ListObjectsError>::builder()
143                    .transient_errors({
144                        let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
145                        transient_errors.push("InternalError");
146                        ::std::borrow::Cow::Owned(transient_errors)
147                    })
148                    .build(),
149            )
150            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
151                crate::operation::list_objects::ListObjectsError,
152            >::new());
153
154        ::std::borrow::Cow::Owned(rcb)
155    }
156}
157
158#[derive(Debug)]
159struct ListObjectsTelemetryInputCaptureInterceptor;
160
161#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
162impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListObjectsTelemetryInputCaptureInterceptor {
163    fn name(&self) -> &'static str {
164        "ListObjectsTelemetryInputCaptureInterceptor"
165    }
166
167    fn read_before_execution(
168        &self,
169        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
170            '_,
171            ::aws_smithy_runtime_api::client::interceptors::context::Input,
172            ::aws_smithy_runtime_api::client::interceptors::context::Output,
173            ::aws_smithy_runtime_api::client::interceptors::context::Error,
174        >,
175        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
176    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
177        // Nothing to do unless the customer opted in by naming members to record.
178        let ::std::option::Option::Some(requested) = cfg
179            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
180            .filter(|r| !r.is_empty())
181        else {
182            return ::std::result::Result::Ok(());
183        };
184
185        let ::std::option::Option::Some(input) = context.input().downcast_ref::<ListObjectsInput>() else {
186            // A mismatched input is not this interceptor's concern; skip quietly.
187            return ::std::result::Result::Ok(());
188        };
189
190        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
191        if requested.should_capture("Bucket") {
192            if let ::std::option::Option::Some(value) = input.bucket.as_deref() {
193                captured.insert("Bucket", value);
194            }
195        }
196        if requested.should_capture("Delimiter") {
197            if let ::std::option::Option::Some(value) = input.delimiter.as_deref() {
198                captured.insert("Delimiter", value);
199            }
200        }
201        if requested.should_capture("Marker") {
202            if let ::std::option::Option::Some(value) = input.marker.as_deref() {
203                captured.insert("Marker", value);
204            }
205        }
206        if requested.should_capture("Prefix") {
207            if let ::std::option::Option::Some(value) = input.prefix.as_deref() {
208                captured.insert("Prefix", value);
209            }
210        }
211        if requested.should_capture("ExpectedBucketOwner") {
212            if let ::std::option::Option::Some(value) = input.expected_bucket_owner.as_deref() {
213                captured.insert("ExpectedBucketOwner", value);
214            }
215        }
216
217        cfg.interceptor_state().store_put(captured);
218        ::std::result::Result::Ok(())
219    }
220}
221#[derive(Debug)]
222struct ListObjectsResponseDeserializer;
223impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ListObjectsResponseDeserializer {
224    fn deserialize_nonstreaming_with_config(
225        &self,
226        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
227        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
228    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
229        let (success, status) = (response.status().is_success(), response.status().as_u16());
230        let headers = response.headers();
231        let body = response.body().bytes().expect("body loaded");
232        #[allow(unused_mut)]
233        let mut force_error = false;
234        ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
235        if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
236            force_error = true;
237        }
238        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
239        let parse_result = if !success && status != 200 || force_error {
240            crate::protocol_serde::shape_list_objects::de_list_objects_http_error(status, headers, body)
241        } else {
242            crate::protocol_serde::shape_list_objects::de_list_objects_http_response(status, headers, body)
243        };
244        crate::protocol_serde::type_erase_result(parse_result)
245    }
246}
247#[derive(Debug)]
248struct ListObjectsRequestSerializer;
249impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ListObjectsRequestSerializer {
250    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
251    fn serialize_input(
252        &self,
253        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
254        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
255    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
256        let input = input
257            .downcast::<crate::operation::list_objects::ListObjectsInput>()
258            .expect("correct type");
259        let _header_serialization_settings = _cfg
260            .load::<crate::serialization_settings::HeaderSerializationSettings>()
261            .cloned()
262            .unwrap_or_default();
263        let mut request_builder = {
264            #[allow(clippy::uninlined_format_args)]
265            fn uri_base(
266                _input: &crate::operation::list_objects::ListObjectsInput,
267                output: &mut ::std::string::String,
268            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
269                use ::std::fmt::Write as _;
270                ::std::write!(output, "/").expect("formatting should succeed");
271                ::std::result::Result::Ok(())
272            }
273            fn uri_query(
274                _input: &crate::operation::list_objects::ListObjectsInput,
275                mut output: &mut ::std::string::String,
276            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
277                let mut query = ::aws_smithy_http::query::Writer::new(output);
278                if let ::std::option::Option::Some(inner_1) = &_input.delimiter {
279                    {
280                        query.push_kv("delimiter", &::aws_smithy_http::query::fmt_string(inner_1));
281                    }
282                }
283                if let ::std::option::Option::Some(inner_2) = &_input.encoding_type {
284                    {
285                        query.push_kv("encoding-type", &::aws_smithy_http::query::fmt_string(inner_2.as_str()));
286                    }
287                }
288                if let ::std::option::Option::Some(inner_3) = &_input.marker {
289                    {
290                        query.push_kv("marker", &::aws_smithy_http::query::fmt_string(inner_3));
291                    }
292                }
293                if let ::std::option::Option::Some(inner_4) = &_input.max_keys {
294                    {
295                        query.push_kv("max-keys", ::aws_smithy_types::primitive::Encoder::from(*inner_4).encode());
296                    }
297                }
298                if let ::std::option::Option::Some(inner_5) = &_input.prefix {
299                    {
300                        query.push_kv("prefix", &::aws_smithy_http::query::fmt_string(inner_5));
301                    }
302                }
303                ::std::result::Result::Ok(())
304            }
305            #[allow(clippy::unnecessary_wraps)]
306            fn update_http_builder(
307                input: &crate::operation::list_objects::ListObjectsInput,
308                builder: ::http_1x::request::Builder,
309            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
310                let mut uri = ::std::string::String::new();
311                uri_base(input, &mut uri)?;
312                uri_query(input, &mut uri)?;
313                let builder = crate::protocol_serde::shape_list_objects::ser_list_objects_headers(input, builder)?;
314                ::std::result::Result::Ok(builder.method("GET").uri(uri))
315            }
316            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
317            builder
318        };
319        let body = ::aws_smithy_types::body::SdkBody::from("");
320
321        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
322    }
323}
324#[derive(Debug)]
325struct ListObjectsEndpointParamsInterceptor;
326
327#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
328impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListObjectsEndpointParamsInterceptor {
329    fn name(&self) -> &'static str {
330        "ListObjectsEndpointParamsInterceptor"
331    }
332
333    fn read_before_execution(
334        &self,
335        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
336            '_,
337            ::aws_smithy_runtime_api::client::interceptors::context::Input,
338            ::aws_smithy_runtime_api::client::interceptors::context::Output,
339            ::aws_smithy_runtime_api::client::interceptors::context::Error,
340        >,
341        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
342    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
343        let _input = context
344            .input()
345            .downcast_ref::<ListObjectsInput>()
346            .ok_or("failed to downcast to ListObjectsInput")?;
347
348        let params = crate::config::endpoint::Params::builder()
349            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
350            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
351            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
352            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
353            .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
354            .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
355            .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
356            .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
357            .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
358            .set_bucket(Some(
359                _input
360                    .bucket
361                    .clone()
362                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
363                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
364            ))
365            .set_prefix(_input.prefix.clone())
366            .build()
367            .map_err(|err| {
368                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
369            })?;
370        cfg.interceptor_state()
371            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
372        ::std::result::Result::Ok(())
373    }
374}
375
376// The get_* functions below are generated from JMESPath expressions in the
377// operationContextParams trait. They target the operation's input shape.
378
379#[allow(unreachable_code, unused_variables)]
380#[cfg(test)]
381mod list_objects_test {
382
383    /// This test validates that parsing respects whitespace
384    /// Test ID: KeysWithWhitespace
385    #[::tokio::test]
386    #[::tracing_test::traced_test]
387    async fn keys_with_whitespace_response() {
388        let expected_output = crate::operation::list_objects::ListObjectsOutput::builder()
389            .set_max_keys(::std::option::Option::Some(1000))
390            .set_is_truncated(::std::option::Option::Some(false))
391            .set_marker(::std::option::Option::Some("".to_owned()))
392            .set_name(::std::option::Option::Some("bucketname".to_owned()))
393            .set_prefix(::std::option::Option::Some("".to_owned()))
394            .set_contents(::std::option::Option::Some(vec![
395                crate::types::Object::builder()
396                    .set_key(::std::option::Option::Some("    ".to_owned()))
397                    .set_last_modified(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
398                        1626452453, 0_f64,
399                    )))
400                    .set_e_tag(::std::option::Option::Some("\"etag123\"".to_owned()))
401                    .set_size(::std::option::Option::Some(0))
402                    .set_owner(::std::option::Option::Some(
403                        crate::types::Owner::builder()
404                            .set_id(::std::option::Option::Some("owner".to_owned()))
405                            .build(),
406                    ))
407                    .set_storage_class(::std::option::Option::Some(
408                        "STANDARD"
409                            .parse::<crate::types::ObjectStorageClass>()
410                            .expect("static value validated to member"),
411                    ))
412                    .build(),
413                crate::types::Object::builder()
414                    .set_key(::std::option::Option::Some(" a ".to_owned()))
415                    .set_last_modified(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
416                        1626451330, 0_f64,
417                    )))
418                    .set_e_tag(::std::option::Option::Some("\"etag123\"".to_owned()))
419                    .set_size(::std::option::Option::Some(0))
420                    .set_owner(::std::option::Option::Some(
421                        crate::types::Owner::builder()
422                            .set_id(::std::option::Option::Some("owner".to_owned()))
423                            .build(),
424                    ))
425                    .set_storage_class(::std::option::Option::Some(
426                        "STANDARD"
427                            .parse::<crate::types::ObjectStorageClass>()
428                            .expect("static value validated to member"),
429                    ))
430                    .build(),
431            ]))
432            .build();
433        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
434        .status(200)
435                    .body(::aws_smithy_types::body::SdkBody::from("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<ListBucketResult\n\txmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n\t<Name>bucketname</Name>\n\t<Prefix></Prefix>\n\t<Marker></Marker>\n\t<MaxKeys>1000</MaxKeys>\n\t<IsTruncated>false</IsTruncated>\n\t<Contents>\n\t\t<Key>    </Key>\n\t\t<LastModified>2021-07-16T16:20:53.000Z</LastModified>\n\t\t<ETag>&quot;etag123&quot;</ETag>\n\t\t<Size>0</Size>\n\t\t<Owner>\n\t\t\t<ID>owner</ID>\n\t\t</Owner>\n\t\t<StorageClass>STANDARD</StorageClass>\n\t</Contents>\n\t<Contents>\n\t\t<Key> a </Key>\n\t\t<LastModified>2021-07-16T16:02:10.000Z</LastModified>\n\t\t<ETag>&quot;etag123&quot;</ETag>\n\t\t<Size>0</Size>\n\t\t<Owner>\n\t\t\t<ID>owner</ID>\n\t\t</Owner>\n\t\t<StorageClass>STANDARD</StorageClass>\n\t</Contents>\n</ListBucketResult>\n"))
436                    .unwrap()
437                    ).unwrap();
438        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
439        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
440
441        let op = crate::operation::list_objects::ListObjects::new();
442        let config = op.config().expect("the operation has config");
443        let de = config
444            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
445            .expect("the config must have a deserializer");
446
447        // Build a config bag with the protocol for schema-based deserialization
448        #[allow(unused_mut)]
449        let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
450
451        let parsed = de.deserialize_streaming(&mut http_response);
452        let parsed = parsed.unwrap_or_else(|| {
453            let http_response = http_response.map(|body| {
454                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
455                    body.bytes().unwrap(),
456                    ::aws_smithy_protocol_test::MediaType::from("application/xml"),
457                )))
458            });
459            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
460        });
461        let parsed = parsed
462            .expect("should be successful response")
463            .downcast::<crate::operation::list_objects::ListObjectsOutput>()
464            .unwrap();
465        ::pretty_assertions::assert_eq!(parsed.is_truncated, expected_output.is_truncated, "Unexpected value for `is_truncated`");
466        ::pretty_assertions::assert_eq!(parsed.marker, expected_output.marker, "Unexpected value for `marker`");
467        ::pretty_assertions::assert_eq!(parsed.next_marker, expected_output.next_marker, "Unexpected value for `next_marker`");
468        ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
469        ::pretty_assertions::assert_eq!(parsed.name, expected_output.name, "Unexpected value for `name`");
470        ::pretty_assertions::assert_eq!(parsed.prefix, expected_output.prefix, "Unexpected value for `prefix`");
471        ::pretty_assertions::assert_eq!(parsed.delimiter, expected_output.delimiter, "Unexpected value for `delimiter`");
472        ::pretty_assertions::assert_eq!(parsed.max_keys, expected_output.max_keys, "Unexpected value for `max_keys`");
473        ::pretty_assertions::assert_eq!(
474            parsed.common_prefixes,
475            expected_output.common_prefixes,
476            "Unexpected value for `common_prefixes`"
477        );
478        ::pretty_assertions::assert_eq!(
479            parsed.encoding_type,
480            expected_output.encoding_type,
481            "Unexpected value for `encoding_type`"
482        );
483        ::pretty_assertions::assert_eq!(
484            parsed.request_charged,
485            expected_output.request_charged,
486            "Unexpected value for `request_charged`"
487        );
488    }
489}
490
491/// Error type for the `ListObjectsError` operation.
492#[non_exhaustive]
493#[derive(::std::fmt::Debug)]
494pub enum ListObjectsError {
495    /// <p>The specified bucket does not exist.</p>
496    NoSuchBucket(crate::types::error::NoSuchBucket),
497    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
498    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
499    variable wildcard pattern and check `.code()`:
500     \
501    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
502     \
503    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ListObjectsError) for what information is available for the error.")]
504    Unhandled(crate::error::sealed_unhandled::Unhandled),
505}
506impl ListObjectsError {
507    /// Creates the `ListObjectsError::Unhandled` variant from any error type.
508    pub fn unhandled(
509        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
510    ) -> Self {
511        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
512            source: err.into(),
513            meta: ::std::default::Default::default(),
514        })
515    }
516
517    /// Creates the `ListObjectsError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
518    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
519        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
520            source: err.clone().into(),
521            meta: err,
522        })
523    }
524    ///
525    /// Returns error metadata, which includes the error code, message,
526    /// request ID, and potentially additional information.
527    ///
528    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
529        match self {
530            Self::NoSuchBucket(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
531            Self::Unhandled(e) => &e.meta,
532        }
533    }
534    /// Returns `true` if the error kind is `ListObjectsError::NoSuchBucket`.
535    pub fn is_no_such_bucket(&self) -> bool {
536        matches!(self, Self::NoSuchBucket(_))
537    }
538}
539impl ::std::error::Error for ListObjectsError {
540    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
541        match self {
542            Self::NoSuchBucket(_inner) => ::std::option::Option::Some(_inner),
543            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
544        }
545    }
546}
547impl ::std::fmt::Display for ListObjectsError {
548    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
549        match self {
550            Self::NoSuchBucket(_inner) => _inner.fmt(f),
551            Self::Unhandled(_inner) => {
552                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
553                    write!(f, "unhandled error ({code})")
554                } else {
555                    f.write_str("unhandled error")
556                }
557            }
558        }
559    }
560}
561impl ::aws_smithy_types::retry::ProvideErrorKind for ListObjectsError {
562    fn code(&self) -> ::std::option::Option<&str> {
563        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
564    }
565    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
566        ::std::option::Option::None
567    }
568}
569impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ListObjectsError {
570    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
571        match self {
572            Self::NoSuchBucket(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
573            Self::Unhandled(_inner) => &_inner.meta,
574        }
575    }
576}
577impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ListObjectsError {
578    fn create_unhandled_error(
579        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
580        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
581    ) -> Self {
582        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
583            source,
584            meta: meta.unwrap_or_default(),
585        })
586    }
587}
588impl crate::s3_request_id::RequestIdExt for crate::operation::list_objects::ListObjectsError {
589    fn extended_request_id(&self) -> Option<&str> {
590        self.meta().extended_request_id()
591    }
592}
593impl ::aws_types::request_id::RequestId for crate::operation::list_objects::ListObjectsError {
594    fn request_id(&self) -> Option<&str> {
595        self.meta().request_id()
596    }
597}
598
599pub use crate::operation::list_objects::_list_objects_input::ListObjectsInput;
600
601pub use crate::operation::list_objects::_list_objects_output::ListObjectsOutput;
602
603mod _list_objects_input;
604
605mod _list_objects_output;
606
607/// Builders
608pub mod builders;