aws_sdk_s3/protocol_serde/
shape_list_bucket_metrics_configurations.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_bucket_metrics_configurations_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsOutput,
9    crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsError::unhandled)?;
14    generic_builder = crate::s3_request_id::apply_extended_request_id(generic_builder, _response_headers);
15    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
16    let generic = generic_builder.build();
17    Err(crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsError::generic(generic))
18}
19
20#[allow(clippy::unnecessary_wraps)]
21pub fn de_list_bucket_metrics_configurations_http_response(
22    _response_status: u16,
23    _response_headers: &::aws_smithy_runtime_api::http::Headers,
24    _response_body: &[u8],
25) -> std::result::Result<
26    crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsOutput,
27    crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsError,
28> {
29    Ok({
30        #[allow(unused_mut)]
31        let mut output = crate::operation::list_bucket_metrics_configurations::builders::ListBucketMetricsConfigurationsOutputBuilder::default();
32        output = crate::protocol_serde::shape_list_bucket_metrics_configurations::de_list_bucket_metrics_configurations(_response_body, output)
33            .map_err(crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsError::unhandled)?;
34        output._set_extended_request_id(crate::s3_request_id::RequestIdExt::extended_request_id(_response_headers).map(str::to_string));
35        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
36        output.build()
37    })
38}
39
40pub fn ser_list_bucket_metrics_configurations_headers(
41    input: &crate::operation::list_bucket_metrics_configurations::ListBucketMetricsConfigurationsInput,
42    mut builder: ::http::request::Builder,
43) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
44    if let ::std::option::Option::Some(inner_1) = &input.expected_bucket_owner {
45        let formatted_2 = inner_1.as_str();
46        let header_value = formatted_2;
47        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
48            ::aws_smithy_types::error::operation::BuildError::invalid_field(
49                "expected_bucket_owner",
50                format!("`{}` cannot be used as a header value: {}", &header_value, err),
51            )
52        })?;
53        builder = builder.header("x-amz-expected-bucket-owner", header_value);
54    }
55    Ok(builder)
56}
57
58#[allow(unused_mut)]
59pub fn de_list_bucket_metrics_configurations(
60    inp: &[u8],
61    mut builder: crate::operation::list_bucket_metrics_configurations::builders::ListBucketMetricsConfigurationsOutputBuilder,
62) -> std::result::Result<
63    crate::operation::list_bucket_metrics_configurations::builders::ListBucketMetricsConfigurationsOutputBuilder,
64    ::aws_smithy_xml::decode::XmlDecodeError,
65> {
66    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
67
68    #[allow(unused_mut)]
69    let mut decoder = doc.root_element()?;
70    #[allow(unused_variables)]
71    let start_el = decoder.start_el();
72    if !start_el.matches("ListMetricsConfigurationsResult") {
73        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
74            "encountered invalid XML root: expected ListMetricsConfigurationsResult but got {:?}. This is likely a bug in the SDK.",
75            start_el
76        )));
77    }
78    while let Some(mut tag) = decoder.next_tag() {
79        match tag.start_el() {
80            s if s.matches("NextContinuationToken") /* NextContinuationToken com.amazonaws.s3.synthetic#ListBucketMetricsConfigurationsOutput$NextContinuationToken */ =>  {
81                let var_3 =
82                    Some(
83                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
84                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
85                            .into()
86                        )
87                        ?
88                    )
89                ;
90                builder = builder.set_next_continuation_token(var_3);
91            }
92            ,
93            s if s.matches("ContinuationToken") /* ContinuationToken com.amazonaws.s3.synthetic#ListBucketMetricsConfigurationsOutput$ContinuationToken */ =>  {
94                let var_4 =
95                    Some(
96                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
97                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
98                            .into()
99                        )
100                        ?
101                    )
102                ;
103                builder = builder.set_continuation_token(var_4);
104            }
105            ,
106            s if s.matches("MetricsConfiguration") /* MetricsConfigurationList com.amazonaws.s3.synthetic#ListBucketMetricsConfigurationsOutput$MetricsConfigurationList */ =>  {
107                let var_5 =
108                    Some(
109                        Result::<::std::vec::Vec::<crate::types::MetricsConfiguration>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
110                            let mut list_6 = builder.metrics_configuration_list.take().unwrap_or_default();
111                            list_6.push(
112                                crate::protocol_serde::shape_metrics_configuration::de_metrics_configuration(&mut tag)
113                                ?
114                            );
115                            list_6
116                        })
117                        ?
118                    )
119                ;
120                builder = builder.set_metrics_configuration_list(var_5);
121            }
122            ,
123            s if s.matches("IsTruncated") /* IsTruncated com.amazonaws.s3.synthetic#ListBucketMetricsConfigurationsOutput$IsTruncated */ =>  {
124                let var_7 =
125                    Some(
126                         {
127                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
128                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
129                            )
130                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.s3#IsTruncated`)"))
131                        }
132                        ?
133                    )
134                ;
135                builder = builder.set_is_truncated(var_7);
136            }
137            ,
138            _ => {}
139        }
140    }
141    Ok(builder)
142}