aws_sdk_globalaccelerator/protocol_serde/
shape_list_custom_routing_endpoint_groups.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_custom_routing_endpoint_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::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsOutput,
9    crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError,
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_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::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::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "InternalServiceErrorException" => {
24            crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::InternalServiceErrorException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::InternalServiceErrorExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_internal_service_error_exception::de_internal_service_error_exception_json_err(
30                        _response_body,
31                        output,
32                    )
33                    .map_err(crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::unhandled)?;
34                    let output = output.meta(generic);
35                    output.build()
36                };
37                if tmp.message.is_none() {
38                    tmp.message = _error_message;
39                }
40                tmp
41            })
42        }
43        "InvalidArgumentException" => {
44            crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::InvalidArgumentException({
45                #[allow(unused_mut)]
46                let mut tmp = {
47                    #[allow(unused_mut)]
48                    let mut output = crate::types::error::builders::InvalidArgumentExceptionBuilder::default();
49                    output = crate::protocol_serde::shape_invalid_argument_exception::de_invalid_argument_exception_json_err(_response_body, output)
50                        .map_err(crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::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        }
60        "InvalidNextTokenException" => {
61            crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::InvalidNextTokenException({
62                #[allow(unused_mut)]
63                let mut tmp = {
64                    #[allow(unused_mut)]
65                    let mut output = crate::types::error::builders::InvalidNextTokenExceptionBuilder::default();
66                    output =
67                        crate::protocol_serde::shape_invalid_next_token_exception::de_invalid_next_token_exception_json_err(_response_body, output)
68                            .map_err(crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::unhandled)?;
69                    let output = output.meta(generic);
70                    output.build()
71                };
72                if tmp.message.is_none() {
73                    tmp.message = _error_message;
74                }
75                tmp
76            })
77        }
78        "ListenerNotFoundException" => {
79            crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::ListenerNotFoundException({
80                #[allow(unused_mut)]
81                let mut tmp = {
82                    #[allow(unused_mut)]
83                    let mut output = crate::types::error::builders::ListenerNotFoundExceptionBuilder::default();
84                    output =
85                        crate::protocol_serde::shape_listener_not_found_exception::de_listener_not_found_exception_json_err(_response_body, output)
86                            .map_err(crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::unhandled)?;
87                    let output = output.meta(generic);
88                    output.build()
89                };
90                if tmp.message.is_none() {
91                    tmp.message = _error_message;
92                }
93                tmp
94            })
95        }
96        _ => crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::generic(generic),
97    })
98}
99
100#[allow(clippy::unnecessary_wraps)]
101pub fn de_list_custom_routing_endpoint_groups_http_response(
102    _response_status: u16,
103    _response_headers: &::aws_smithy_runtime_api::http::Headers,
104    _response_body: &[u8],
105) -> std::result::Result<
106    crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsOutput,
107    crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError,
108> {
109    Ok({
110        #[allow(unused_mut)]
111        let mut output = crate::operation::list_custom_routing_endpoint_groups::builders::ListCustomRoutingEndpointGroupsOutputBuilder::default();
112        output = crate::protocol_serde::shape_list_custom_routing_endpoint_groups::de_list_custom_routing_endpoint_groups(_response_body, output)
113            .map_err(crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsError::unhandled)?;
114        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
115        output.build()
116    })
117}
118
119pub fn ser_list_custom_routing_endpoint_groups_input(
120    input: &crate::operation::list_custom_routing_endpoint_groups::ListCustomRoutingEndpointGroupsInput,
121) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
122    let mut out = String::new();
123    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
124    crate::protocol_serde::shape_list_custom_routing_endpoint_groups_input::ser_list_custom_routing_endpoint_groups_input_input(&mut object, input)?;
125    object.finish();
126    Ok(::aws_smithy_types::body::SdkBody::from(out))
127}
128
129pub(crate) fn de_list_custom_routing_endpoint_groups(
130    value: &[u8],
131    mut builder: crate::operation::list_custom_routing_endpoint_groups::builders::ListCustomRoutingEndpointGroupsOutputBuilder,
132) -> ::std::result::Result<
133    crate::operation::list_custom_routing_endpoint_groups::builders::ListCustomRoutingEndpointGroupsOutputBuilder,
134    ::aws_smithy_json::deserialize::error::DeserializeError,
135> {
136    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
137    let tokens = &mut tokens_owned;
138    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
139    loop {
140        match tokens.next().transpose()? {
141            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
142            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
143                "EndpointGroups" => {
144                    builder = builder
145                        .set_endpoint_groups(crate::protocol_serde::shape_custom_routing_endpoint_groups::de_custom_routing_endpoint_groups(tokens)?);
146                }
147                "NextToken" => {
148                    builder = builder.set_next_token(
149                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
150                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
151                            .transpose()?,
152                    );
153                }
154                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
155            },
156            other => {
157                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
158                    "expected object key or end object, found: {:?}",
159                    other
160                )))
161            }
162        }
163    }
164    if tokens.next().is_some() {
165        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
166            "found more JSON tokens after completing parsing",
167        ));
168    }
169    Ok(builder)
170}