aws_sdk_cloudwatch/protocol_serde/
shape_list_dashboards.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_dashboards_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::list_dashboards::ListDashboardsOutput, crate::operation::list_dashboards::ListDashboardsError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::list_dashboards::ListDashboardsError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::list_dashboards::ListDashboardsError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "InternalServiceError" => crate::operation::list_dashboards::ListDashboardsError::InternalServiceFault({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::InternalServiceFaultBuilder::default();
25                output = crate::protocol_serde::shape_internal_service_fault::de_internal_service_fault_xml_err(_response_body, output)
26                    .map_err(crate::operation::list_dashboards::ListDashboardsError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        "InvalidParameterValue" => crate::operation::list_dashboards::ListDashboardsError::InvalidParameterValueException({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
40                output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_xml_err(
41                    _response_body,
42                    output,
43                )
44                .map_err(crate::operation::list_dashboards::ListDashboardsError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        _ => crate::operation::list_dashboards::ListDashboardsError::generic(generic),
54    })
55}
56
57#[allow(clippy::unnecessary_wraps)]
58pub fn de_list_dashboards_http_response(
59    _response_status: u16,
60    _response_headers: &::aws_smithy_runtime_api::http::Headers,
61    _response_body: &[u8],
62) -> std::result::Result<crate::operation::list_dashboards::ListDashboardsOutput, crate::operation::list_dashboards::ListDashboardsError> {
63    Ok({
64        #[allow(unused_mut)]
65        let mut output = crate::operation::list_dashboards::builders::ListDashboardsOutputBuilder::default();
66        output = crate::protocol_serde::shape_list_dashboards::de_list_dashboards(_response_body, output)
67            .map_err(crate::operation::list_dashboards::ListDashboardsError::unhandled)?;
68        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
69        output.build()
70    })
71}
72
73#[allow(unused_mut)]
74pub fn de_list_dashboards(
75    inp: &[u8],
76    mut builder: crate::operation::list_dashboards::builders::ListDashboardsOutputBuilder,
77) -> std::result::Result<crate::operation::list_dashboards::builders::ListDashboardsOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
78    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
79
80    #[allow(unused_mut)]
81    let mut decoder = doc.root_element()?;
82    #[allow(unused_variables)]
83    let start_el = decoder.start_el();
84    if !(start_el.matches("ListDashboardsResponse")) {
85        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
86            "invalid root, expected ListDashboardsResponse got {:?}",
87            start_el
88        )));
89    }
90    if let Some(mut result_tag) = decoder.next_tag() {
91        let start_el = result_tag.start_el();
92        if !(start_el.matches("ListDashboardsResult")) {
93            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
94                "invalid result, expected ListDashboardsResult got {:?}",
95                start_el
96            )));
97        }
98        while let Some(mut tag) = result_tag.next_tag() {
99            match tag.start_el() {
100            s if s.matches("DashboardEntries") /* DashboardEntries com.amazonaws.cloudwatch.synthetic#ListDashboardsOutput$DashboardEntries */ =>  {
101                let var_1 =
102                    Some(
103                        crate::protocol_serde::shape_dashboard_entries::de_dashboard_entries(&mut tag)
104                        ?
105                    )
106                ;
107                builder = builder.set_dashboard_entries(var_1);
108            }
109            ,
110            s if s.matches("NextToken") /* NextToken com.amazonaws.cloudwatch.synthetic#ListDashboardsOutput$NextToken */ =>  {
111                let var_2 =
112                    Some(
113                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
114                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
115                            .into()
116                        )
117                        ?
118                    )
119                ;
120                builder = builder.set_next_token(var_2);
121            }
122            ,
123            _ => {}
124        }
125        }
126    } else {
127        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected ListDashboardsResult tag"));
128    };
129    Ok(builder)
130}