aws_sdk_cloudformation/protocol_serde/
shape_list_resource_scan_resources.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_resource_scan_resources_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_resource_scan_resources::ListResourceScanResourcesOutput,
9    crate::operation::list_resource_scan_resources::ListResourceScanResourcesError,
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_resource_scan_resources::ListResourceScanResourcesError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => {
19            return Err(crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "ResourceScanInProgress" => {
28            crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::ResourceScanInProgressException({
29                #[allow(unused_mut)]
30                let mut tmp = {
31                    #[allow(unused_mut)]
32                    let mut output = crate::types::error::builders::ResourceScanInProgressExceptionBuilder::default();
33                    output = crate::protocol_serde::shape_resource_scan_in_progress_exception::de_resource_scan_in_progress_exception_xml_err(
34                        _response_body,
35                        output,
36                    )
37                    .map_err(crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::unhandled)?;
38                    let output = output.meta(generic);
39                    output.build()
40                };
41                if tmp.message.is_none() {
42                    tmp.message = _error_message;
43                }
44                tmp
45            })
46        }
47        "ResourceScanNotFound" => crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::ResourceScanNotFoundException({
48            #[allow(unused_mut)]
49            let mut tmp = {
50                #[allow(unused_mut)]
51                let mut output = crate::types::error::builders::ResourceScanNotFoundExceptionBuilder::default();
52                output = crate::protocol_serde::shape_resource_scan_not_found_exception::de_resource_scan_not_found_exception_xml_err(
53                    _response_body,
54                    output,
55                )
56                .map_err(crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::unhandled)?;
57                let output = output.meta(generic);
58                output.build()
59            };
60            if tmp.message.is_none() {
61                tmp.message = _error_message;
62            }
63            tmp
64        }),
65        _ => crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::generic(generic),
66    })
67}
68
69#[allow(clippy::unnecessary_wraps)]
70pub fn de_list_resource_scan_resources_http_response(
71    _response_status: u16,
72    _response_headers: &::aws_smithy_runtime_api::http::Headers,
73    _response_body: &[u8],
74) -> std::result::Result<
75    crate::operation::list_resource_scan_resources::ListResourceScanResourcesOutput,
76    crate::operation::list_resource_scan_resources::ListResourceScanResourcesError,
77> {
78    Ok({
79        #[allow(unused_mut)]
80        let mut output = crate::operation::list_resource_scan_resources::builders::ListResourceScanResourcesOutputBuilder::default();
81        output = crate::protocol_serde::shape_list_resource_scan_resources::de_list_resource_scan_resources(_response_body, output)
82            .map_err(crate::operation::list_resource_scan_resources::ListResourceScanResourcesError::unhandled)?;
83        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
84        output.build()
85    })
86}
87
88#[allow(unused_mut)]
89pub fn de_list_resource_scan_resources(
90    inp: &[u8],
91    mut builder: crate::operation::list_resource_scan_resources::builders::ListResourceScanResourcesOutputBuilder,
92) -> std::result::Result<
93    crate::operation::list_resource_scan_resources::builders::ListResourceScanResourcesOutputBuilder,
94    ::aws_smithy_xml::decode::XmlDecodeError,
95> {
96    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
97
98    #[allow(unused_mut)]
99    let mut decoder = doc.root_element()?;
100    #[allow(unused_variables)]
101    let start_el = decoder.start_el();
102    if !(start_el.matches("ListResourceScanResourcesResponse")) {
103        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
104            "invalid root, expected ListResourceScanResourcesResponse got {:?}",
105            start_el
106        )));
107    }
108    if let Some(mut result_tag) = decoder.next_tag() {
109        let start_el = result_tag.start_el();
110        if !(start_el.matches("ListResourceScanResourcesResult")) {
111            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
112                "invalid result, expected ListResourceScanResourcesResult got {:?}",
113                start_el
114            )));
115        }
116        while let Some(mut tag) = result_tag.next_tag() {
117            match tag.start_el() {
118            s if s.matches("Resources") /* Resources com.amazonaws.cloudformation.synthetic#ListResourceScanResourcesOutput$Resources */ =>  {
119                let var_1 =
120                    Some(
121                        crate::protocol_serde::shape_scanned_resources::de_scanned_resources(&mut tag)
122                        ?
123                    )
124                ;
125                builder = builder.set_resources(var_1);
126            }
127            ,
128            s if s.matches("NextToken") /* NextToken com.amazonaws.cloudformation.synthetic#ListResourceScanResourcesOutput$NextToken */ =>  {
129                let var_2 =
130                    Some(
131                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
132                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
133                            .into()
134                        )
135                        ?
136                    )
137                ;
138                builder = builder.set_next_token(var_2);
139            }
140            ,
141            _ => {}
142        }
143        }
144    } else {
145        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
146            "expected ListResourceScanResourcesResult tag",
147        ));
148    };
149    Ok(builder)
150}