aws_sdk_cloudtrail/protocol_serde/
shape_update_channel.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_channel_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::update_channel::UpdateChannelOutput, crate::operation::update_channel::UpdateChannelError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::update_channel::UpdateChannelError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ChannelAlreadyExistsException" => crate::operation::update_channel::UpdateChannelError::ChannelAlreadyExistsException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::ChannelAlreadyExistsExceptionBuilder::default();
25 output = crate::protocol_serde::shape_channel_already_exists_exception::de_channel_already_exists_exception_json_err(
26 _response_body,
27 output,
28 )
29 .map_err(crate::operation::update_channel::UpdateChannelError::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 "ChannelARNInvalidException" => crate::operation::update_channel::UpdateChannelError::ChannelArnInvalidException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::ChannelArnInvalidExceptionBuilder::default();
43 output =
44 crate::protocol_serde::shape_channel_arn_invalid_exception::de_channel_arn_invalid_exception_json_err(_response_body, output)
45 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
46 let output = output.meta(generic);
47 output.build()
48 };
49 if tmp.message.is_none() {
50 tmp.message = _error_message;
51 }
52 tmp
53 }),
54 "ChannelNotFoundException" => crate::operation::update_channel::UpdateChannelError::ChannelNotFoundException({
55 #[allow(unused_mut)]
56 let mut tmp = {
57 #[allow(unused_mut)]
58 let mut output = crate::types::error::builders::ChannelNotFoundExceptionBuilder::default();
59 output = crate::protocol_serde::shape_channel_not_found_exception::de_channel_not_found_exception_json_err(_response_body, output)
60 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
61 let output = output.meta(generic);
62 output.build()
63 };
64 if tmp.message.is_none() {
65 tmp.message = _error_message;
66 }
67 tmp
68 }),
69 "EventDataStoreARNInvalidException" => crate::operation::update_channel::UpdateChannelError::EventDataStoreArnInvalidException({
70 #[allow(unused_mut)]
71 let mut tmp = {
72 #[allow(unused_mut)]
73 let mut output = crate::types::error::builders::EventDataStoreArnInvalidExceptionBuilder::default();
74 output = crate::protocol_serde::shape_event_data_store_arn_invalid_exception::de_event_data_store_arn_invalid_exception_json_err(
75 _response_body,
76 output,
77 )
78 .map_err(crate::operation::update_channel::UpdateChannelError::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 "EventDataStoreNotFoundException" => crate::operation::update_channel::UpdateChannelError::EventDataStoreNotFoundException({
88 #[allow(unused_mut)]
89 let mut tmp = {
90 #[allow(unused_mut)]
91 let mut output = crate::types::error::builders::EventDataStoreNotFoundExceptionBuilder::default();
92 output = crate::protocol_serde::shape_event_data_store_not_found_exception::de_event_data_store_not_found_exception_json_err(
93 _response_body,
94 output,
95 )
96 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
97 let output = output.meta(generic);
98 output.build()
99 };
100 if tmp.message.is_none() {
101 tmp.message = _error_message;
102 }
103 tmp
104 }),
105 "InactiveEventDataStoreException" => crate::operation::update_channel::UpdateChannelError::InactiveEventDataStoreException({
106 #[allow(unused_mut)]
107 let mut tmp = {
108 #[allow(unused_mut)]
109 let mut output = crate::types::error::builders::InactiveEventDataStoreExceptionBuilder::default();
110 output = crate::protocol_serde::shape_inactive_event_data_store_exception::de_inactive_event_data_store_exception_json_err(
111 _response_body,
112 output,
113 )
114 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
115 let output = output.meta(generic);
116 output.build()
117 };
118 if tmp.message.is_none() {
119 tmp.message = _error_message;
120 }
121 tmp
122 }),
123 "InvalidEventDataStoreCategoryException" => crate::operation::update_channel::UpdateChannelError::InvalidEventDataStoreCategoryException({
124 #[allow(unused_mut)]
125 let mut tmp = {
126 #[allow(unused_mut)]
127 let mut output = crate::types::error::builders::InvalidEventDataStoreCategoryExceptionBuilder::default();
128 output = crate::protocol_serde::shape_invalid_event_data_store_category_exception::de_invalid_event_data_store_category_exception_json_err(_response_body, output).map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
129 let output = output.meta(generic);
130 output.build()
131 };
132 if tmp.message.is_none() {
133 tmp.message = _error_message;
134 }
135 tmp
136 }),
137 "InvalidParameterException" => crate::operation::update_channel::UpdateChannelError::InvalidParameterException({
138 #[allow(unused_mut)]
139 let mut tmp = {
140 #[allow(unused_mut)]
141 let mut output = crate::types::error::builders::InvalidParameterExceptionBuilder::default();
142 output = crate::protocol_serde::shape_invalid_parameter_exception::de_invalid_parameter_exception_json_err(_response_body, output)
143 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
144 let output = output.meta(generic);
145 output.build()
146 };
147 if tmp.message.is_none() {
148 tmp.message = _error_message;
149 }
150 tmp
151 }),
152 "OperationNotPermittedException" => crate::operation::update_channel::UpdateChannelError::OperationNotPermittedException({
153 #[allow(unused_mut)]
154 let mut tmp = {
155 #[allow(unused_mut)]
156 let mut output = crate::types::error::builders::OperationNotPermittedExceptionBuilder::default();
157 output = crate::protocol_serde::shape_operation_not_permitted_exception::de_operation_not_permitted_exception_json_err(
158 _response_body,
159 output,
160 )
161 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
162 let output = output.meta(generic);
163 output.build()
164 };
165 if tmp.message.is_none() {
166 tmp.message = _error_message;
167 }
168 tmp
169 }),
170 "UnsupportedOperationException" => crate::operation::update_channel::UpdateChannelError::UnsupportedOperationException({
171 #[allow(unused_mut)]
172 let mut tmp = {
173 #[allow(unused_mut)]
174 let mut output = crate::types::error::builders::UnsupportedOperationExceptionBuilder::default();
175 output =
176 crate::protocol_serde::shape_unsupported_operation_exception::de_unsupported_operation_exception_json_err(_response_body, output)
177 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
178 let output = output.meta(generic);
179 output.build()
180 };
181 if tmp.message.is_none() {
182 tmp.message = _error_message;
183 }
184 tmp
185 }),
186 _ => crate::operation::update_channel::UpdateChannelError::generic(generic),
187 })
188}
189
190#[allow(clippy::unnecessary_wraps)]
191pub fn de_update_channel_http_response(
192 _response_status: u16,
193 _response_headers: &::aws_smithy_runtime_api::http::Headers,
194 _response_body: &[u8],
195) -> std::result::Result<crate::operation::update_channel::UpdateChannelOutput, crate::operation::update_channel::UpdateChannelError> {
196 Ok({
197 #[allow(unused_mut)]
198 let mut output = crate::operation::update_channel::builders::UpdateChannelOutputBuilder::default();
199 output = crate::protocol_serde::shape_update_channel::de_update_channel(_response_body, output)
200 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
201 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
202 output.build()
203 })
204}
205
206pub fn ser_update_channel_input(
207 input: &crate::operation::update_channel::UpdateChannelInput,
208) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
209 let mut out = String::new();
210 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
211 crate::protocol_serde::shape_update_channel_input::ser_update_channel_input_input(&mut object, input)?;
212 object.finish();
213 Ok(::aws_smithy_types::body::SdkBody::from(out))
214}
215
216pub(crate) fn de_update_channel(
217 value: &[u8],
218 mut builder: crate::operation::update_channel::builders::UpdateChannelOutputBuilder,
219) -> ::std::result::Result<
220 crate::operation::update_channel::builders::UpdateChannelOutputBuilder,
221 ::aws_smithy_json::deserialize::error::DeserializeError,
222> {
223 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
224 let tokens = &mut tokens_owned;
225 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
226 loop {
227 match tokens.next().transpose()? {
228 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
229 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
230 "ChannelArn" => {
231 builder = builder.set_channel_arn(
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 "Name" => {
238 builder = builder.set_name(
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 "Source" => {
245 builder = builder.set_source(
246 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
247 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
248 .transpose()?,
249 );
250 }
251 "Destinations" => {
252 builder = builder.set_destinations(crate::protocol_serde::shape_destinations::de_destinations(tokens)?);
253 }
254 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
255 },
256 other => {
257 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
258 "expected object key or end object, found: {other:?}"
259 )))
260 }
261 }
262 }
263 if tokens.next().is_some() {
264 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
265 "found more JSON tokens after completing parsing",
266 ));
267 }
268 Ok(builder)
269}