aws_sdk_devopsguru/protocol_serde/
shape_add_notification_channel.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_add_notification_channel_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::add_notification_channel::AddNotificationChannelOutput,
9 crate::operation::add_notification_channel::AddNotificationChannelError,
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::add_notification_channel::AddNotificationChannelError::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::add_notification_channel::AddNotificationChannelError::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::add_notification_channel::AddNotificationChannelError::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::add_notification_channel::AddNotificationChannelError::unhandled)?;
34 let output = output.meta(generic);
35 crate::serde_util::access_denied_exception_correct_errors(output)
36 .build()
37 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
38 };
39 tmp
40 }),
41 "ConflictException" => crate::operation::add_notification_channel::AddNotificationChannelError::ConflictException({
42 #[allow(unused_mut)]
43 let mut tmp = {
44 #[allow(unused_mut)]
45 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
46 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
47 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
48 let output = output.meta(generic);
49 crate::serde_util::conflict_exception_correct_errors(output)
50 .build()
51 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
52 };
53 tmp
54 }),
55 "InternalServerException" => crate::operation::add_notification_channel::AddNotificationChannelError::InternalServerException({
56 #[allow(unused_mut)]
57 let mut tmp = {
58 #[allow(unused_mut)]
59 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
60 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
61 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
62 output = output.set_retry_after_seconds(
63 crate::protocol_serde::shape_internal_server_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
64 crate::operation::add_notification_channel::AddNotificationChannelError::unhandled(
65 "Failed to parse RetryAfterSeconds from header `Retry-After",
66 )
67 })?,
68 );
69 let output = output.meta(generic);
70 crate::serde_util::internal_server_exception_correct_errors(output)
71 .build()
72 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
73 };
74 tmp
75 }),
76 "ResourceNotFoundException" => crate::operation::add_notification_channel::AddNotificationChannelError::ResourceNotFoundException({
77 #[allow(unused_mut)]
78 let mut tmp = {
79 #[allow(unused_mut)]
80 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
81 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
82 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
83 let output = output.meta(generic);
84 crate::serde_util::resource_not_found_exception_correct_errors(output)
85 .build()
86 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
87 };
88 tmp
89 }),
90 "ServiceQuotaExceededException" => crate::operation::add_notification_channel::AddNotificationChannelError::ServiceQuotaExceededException({
91 #[allow(unused_mut)]
92 let mut tmp = {
93 #[allow(unused_mut)]
94 let mut output = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
95 output = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
96 _response_body,
97 output,
98 )
99 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
100 let output = output.meta(generic);
101 output.build()
102 };
103 if tmp.message.is_none() {
104 tmp.message = _error_message;
105 }
106 tmp
107 }),
108 "ThrottlingException" => crate::operation::add_notification_channel::AddNotificationChannelError::ThrottlingException({
109 #[allow(unused_mut)]
110 let mut tmp = {
111 #[allow(unused_mut)]
112 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
113 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
114 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
115 output = output.set_retry_after_seconds(
116 crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
117 crate::operation::add_notification_channel::AddNotificationChannelError::unhandled(
118 "Failed to parse RetryAfterSeconds from header `Retry-After",
119 )
120 })?,
121 );
122 let output = output.meta(generic);
123 crate::serde_util::throttling_exception_correct_errors(output)
124 .build()
125 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
126 };
127 tmp
128 }),
129 "ValidationException" => crate::operation::add_notification_channel::AddNotificationChannelError::ValidationException({
130 #[allow(unused_mut)]
131 let mut tmp = {
132 #[allow(unused_mut)]
133 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
134 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
135 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
136 let output = output.meta(generic);
137 crate::serde_util::validation_exception_correct_errors(output)
138 .build()
139 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
140 };
141 tmp
142 }),
143 _ => crate::operation::add_notification_channel::AddNotificationChannelError::generic(generic),
144 })
145}
146
147#[allow(clippy::unnecessary_wraps)]
148pub fn de_add_notification_channel_http_response(
149 _response_status: u16,
150 _response_headers: &::aws_smithy_runtime_api::http::Headers,
151 _response_body: &[u8],
152) -> std::result::Result<
153 crate::operation::add_notification_channel::AddNotificationChannelOutput,
154 crate::operation::add_notification_channel::AddNotificationChannelError,
155> {
156 Ok({
157 #[allow(unused_mut)]
158 let mut output = crate::operation::add_notification_channel::builders::AddNotificationChannelOutputBuilder::default();
159 output = crate::protocol_serde::shape_add_notification_channel::de_add_notification_channel(_response_body, output)
160 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?;
161 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
162 crate::serde_util::add_notification_channel_output_output_correct_errors(output)
163 .build()
164 .map_err(crate::operation::add_notification_channel::AddNotificationChannelError::unhandled)?
165 })
166}
167
168pub fn ser_add_notification_channel_input(
169 input: &crate::operation::add_notification_channel::AddNotificationChannelInput,
170) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
171 let mut out = String::new();
172 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
173 crate::protocol_serde::shape_add_notification_channel_input::ser_add_notification_channel_input_input(&mut object, input)?;
174 object.finish();
175 Ok(::aws_smithy_types::body::SdkBody::from(out))
176}
177
178pub(crate) fn de_add_notification_channel(
179 value: &[u8],
180 mut builder: crate::operation::add_notification_channel::builders::AddNotificationChannelOutputBuilder,
181) -> ::std::result::Result<
182 crate::operation::add_notification_channel::builders::AddNotificationChannelOutputBuilder,
183 ::aws_smithy_json::deserialize::error::DeserializeError,
184> {
185 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
186 let tokens = &mut tokens_owned;
187 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
188 loop {
189 match tokens.next().transpose()? {
190 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
191 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
192 "Id" => {
193 builder = builder.set_id(
194 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
195 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
196 .transpose()?,
197 );
198 }
199 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
200 },
201 other => {
202 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
203 "expected object key or end object, found: {:?}",
204 other
205 )))
206 }
207 }
208 }
209 if tokens.next().is_some() {
210 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
211 "found more JSON tokens after completing parsing",
212 ));
213 }
214 Ok(builder)
215}