aws_sdk_ssooidc/protocol_serde/
shape_create_token_with_iam.rs
1#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_token_with_iam_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_token_with_iam::CreateTokenWithIamOutput,
9 crate::operation::create_token_with_iam::CreateTokenWithIAMError,
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_token_with_iam::CreateTokenWithIAMError::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_token_with_iam::CreateTokenWithIAMError::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_token_with_iam::CreateTokenWithIAMError::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_token_with_iam::CreateTokenWithIAMError::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 "AuthorizationPendingException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::AuthorizationPendingException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::AuthorizationPendingExceptionBuilder::default();
43 output =
44 crate::protocol_serde::shape_authorization_pending_exception::de_authorization_pending_exception_json_err(_response_body, output)
45 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::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 "ExpiredTokenException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::ExpiredTokenException({
55 #[allow(unused_mut)]
56 let mut tmp = {
57 #[allow(unused_mut)]
58 let mut output = crate::types::error::builders::ExpiredTokenExceptionBuilder::default();
59 output = crate::protocol_serde::shape_expired_token_exception::de_expired_token_exception_json_err(_response_body, output)
60 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::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 "InternalServerException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InternalServerException({
70 #[allow(unused_mut)]
71 let mut tmp = {
72 #[allow(unused_mut)]
73 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
74 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
75 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
76 let output = output.meta(generic);
77 output.build()
78 };
79 if tmp.message.is_none() {
80 tmp.message = _error_message;
81 }
82 tmp
83 }),
84 "InvalidClientException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InvalidClientException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::InvalidClientExceptionBuilder::default();
89 output = crate::protocol_serde::shape_invalid_client_exception::de_invalid_client_exception_json_err(_response_body, output)
90 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
91 let output = output.meta(generic);
92 output.build()
93 };
94 if tmp.message.is_none() {
95 tmp.message = _error_message;
96 }
97 tmp
98 }),
99 "InvalidGrantException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InvalidGrantException({
100 #[allow(unused_mut)]
101 let mut tmp = {
102 #[allow(unused_mut)]
103 let mut output = crate::types::error::builders::InvalidGrantExceptionBuilder::default();
104 output = crate::protocol_serde::shape_invalid_grant_exception::de_invalid_grant_exception_json_err(_response_body, output)
105 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
106 let output = output.meta(generic);
107 output.build()
108 };
109 if tmp.message.is_none() {
110 tmp.message = _error_message;
111 }
112 tmp
113 }),
114 "InvalidRequestException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InvalidRequestException({
115 #[allow(unused_mut)]
116 let mut tmp = {
117 #[allow(unused_mut)]
118 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
119 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
120 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
121 let output = output.meta(generic);
122 output.build()
123 };
124 if tmp.message.is_none() {
125 tmp.message = _error_message;
126 }
127 tmp
128 }),
129 "InvalidRequestRegionException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InvalidRequestRegionException({
130 #[allow(unused_mut)]
131 let mut tmp = {
132 #[allow(unused_mut)]
133 let mut output = crate::types::error::builders::InvalidRequestRegionExceptionBuilder::default();
134 output = crate::protocol_serde::shape_invalid_request_region_exception::de_invalid_request_region_exception_json_err(
135 _response_body,
136 output,
137 )
138 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
139 let output = output.meta(generic);
140 output.build()
141 };
142 if tmp.message.is_none() {
143 tmp.message = _error_message;
144 }
145 tmp
146 }),
147 "InvalidScopeException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::InvalidScopeException({
148 #[allow(unused_mut)]
149 let mut tmp = {
150 #[allow(unused_mut)]
151 let mut output = crate::types::error::builders::InvalidScopeExceptionBuilder::default();
152 output = crate::protocol_serde::shape_invalid_scope_exception::de_invalid_scope_exception_json_err(_response_body, output)
153 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
154 let output = output.meta(generic);
155 output.build()
156 };
157 if tmp.message.is_none() {
158 tmp.message = _error_message;
159 }
160 tmp
161 }),
162 "SlowDownException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::SlowDownException({
163 #[allow(unused_mut)]
164 let mut tmp = {
165 #[allow(unused_mut)]
166 let mut output = crate::types::error::builders::SlowDownExceptionBuilder::default();
167 output = crate::protocol_serde::shape_slow_down_exception::de_slow_down_exception_json_err(_response_body, output)
168 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
169 let output = output.meta(generic);
170 output.build()
171 };
172 if tmp.message.is_none() {
173 tmp.message = _error_message;
174 }
175 tmp
176 }),
177 "UnauthorizedClientException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::UnauthorizedClientException({
178 #[allow(unused_mut)]
179 let mut tmp = {
180 #[allow(unused_mut)]
181 let mut output = crate::types::error::builders::UnauthorizedClientExceptionBuilder::default();
182 output =
183 crate::protocol_serde::shape_unauthorized_client_exception::de_unauthorized_client_exception_json_err(_response_body, output)
184 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
185 let output = output.meta(generic);
186 output.build()
187 };
188 if tmp.message.is_none() {
189 tmp.message = _error_message;
190 }
191 tmp
192 }),
193 "UnsupportedGrantTypeException" => crate::operation::create_token_with_iam::CreateTokenWithIAMError::UnsupportedGrantTypeException({
194 #[allow(unused_mut)]
195 let mut tmp = {
196 #[allow(unused_mut)]
197 let mut output = crate::types::error::builders::UnsupportedGrantTypeExceptionBuilder::default();
198 output = crate::protocol_serde::shape_unsupported_grant_type_exception::de_unsupported_grant_type_exception_json_err(
199 _response_body,
200 output,
201 )
202 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
203 let output = output.meta(generic);
204 output.build()
205 };
206 if tmp.message.is_none() {
207 tmp.message = _error_message;
208 }
209 tmp
210 }),
211 _ => crate::operation::create_token_with_iam::CreateTokenWithIAMError::generic(generic),
212 })
213}
214
215#[allow(clippy::unnecessary_wraps)]
216pub fn de_create_token_with_iam_http_response(
217 _response_status: u16,
218 _response_headers: &::aws_smithy_runtime_api::http::Headers,
219 _response_body: &[u8],
220) -> std::result::Result<
221 crate::operation::create_token_with_iam::CreateTokenWithIamOutput,
222 crate::operation::create_token_with_iam::CreateTokenWithIAMError,
223> {
224 Ok({
225 #[allow(unused_mut)]
226 let mut output = crate::operation::create_token_with_iam::builders::CreateTokenWithIamOutputBuilder::default();
227 output = crate::protocol_serde::shape_create_token_with_iam::de_create_token_with_iam(_response_body, output)
228 .map_err(crate::operation::create_token_with_iam::CreateTokenWithIAMError::unhandled)?;
229 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
230 output.build()
231 })
232}
233
234pub fn ser_create_token_with_iam_input(
235 input: &crate::operation::create_token_with_iam::CreateTokenWithIamInput,
236) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
237 let mut out = String::new();
238 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
239 crate::protocol_serde::shape_create_token_with_iam_input::ser_create_token_with_iam_input_input(&mut object, input)?;
240 object.finish();
241 Ok(::aws_smithy_types::body::SdkBody::from(out))
242}
243
244pub(crate) fn de_create_token_with_iam(
245 value: &[u8],
246 mut builder: crate::operation::create_token_with_iam::builders::CreateTokenWithIamOutputBuilder,
247) -> ::std::result::Result<
248 crate::operation::create_token_with_iam::builders::CreateTokenWithIamOutputBuilder,
249 ::aws_smithy_json::deserialize::error::DeserializeError,
250> {
251 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
252 let tokens = &mut tokens_owned;
253 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
254 loop {
255 match tokens.next().transpose()? {
256 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
257 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
258 "accessToken" => {
259 builder = builder.set_access_token(
260 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
261 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
262 .transpose()?,
263 );
264 }
265 "expiresIn" => {
266 builder = builder.set_expires_in(
267 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
268 .map(i32::try_from)
269 .transpose()?,
270 );
271 }
272 "idToken" => {
273 builder = builder.set_id_token(
274 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
275 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
276 .transpose()?,
277 );
278 }
279 "issuedTokenType" => {
280 builder = builder.set_issued_token_type(
281 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
282 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
283 .transpose()?,
284 );
285 }
286 "refreshToken" => {
287 builder = builder.set_refresh_token(
288 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
289 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
290 .transpose()?,
291 );
292 }
293 "scope" => {
294 builder = builder.set_scope(crate::protocol_serde::shape_scopes::de_scopes(tokens)?);
295 }
296 "tokenType" => {
297 builder = builder.set_token_type(
298 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
299 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
300 .transpose()?,
301 );
302 }
303 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
304 },
305 other => {
306 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
307 "expected object key or end object, found: {:?}",
308 other
309 )))
310 }
311 }
312 }
313 if tokens.next().is_some() {
314 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
315 "found more JSON tokens after completing parsing",
316 ));
317 }
318 Ok(builder)
319}