aws_sdk_directconnect/protocol_serde/
shape_associate_connection_with_lag.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_associate_connection_with_lag_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::associate_connection_with_lag::AssociateConnectionWithLagOutput,
9 crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError,
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::associate_connection_with_lag::AssociateConnectionWithLagError::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::associate_connection_with_lag::AssociateConnectionWithLagError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "DirectConnectClientException" => {
24 crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::DirectConnectClientException({
25 #[allow(unused_mut)]
26 let mut tmp = {
27 #[allow(unused_mut)]
28 let mut output = crate::types::error::builders::DirectConnectClientExceptionBuilder::default();
29 output = crate::protocol_serde::shape_direct_connect_client_exception::de_direct_connect_client_exception_json_err(
30 _response_body,
31 output,
32 )
33 .map_err(crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::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 "DirectConnectServerException" => {
44 crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::DirectConnectServerException({
45 #[allow(unused_mut)]
46 let mut tmp = {
47 #[allow(unused_mut)]
48 let mut output = crate::types::error::builders::DirectConnectServerExceptionBuilder::default();
49 output = crate::protocol_serde::shape_direct_connect_server_exception::de_direct_connect_server_exception_json_err(
50 _response_body,
51 output,
52 )
53 .map_err(crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::unhandled)?;
54 let output = output.meta(generic);
55 output.build()
56 };
57 if tmp.message.is_none() {
58 tmp.message = _error_message;
59 }
60 tmp
61 })
62 }
63 _ => crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::generic(generic),
64 })
65}
66
67#[allow(clippy::unnecessary_wraps)]
68pub fn de_associate_connection_with_lag_http_response(
69 _response_status: u16,
70 _response_headers: &::aws_smithy_runtime_api::http::Headers,
71 _response_body: &[u8],
72) -> std::result::Result<
73 crate::operation::associate_connection_with_lag::AssociateConnectionWithLagOutput,
74 crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError,
75> {
76 Ok({
77 #[allow(unused_mut)]
78 let mut output = crate::operation::associate_connection_with_lag::builders::AssociateConnectionWithLagOutputBuilder::default();
79 output = crate::protocol_serde::shape_associate_connection_with_lag::de_associate_connection_with_lag(_response_body, output)
80 .map_err(crate::operation::associate_connection_with_lag::AssociateConnectionWithLagError::unhandled)?;
81 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
82 output.build()
83 })
84}
85
86pub fn ser_associate_connection_with_lag_input(
87 input: &crate::operation::associate_connection_with_lag::AssociateConnectionWithLagInput,
88) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
89 let mut out = String::new();
90 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
91 crate::protocol_serde::shape_associate_connection_with_lag_input::ser_associate_connection_with_lag_input_input(&mut object, input)?;
92 object.finish();
93 Ok(::aws_smithy_types::body::SdkBody::from(out))
94}
95
96pub(crate) fn de_associate_connection_with_lag(
97 value: &[u8],
98 mut builder: crate::operation::associate_connection_with_lag::builders::AssociateConnectionWithLagOutputBuilder,
99) -> ::std::result::Result<
100 crate::operation::associate_connection_with_lag::builders::AssociateConnectionWithLagOutputBuilder,
101 ::aws_smithy_json::deserialize::error::DeserializeError,
102> {
103 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
104 let tokens = &mut tokens_owned;
105 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
106 loop {
107 match tokens.next().transpose()? {
108 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
109 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
110 "ownerAccount" => {
111 builder = builder.set_owner_account(
112 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
113 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
114 .transpose()?,
115 );
116 }
117 "connectionId" => {
118 builder = builder.set_connection_id(
119 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
120 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
121 .transpose()?,
122 );
123 }
124 "connectionName" => {
125 builder = builder.set_connection_name(
126 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
127 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
128 .transpose()?,
129 );
130 }
131 "connectionState" => {
132 builder = builder.set_connection_state(
133 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
134 .map(|s| s.to_unescaped().map(|u| crate::types::ConnectionState::from(u.as_ref())))
135 .transpose()?,
136 );
137 }
138 "region" => {
139 builder = builder.set_region(
140 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
141 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
142 .transpose()?,
143 );
144 }
145 "location" => {
146 builder = builder.set_location(
147 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
148 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
149 .transpose()?,
150 );
151 }
152 "bandwidth" => {
153 builder = builder.set_bandwidth(
154 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
155 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
156 .transpose()?,
157 );
158 }
159 "vlan" => {
160 builder = builder.set_vlan(
161 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
162 .map(i32::try_from)
163 .transpose()?,
164 );
165 }
166 "partnerName" => {
167 builder = builder.set_partner_name(
168 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
169 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
170 .transpose()?,
171 );
172 }
173 "loaIssueTime" => {
174 builder = builder.set_loa_issue_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
175 tokens.next(),
176 ::aws_smithy_types::date_time::Format::EpochSeconds,
177 )?);
178 }
179 "lagId" => {
180 builder = builder.set_lag_id(
181 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
182 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
183 .transpose()?,
184 );
185 }
186 "awsDevice" => {
187 builder = builder.set_aws_device(
188 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
189 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
190 .transpose()?,
191 );
192 }
193 "jumboFrameCapable" => {
194 builder = builder.set_jumbo_frame_capable(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
195 }
196 "awsDeviceV2" => {
197 builder = builder.set_aws_device_v2(
198 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
199 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
200 .transpose()?,
201 );
202 }
203 "awsLogicalDeviceId" => {
204 builder = builder.set_aws_logical_device_id(
205 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
206 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
207 .transpose()?,
208 );
209 }
210 "hasLogicalRedundancy" => {
211 builder = builder.set_has_logical_redundancy(
212 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
213 .map(|s| s.to_unescaped().map(|u| crate::types::HasLogicalRedundancy::from(u.as_ref())))
214 .transpose()?,
215 );
216 }
217 "tags" => {
218 builder = builder.set_tags(crate::protocol_serde::shape_tag_list::de_tag_list(tokens)?);
219 }
220 "providerName" => {
221 builder = builder.set_provider_name(
222 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
223 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
224 .transpose()?,
225 );
226 }
227 "macSecCapable" => {
228 builder = builder.set_mac_sec_capable(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
229 }
230 "portEncryptionStatus" => {
231 builder = builder.set_port_encryption_status(
232 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
233 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
234 .transpose()?,
235 );
236 }
237 "encryptionMode" => {
238 builder = builder.set_encryption_mode(
239 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
240 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
241 .transpose()?,
242 );
243 }
244 "macSecKeys" => {
245 builder = builder.set_mac_sec_keys(crate::protocol_serde::shape_mac_sec_key_list::de_mac_sec_key_list(tokens)?);
246 }
247 "partnerInterconnectMacSecCapable" => {
248 builder =
249 builder.set_partner_interconnect_mac_sec_capable(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
250 }
251 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
252 },
253 other => {
254 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
255 "expected object key or end object, found: {other:?}"
256 )))
257 }
258 }
259 }
260 if tokens.next().is_some() {
261 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
262 "found more JSON tokens after completing parsing",
263 ));
264 }
265 Ok(builder)
266}