aws_sdk_globalaccelerator/protocol_serde/
shape_create_cross_account_attachment.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_cross_account_attachment_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::create_cross_account_attachment::CreateCrossAccountAttachmentOutput,
9 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError,
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::create_cross_account_attachment::CreateCrossAccountAttachmentError::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::create_cross_account_attachment::CreateCrossAccountAttachmentError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "AccessDeniedException" => crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::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::create_cross_account_attachment::CreateCrossAccountAttachmentError::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" => {
39 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::InternalServiceErrorException({
40 #[allow(unused_mut)]
41 let mut tmp = {
42 #[allow(unused_mut)]
43 let mut output = crate::types::error::builders::InternalServiceErrorExceptionBuilder::default();
44 output = crate::protocol_serde::shape_internal_service_error_exception::de_internal_service_error_exception_json_err(
45 _response_body,
46 output,
47 )
48 .map_err(crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::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 }
58 "InvalidArgumentException" => {
59 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::InvalidArgumentException({
60 #[allow(unused_mut)]
61 let mut tmp = {
62 #[allow(unused_mut)]
63 let mut output = crate::types::error::builders::InvalidArgumentExceptionBuilder::default();
64 output = crate::protocol_serde::shape_invalid_argument_exception::de_invalid_argument_exception_json_err(_response_body, output)
65 .map_err(crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::unhandled)?;
66 let output = output.meta(generic);
67 output.build()
68 };
69 if tmp.message.is_none() {
70 tmp.message = _error_message;
71 }
72 tmp
73 })
74 }
75 "LimitExceededException" => crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::LimitExceededException({
76 #[allow(unused_mut)]
77 let mut tmp = {
78 #[allow(unused_mut)]
79 let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
80 output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
81 .map_err(crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::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 "TransactionInProgressException" => {
91 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::TransactionInProgressException({
92 #[allow(unused_mut)]
93 let mut tmp = {
94 #[allow(unused_mut)]
95 let mut output = crate::types::error::builders::TransactionInProgressExceptionBuilder::default();
96 output = crate::protocol_serde::shape_transaction_in_progress_exception::de_transaction_in_progress_exception_json_err(
97 _response_body,
98 output,
99 )
100 .map_err(crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::unhandled)?;
101 let output = output.meta(generic);
102 output.build()
103 };
104 if tmp.message.is_none() {
105 tmp.message = _error_message;
106 }
107 tmp
108 })
109 }
110 _ => crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::generic(generic),
111 })
112}
113
114#[allow(clippy::unnecessary_wraps)]
115pub fn de_create_cross_account_attachment_http_response(
116 _response_status: u16,
117 _response_headers: &::aws_smithy_runtime_api::http::Headers,
118 _response_body: &[u8],
119) -> std::result::Result<
120 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentOutput,
121 crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError,
122> {
123 Ok({
124 #[allow(unused_mut)]
125 let mut output = crate::operation::create_cross_account_attachment::builders::CreateCrossAccountAttachmentOutputBuilder::default();
126 output = crate::protocol_serde::shape_create_cross_account_attachment::de_create_cross_account_attachment(_response_body, output)
127 .map_err(crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentError::unhandled)?;
128 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
129 output.build()
130 })
131}
132
133pub fn ser_create_cross_account_attachment_input(
134 input: &crate::operation::create_cross_account_attachment::CreateCrossAccountAttachmentInput,
135) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
136 let mut out = String::new();
137 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
138 crate::protocol_serde::shape_create_cross_account_attachment_input::ser_create_cross_account_attachment_input_input(&mut object, input)?;
139 object.finish();
140 Ok(::aws_smithy_types::body::SdkBody::from(out))
141}
142
143pub(crate) fn de_create_cross_account_attachment(
144 _value: &[u8],
145 mut builder: crate::operation::create_cross_account_attachment::builders::CreateCrossAccountAttachmentOutputBuilder,
146) -> ::std::result::Result<
147 crate::operation::create_cross_account_attachment::builders::CreateCrossAccountAttachmentOutputBuilder,
148 ::aws_smithy_json::deserialize::error::DeserializeError,
149> {
150 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
151 let tokens = &mut tokens_owned;
152 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
153 loop {
154 match tokens.next().transpose()? {
155 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
156 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
157 "CrossAccountAttachment" => {
158 builder = builder.set_cross_account_attachment(crate::protocol_serde::shape_attachment::de_attachment(tokens, _value)?);
159 }
160 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
161 },
162 other => {
163 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
164 "expected object key or end object, found: {other:?}"
165 )))
166 }
167 }
168 }
169 if tokens.next().is_some() {
170 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
171 "found more JSON tokens after completing parsing",
172 ));
173 }
174 Ok(builder)
175}