aws_sdk_route53resolver/protocol_serde/
shape_update_firewall_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_firewall_config_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::update_firewall_config::UpdateFirewallConfigOutput,
9    crate::operation::update_firewall_config::UpdateFirewallConfigError,
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::update_firewall_config::UpdateFirewallConfigError::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::update_firewall_config::UpdateFirewallConfigError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => crate::operation::update_firewall_config::UpdateFirewallConfigError::AccessDeniedException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
28                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "InternalServiceErrorException" => crate::operation::update_firewall_config::UpdateFirewallConfigError::InternalServiceErrorException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InternalServiceErrorExceptionBuilder::default();
43                output = crate::protocol_serde::shape_internal_service_error_exception::de_internal_service_error_exception_json_err(
44                    _response_body,
45                    output,
46                )
47                .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
48                let output = output.meta(generic);
49                output.build()
50            };
51            if tmp.message.is_none() {
52                tmp.message = _error_message;
53            }
54            tmp
55        }),
56        "ResourceNotFoundException" => crate::operation::update_firewall_config::UpdateFirewallConfigError::ResourceNotFoundException({
57            #[allow(unused_mut)]
58            let mut tmp = {
59                #[allow(unused_mut)]
60                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
61                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
62                    .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
63                let output = output.meta(generic);
64                output.build()
65            };
66            if tmp.message.is_none() {
67                tmp.message = _error_message;
68            }
69            tmp
70        }),
71        "ThrottlingException" => crate::operation::update_firewall_config::UpdateFirewallConfigError::ThrottlingException({
72            #[allow(unused_mut)]
73            let mut tmp = {
74                #[allow(unused_mut)]
75                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
76                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
77                    .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
78                let output = output.meta(generic);
79                output.build()
80            };
81            if tmp.message.is_none() {
82                tmp.message = _error_message;
83            }
84            tmp
85        }),
86        "ValidationException" => crate::operation::update_firewall_config::UpdateFirewallConfigError::ValidationException({
87            #[allow(unused_mut)]
88            let mut tmp = {
89                #[allow(unused_mut)]
90                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
91                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
92                    .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
93                let output = output.meta(generic);
94                output.build()
95            };
96            if tmp.message.is_none() {
97                tmp.message = _error_message;
98            }
99            tmp
100        }),
101        _ => crate::operation::update_firewall_config::UpdateFirewallConfigError::generic(generic),
102    })
103}
104
105#[allow(clippy::unnecessary_wraps)]
106pub fn de_update_firewall_config_http_response(
107    _response_status: u16,
108    _response_headers: &::aws_smithy_runtime_api::http::Headers,
109    _response_body: &[u8],
110) -> std::result::Result<
111    crate::operation::update_firewall_config::UpdateFirewallConfigOutput,
112    crate::operation::update_firewall_config::UpdateFirewallConfigError,
113> {
114    Ok({
115        #[allow(unused_mut)]
116        let mut output = crate::operation::update_firewall_config::builders::UpdateFirewallConfigOutputBuilder::default();
117        output = crate::protocol_serde::shape_update_firewall_config::de_update_firewall_config(_response_body, output)
118            .map_err(crate::operation::update_firewall_config::UpdateFirewallConfigError::unhandled)?;
119        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
120        output.build()
121    })
122}
123
124pub fn ser_update_firewall_config_input(
125    input: &crate::operation::update_firewall_config::UpdateFirewallConfigInput,
126) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
127    let mut out = String::new();
128    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
129    crate::protocol_serde::shape_update_firewall_config_input::ser_update_firewall_config_input_input(&mut object, input)?;
130    object.finish();
131    Ok(::aws_smithy_types::body::SdkBody::from(out))
132}
133
134pub(crate) fn de_update_firewall_config(
135    value: &[u8],
136    mut builder: crate::operation::update_firewall_config::builders::UpdateFirewallConfigOutputBuilder,
137) -> ::std::result::Result<
138    crate::operation::update_firewall_config::builders::UpdateFirewallConfigOutputBuilder,
139    ::aws_smithy_json::deserialize::error::DeserializeError,
140> {
141    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
142    let tokens = &mut tokens_owned;
143    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
144    loop {
145        match tokens.next().transpose()? {
146            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
147            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
148                "FirewallConfig" => {
149                    builder = builder.set_firewall_config(crate::protocol_serde::shape_firewall_config::de_firewall_config(tokens)?);
150                }
151                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
152            },
153            other => {
154                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
155                    "expected object key or end object, found: {:?}",
156                    other
157                )))
158            }
159        }
160    }
161    if tokens.next().is_some() {
162        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
163            "found more JSON tokens after completing parsing",
164        ));
165    }
166    Ok(builder)
167}