Skip to main content

aws_sdk_route53resolver/protocol_serde/
shape_list_firewall_rule_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_firewall_rule_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_firewall_rule_groups::ListFirewallRuleGroupsOutput,
9    crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError,
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_firewall_rule_groups::ListFirewallRuleGroupsError::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 => {
19            return Err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "AccessDeniedException" => crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::AccessDeniedException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
32                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::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        "InternalServiceErrorException" => crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::InternalServiceErrorException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InternalServiceErrorExceptionBuilder::default();
47                output = crate::protocol_serde::shape_internal_service_error_exception::de_internal_service_error_exception_json_err(
48                    _response_body,
49                    output,
50                )
51                .map_err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::unhandled)?;
52                let output = output.meta(generic);
53                output.build()
54            };
55            if tmp.message.is_none() {
56                tmp.message = _error_message;
57            }
58            tmp
59        }),
60        "ThrottlingException" => crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::ThrottlingException({
61            #[allow(unused_mut)]
62            let mut tmp = {
63                #[allow(unused_mut)]
64                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
65                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
66                    .map_err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::unhandled)?;
67                let output = output.meta(generic);
68                output.build()
69            };
70            if tmp.message.is_none() {
71                tmp.message = _error_message;
72            }
73            tmp
74        }),
75        "ValidationException" => crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::ValidationException({
76            #[allow(unused_mut)]
77            let mut tmp = {
78                #[allow(unused_mut)]
79                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
80                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
81                    .map_err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::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::list_firewall_rule_groups::ListFirewallRuleGroupsError::generic(generic),
91    })
92}
93
94#[allow(clippy::unnecessary_wraps)]
95pub fn de_list_firewall_rule_groups_http_response(
96    _response_status: u16,
97    _response_headers: &::aws_smithy_runtime_api::http::Headers,
98    _response_body: &[u8],
99) -> std::result::Result<
100    crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsOutput,
101    crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError,
102> {
103    Ok({
104        #[allow(unused_mut)]
105        let mut output = crate::operation::list_firewall_rule_groups::builders::ListFirewallRuleGroupsOutputBuilder::default();
106        output = crate::protocol_serde::shape_list_firewall_rule_groups::de_list_firewall_rule_groups(_response_body, output)
107            .map_err(crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsError::unhandled)?;
108        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
109        output.build()
110    })
111}
112
113pub fn ser_list_firewall_rule_groups_input(
114    input: &crate::operation::list_firewall_rule_groups::ListFirewallRuleGroupsInput,
115) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
116    let mut out = String::new();
117    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
118    crate::protocol_serde::shape_list_firewall_rule_groups_input::ser_list_firewall_rule_groups_input_input(&mut object, input)?;
119    object.finish();
120    Ok(::aws_smithy_types::body::SdkBody::from(out))
121}
122
123pub(crate) fn de_list_firewall_rule_groups(
124    _value: &[u8],
125    mut builder: crate::operation::list_firewall_rule_groups::builders::ListFirewallRuleGroupsOutputBuilder,
126) -> ::std::result::Result<
127    crate::operation::list_firewall_rule_groups::builders::ListFirewallRuleGroupsOutputBuilder,
128    ::aws_smithy_json::deserialize::error::DeserializeError,
129> {
130    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
131    let tokens = &mut tokens_owned;
132    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
133    loop {
134        match tokens.next().transpose()? {
135            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
136            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
137                "NextToken" => {
138                    builder = builder.set_next_token(
139                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
140                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
141                            .transpose()?,
142                    );
143                }
144                "FirewallRuleGroups" => {
145                    builder = builder.set_firewall_rule_groups(
146                        crate::protocol_serde::shape_firewall_rule_group_metadata_list::de_firewall_rule_group_metadata_list(tokens, _value)?,
147                    );
148                }
149                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
150            },
151            other => {
152                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
153                    "expected object key or end object, found: {other:?}"
154                )))
155            }
156        }
157    }
158    if tokens.next().is_some() {
159        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
160            "found more JSON tokens after completing parsing",
161        ));
162    }
163    Ok(builder)
164}