aws_sdk_elasticloadbalancingv2/protocol_serde/
shape_get_resource_policy.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_resource_policy_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::get_resource_policy::GetResourcePolicyOutput, crate::operation::get_resource_policy::GetResourcePolicyError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::get_resource_policy::GetResourcePolicyError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    let error_code = match generic.code() {
15        Some(code) => code,
16        None => return Err(crate::operation::get_resource_policy::GetResourcePolicyError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "ResourceNotFound" => crate::operation::get_resource_policy::GetResourcePolicyError::ResourceNotFoundException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
26                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_xml_err(_response_body, output)
27                    .map_err(crate::operation::get_resource_policy::GetResourcePolicyError::unhandled)?;
28                let output = output.meta(generic);
29                output.build()
30            };
31            if tmp.message.is_none() {
32                tmp.message = _error_message;
33            }
34            tmp
35        }),
36        _ => crate::operation::get_resource_policy::GetResourcePolicyError::generic(generic),
37    })
38}
39
40#[allow(clippy::unnecessary_wraps)]
41pub fn de_get_resource_policy_http_response(
42    _response_status: u16,
43    _response_headers: &::aws_smithy_runtime_api::http::Headers,
44    _response_body: &[u8],
45) -> std::result::Result<crate::operation::get_resource_policy::GetResourcePolicyOutput, crate::operation::get_resource_policy::GetResourcePolicyError>
46{
47    Ok({
48        #[allow(unused_mut)]
49        let mut output = crate::operation::get_resource_policy::builders::GetResourcePolicyOutputBuilder::default();
50        output = crate::protocol_serde::shape_get_resource_policy::de_get_resource_policy(_response_body, output)
51            .map_err(crate::operation::get_resource_policy::GetResourcePolicyError::unhandled)?;
52        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
53        output.build()
54    })
55}
56
57#[allow(unused_mut)]
58pub fn de_get_resource_policy(
59    inp: &[u8],
60    mut builder: crate::operation::get_resource_policy::builders::GetResourcePolicyOutputBuilder,
61) -> std::result::Result<crate::operation::get_resource_policy::builders::GetResourcePolicyOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
62    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
63
64    #[allow(unused_mut)]
65    let mut decoder = doc.root_element()?;
66    #[allow(unused_variables)]
67    let start_el = decoder.start_el();
68    if !(start_el.matches("GetResourcePolicyResponse")) {
69        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
70            "invalid root, expected GetResourcePolicyResponse got {:?}",
71            start_el
72        )));
73    }
74    if let Some(mut result_tag) = decoder.next_tag() {
75        let start_el = result_tag.start_el();
76        if !(start_el.matches("GetResourcePolicyResult")) {
77            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
78                "invalid result, expected GetResourcePolicyResult got {:?}",
79                start_el
80            )));
81        }
82        while let Some(mut tag) = result_tag.next_tag() {
83            match tag.start_el() {
84            s if s.matches("Policy") /* Policy com.amazonaws.elasticloadbalancingv2.synthetic#GetResourcePolicyOutput$Policy */ =>  {
85                let var_1 =
86                    Some(
87                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
88                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
89                            .into()
90                        )
91                        ?
92                    )
93                ;
94                builder = builder.set_policy(var_1);
95            }
96            ,
97            _ => {}
98        }
99        }
100    } else {
101        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected GetResourcePolicyResult tag"));
102    };
103    Ok(builder)
104}