aws_sdk_elasticloadbalancingv2/protocol_serde/
shape_modify_target_group.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_modify_target_group_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::modify_target_group::ModifyTargetGroupOutput, crate::operation::modify_target_group::ModifyTargetGroupError>
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::modify_target_group::ModifyTargetGroupError::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::modify_target_group::ModifyTargetGroupError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "InvalidConfigurationRequest" => crate::operation::modify_target_group::ModifyTargetGroupError::InvalidConfigurationRequestException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::InvalidConfigurationRequestExceptionBuilder::default();
26                output = crate::protocol_serde::shape_invalid_configuration_request_exception::de_invalid_configuration_request_exception_xml_err(
27                    _response_body,
28                    output,
29                )
30                .map_err(crate::operation::modify_target_group::ModifyTargetGroupError::unhandled)?;
31                let output = output.meta(generic);
32                output.build()
33            };
34            if tmp.message.is_none() {
35                tmp.message = _error_message;
36            }
37            tmp
38        }),
39        "TargetGroupNotFound" => crate::operation::modify_target_group::ModifyTargetGroupError::TargetGroupNotFoundException({
40            #[allow(unused_mut)]
41            let mut tmp = {
42                #[allow(unused_mut)]
43                let mut output = crate::types::error::builders::TargetGroupNotFoundExceptionBuilder::default();
44                output = crate::protocol_serde::shape_target_group_not_found_exception::de_target_group_not_found_exception_xml_err(
45                    _response_body,
46                    output,
47                )
48                .map_err(crate::operation::modify_target_group::ModifyTargetGroupError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        _ => crate::operation::modify_target_group::ModifyTargetGroupError::generic(generic),
58    })
59}
60
61#[allow(clippy::unnecessary_wraps)]
62pub fn de_modify_target_group_http_response(
63    _response_status: u16,
64    _response_headers: &::aws_smithy_runtime_api::http::Headers,
65    _response_body: &[u8],
66) -> std::result::Result<crate::operation::modify_target_group::ModifyTargetGroupOutput, crate::operation::modify_target_group::ModifyTargetGroupError>
67{
68    Ok({
69        #[allow(unused_mut)]
70        let mut output = crate::operation::modify_target_group::builders::ModifyTargetGroupOutputBuilder::default();
71        output = crate::protocol_serde::shape_modify_target_group::de_modify_target_group(_response_body, output)
72            .map_err(crate::operation::modify_target_group::ModifyTargetGroupError::unhandled)?;
73        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
74        output.build()
75    })
76}
77
78#[allow(unused_mut)]
79pub fn de_modify_target_group(
80    inp: &[u8],
81    mut builder: crate::operation::modify_target_group::builders::ModifyTargetGroupOutputBuilder,
82) -> std::result::Result<crate::operation::modify_target_group::builders::ModifyTargetGroupOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
83    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
84
85    #[allow(unused_mut)]
86    let mut decoder = doc.root_element()?;
87    #[allow(unused_variables)]
88    let start_el = decoder.start_el();
89    if !(start_el.matches("ModifyTargetGroupResponse")) {
90        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
91            "invalid root, expected ModifyTargetGroupResponse got {:?}",
92            start_el
93        )));
94    }
95    if let Some(mut result_tag) = decoder.next_tag() {
96        let start_el = result_tag.start_el();
97        if !(start_el.matches("ModifyTargetGroupResult")) {
98            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
99                "invalid result, expected ModifyTargetGroupResult got {:?}",
100                start_el
101            )));
102        }
103        while let Some(mut tag) = result_tag.next_tag() {
104            match tag.start_el() {
105            s if s.matches("TargetGroups") /* TargetGroups com.amazonaws.elasticloadbalancingv2.synthetic#ModifyTargetGroupOutput$TargetGroups */ =>  {
106                let var_1 =
107                    Some(
108                        crate::protocol_serde::shape_target_groups::de_target_groups(&mut tag)
109                        ?
110                    )
111                ;
112                builder = builder.set_target_groups(var_1);
113            }
114            ,
115            _ => {}
116        }
117        }
118    } else {
119        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected ModifyTargetGroupResult tag"));
120    };
121    Ok(builder)
122}