Skip to main content

aws_sdk_elasticloadbalancingv2/protocol_serde/
shape_describe_target_groups.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_target_groups_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::describe_target_groups::DescribeTargetGroupsOutput,
9    crate::operation::describe_target_groups::DescribeTargetGroupsError,
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::describe_target_groups::DescribeTargetGroupsError::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 => return Err(crate::operation::describe_target_groups::DescribeTargetGroupsError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "LoadBalancerNotFound" => crate::operation::describe_target_groups::DescribeTargetGroupsError::LoadBalancerNotFoundException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::LoadBalancerNotFoundExceptionBuilder::default();
28                output = crate::protocol_serde::shape_load_balancer_not_found_exception::de_load_balancer_not_found_exception_xml_err(
29                    _response_body,
30                    output,
31                )
32                .map_err(crate::operation::describe_target_groups::DescribeTargetGroupsError::unhandled)?;
33                let output = output.meta(generic);
34                output.build()
35            };
36            if tmp.message.is_none() {
37                tmp.message = _error_message;
38            }
39            tmp
40        }),
41        "TargetGroupNotFound" => crate::operation::describe_target_groups::DescribeTargetGroupsError::TargetGroupNotFoundException({
42            #[allow(unused_mut)]
43            let mut tmp = {
44                #[allow(unused_mut)]
45                let mut output = crate::types::error::builders::TargetGroupNotFoundExceptionBuilder::default();
46                output = crate::protocol_serde::shape_target_group_not_found_exception::de_target_group_not_found_exception_xml_err(
47                    _response_body,
48                    output,
49                )
50                .map_err(crate::operation::describe_target_groups::DescribeTargetGroupsError::unhandled)?;
51                let output = output.meta(generic);
52                output.build()
53            };
54            if tmp.message.is_none() {
55                tmp.message = _error_message;
56            }
57            tmp
58        }),
59        _ => crate::operation::describe_target_groups::DescribeTargetGroupsError::generic(generic),
60    })
61}
62
63#[allow(clippy::unnecessary_wraps)]
64pub fn de_describe_target_groups_http_response(
65    _response_status: u16,
66    _response_headers: &::aws_smithy_runtime_api::http::Headers,
67    _response_body: &[u8],
68) -> std::result::Result<
69    crate::operation::describe_target_groups::DescribeTargetGroupsOutput,
70    crate::operation::describe_target_groups::DescribeTargetGroupsError,
71> {
72    Ok({
73        #[allow(unused_mut)]
74        let mut output = crate::operation::describe_target_groups::builders::DescribeTargetGroupsOutputBuilder::default();
75        output = crate::protocol_serde::shape_describe_target_groups::de_describe_target_groups(_response_body, output)
76            .map_err(crate::operation::describe_target_groups::DescribeTargetGroupsError::unhandled)?;
77        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
78        output.build()
79    })
80}
81
82#[allow(unused_mut)]
83pub fn de_describe_target_groups(
84    inp: &[u8],
85    mut builder: crate::operation::describe_target_groups::builders::DescribeTargetGroupsOutputBuilder,
86) -> std::result::Result<
87    crate::operation::describe_target_groups::builders::DescribeTargetGroupsOutputBuilder,
88    ::aws_smithy_xml::decode::XmlDecodeError,
89> {
90    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
91
92    #[allow(unused_mut)]
93    let mut decoder = doc.root_element()?;
94    #[allow(unused_variables)]
95    let start_el = decoder.start_el();
96    if !(start_el.matches("DescribeTargetGroupsResponse")) {
97        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
98            "invalid root, expected DescribeTargetGroupsResponse got {start_el:?}"
99        )));
100    }
101    if let Some(mut result_tag) = decoder.next_tag() {
102        let start_el = result_tag.start_el();
103        if !(start_el.matches("DescribeTargetGroupsResult")) {
104            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
105                "invalid result, expected DescribeTargetGroupsResult got {start_el:?}"
106            )));
107        }
108        while let Some(mut tag) = result_tag.next_tag() {
109            match tag.start_el() {
110            s if s.matches("TargetGroups") /* TargetGroups com.amazonaws.elasticloadbalancingv2.synthetic#DescribeTargetGroupsOutput$TargetGroups */ =>  {
111                let var_1 =
112                    Some(
113                        crate::protocol_serde::shape_target_groups::de_target_groups(&mut tag)
114                        ?
115                    )
116                ;
117                builder = builder.set_target_groups(var_1);
118            }
119            ,
120            s if s.matches("NextMarker") /* NextMarker com.amazonaws.elasticloadbalancingv2.synthetic#DescribeTargetGroupsOutput$NextMarker */ =>  {
121                let var_2 =
122                    Some(
123                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
124                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
125                            .into()
126                        )
127                        ?
128                    )
129                ;
130                builder = builder.set_next_marker(var_2);
131            }
132            ,
133            _ => {}
134        }
135        }
136    } else {
137        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
138            "expected DescribeTargetGroupsResult tag",
139        ));
140    };
141    Ok(builder)
142}