aws_sdk_networkfirewall/protocol_serde/
shape_describe_firewall_policy.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_firewall_policy_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::describe_firewall_policy::DescribeFirewallPolicyOutput,
9 crate::operation::describe_firewall_policy::DescribeFirewallPolicyError,
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::describe_firewall_policy::DescribeFirewallPolicyError::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::describe_firewall_policy::DescribeFirewallPolicyError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "InternalServerError" => crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::InternalServerError({
28 #[allow(unused_mut)]
29 let mut tmp = {
30 #[allow(unused_mut)]
31 let mut output = crate::types::error::builders::InternalServerErrorBuilder::default();
32 output = crate::protocol_serde::shape_internal_server_error::de_internal_server_error_json_err(_response_body, output)
33 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::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 "InvalidRequestException" => crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::InvalidRequestException({
43 #[allow(unused_mut)]
44 let mut tmp = {
45 #[allow(unused_mut)]
46 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
47 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
48 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::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 "ResourceNotFoundException" => crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::ResourceNotFoundException({
58 #[allow(unused_mut)]
59 let mut tmp = {
60 #[allow(unused_mut)]
61 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
62 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
63 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::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 "ThrottlingException" => crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::ThrottlingException({
73 #[allow(unused_mut)]
74 let mut tmp = {
75 #[allow(unused_mut)]
76 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
77 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
78 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::unhandled)?;
79 let output = output.meta(generic);
80 output.build()
81 };
82 if tmp.message.is_none() {
83 tmp.message = _error_message;
84 }
85 tmp
86 }),
87 _ => crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::generic(generic),
88 })
89}
90
91#[allow(clippy::unnecessary_wraps)]
92pub fn de_describe_firewall_policy_http_response(
93 _response_status: u16,
94 _response_headers: &::aws_smithy_runtime_api::http::Headers,
95 _response_body: &[u8],
96) -> std::result::Result<
97 crate::operation::describe_firewall_policy::DescribeFirewallPolicyOutput,
98 crate::operation::describe_firewall_policy::DescribeFirewallPolicyError,
99> {
100 Ok({
101 #[allow(unused_mut)]
102 let mut output = crate::operation::describe_firewall_policy::builders::DescribeFirewallPolicyOutputBuilder::default();
103 output = crate::protocol_serde::shape_describe_firewall_policy::de_describe_firewall_policy(_response_body, output)
104 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::unhandled)?;
105 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
106 crate::serde_util::describe_firewall_policy_output_output_correct_errors(output)
107 .build()
108 .map_err(crate::operation::describe_firewall_policy::DescribeFirewallPolicyError::unhandled)?
109 })
110}
111
112pub fn ser_describe_firewall_policy_input(
113 input: &crate::operation::describe_firewall_policy::DescribeFirewallPolicyInput,
114) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
115 let mut out = String::new();
116 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
117 crate::protocol_serde::shape_describe_firewall_policy_input::ser_describe_firewall_policy_input_input(&mut object, input)?;
118 object.finish();
119 Ok(::aws_smithy_types::body::SdkBody::from(out))
120}
121
122pub(crate) fn de_describe_firewall_policy(
123 value: &[u8],
124 mut builder: crate::operation::describe_firewall_policy::builders::DescribeFirewallPolicyOutputBuilder,
125) -> ::std::result::Result<
126 crate::operation::describe_firewall_policy::builders::DescribeFirewallPolicyOutputBuilder,
127 ::aws_smithy_json::deserialize::error::DeserializeError,
128> {
129 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
130 let tokens = &mut tokens_owned;
131 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
132 loop {
133 match tokens.next().transpose()? {
134 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
135 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
136 "UpdateToken" => {
137 builder = builder.set_update_token(
138 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
139 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
140 .transpose()?,
141 );
142 }
143 "FirewallPolicyResponse" => {
144 builder = builder.set_firewall_policy_response(
145 crate::protocol_serde::shape_firewall_policy_response::de_firewall_policy_response(tokens)?,
146 );
147 }
148 "FirewallPolicy" => {
149 builder = builder.set_firewall_policy(crate::protocol_serde::shape_firewall_policy::de_firewall_policy(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: {other:?}"
156 )))
157 }
158 }
159 }
160 if tokens.next().is_some() {
161 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
162 "found more JSON tokens after completing parsing",
163 ));
164 }
165 Ok(builder)
166}