aws_sdk_elasticloadbalancingv2/protocol_serde/
shape_create_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_create_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::create_target_group::CreateTargetGroupOutput, crate::operation::create_target_group::CreateTargetGroupError>
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::create_target_group::CreateTargetGroupError::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::create_target_group::CreateTargetGroupError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "DuplicateTargetGroupName" => crate::operation::create_target_group::CreateTargetGroupError::DuplicateTargetGroupNameException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::DuplicateTargetGroupNameExceptionBuilder::default();
26                output = crate::protocol_serde::shape_duplicate_target_group_name_exception::de_duplicate_target_group_name_exception_xml_err(
27                    _response_body,
28                    output,
29                )
30                .map_err(crate::operation::create_target_group::CreateTargetGroupError::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        "InvalidConfigurationRequest" => crate::operation::create_target_group::CreateTargetGroupError::InvalidConfigurationRequestException({
40            #[allow(unused_mut)]
41            let mut tmp = {
42                #[allow(unused_mut)]
43                let mut output = crate::types::error::builders::InvalidConfigurationRequestExceptionBuilder::default();
44                output = crate::protocol_serde::shape_invalid_configuration_request_exception::de_invalid_configuration_request_exception_xml_err(
45                    _response_body,
46                    output,
47                )
48                .map_err(crate::operation::create_target_group::CreateTargetGroupError::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        "TooManyTags" => crate::operation::create_target_group::CreateTargetGroupError::TooManyTagsException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::TooManyTagsExceptionBuilder::default();
62                output = crate::protocol_serde::shape_too_many_tags_exception::de_too_many_tags_exception_xml_err(_response_body, output)
63                    .map_err(crate::operation::create_target_group::CreateTargetGroupError::unhandled)?;
64                let output = output.meta(generic);
65                output.build()
66            };
67            if tmp.message.is_none() {
68                tmp.message = _error_message;
69            }
70            tmp
71        }),
72        "TooManyTargetGroups" => crate::operation::create_target_group::CreateTargetGroupError::TooManyTargetGroupsException({
73            #[allow(unused_mut)]
74            let mut tmp = {
75                #[allow(unused_mut)]
76                let mut output = crate::types::error::builders::TooManyTargetGroupsExceptionBuilder::default();
77                output = crate::protocol_serde::shape_too_many_target_groups_exception::de_too_many_target_groups_exception_xml_err(
78                    _response_body,
79                    output,
80                )
81                .map_err(crate::operation::create_target_group::CreateTargetGroupError::unhandled)?;
82                let output = output.meta(generic);
83                output.build()
84            };
85            if tmp.message.is_none() {
86                tmp.message = _error_message;
87            }
88            tmp
89        }),
90        _ => crate::operation::create_target_group::CreateTargetGroupError::generic(generic),
91    })
92}
93
94#[allow(clippy::unnecessary_wraps)]
95pub fn de_create_target_group_http_response(
96    _response_status: u16,
97    _response_headers: &::aws_smithy_runtime_api::http::Headers,
98    _response_body: &[u8],
99) -> std::result::Result<crate::operation::create_target_group::CreateTargetGroupOutput, crate::operation::create_target_group::CreateTargetGroupError>
100{
101    Ok({
102        #[allow(unused_mut)]
103        let mut output = crate::operation::create_target_group::builders::CreateTargetGroupOutputBuilder::default();
104        output = crate::protocol_serde::shape_create_target_group::de_create_target_group(_response_body, output)
105            .map_err(crate::operation::create_target_group::CreateTargetGroupError::unhandled)?;
106        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
107        output.build()
108    })
109}
110
111#[allow(unused_mut)]
112pub fn de_create_target_group(
113    inp: &[u8],
114    mut builder: crate::operation::create_target_group::builders::CreateTargetGroupOutputBuilder,
115) -> std::result::Result<crate::operation::create_target_group::builders::CreateTargetGroupOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
116    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
117
118    #[allow(unused_mut)]
119    let mut decoder = doc.root_element()?;
120    #[allow(unused_variables)]
121    let start_el = decoder.start_el();
122    if !(start_el.matches("CreateTargetGroupResponse")) {
123        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
124            "invalid root, expected CreateTargetGroupResponse got {:?}",
125            start_el
126        )));
127    }
128    if let Some(mut result_tag) = decoder.next_tag() {
129        let start_el = result_tag.start_el();
130        if !(start_el.matches("CreateTargetGroupResult")) {
131            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
132                "invalid result, expected CreateTargetGroupResult got {:?}",
133                start_el
134            )));
135        }
136        while let Some(mut tag) = result_tag.next_tag() {
137            match tag.start_el() {
138            s if s.matches("TargetGroups") /* TargetGroups com.amazonaws.elasticloadbalancingv2.synthetic#CreateTargetGroupOutput$TargetGroups */ =>  {
139                let var_1 =
140                    Some(
141                        crate::protocol_serde::shape_target_groups::de_target_groups(&mut tag)
142                        ?
143                    )
144                ;
145                builder = builder.set_target_groups(var_1);
146            }
147            ,
148            _ => {}
149        }
150        }
151    } else {
152        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected CreateTargetGroupResult tag"));
153    };
154    Ok(builder)
155}