aws_sdk_sts/protocol_serde/
shape_assume_role_with_web_identity.rs
1#[allow(clippy::unnecessary_wraps)]
3pub fn de_assume_role_with_web_identity_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::assume_role_with_web_identity::AssumeRoleWithWebIdentityOutput,
9 crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError,
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::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::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::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ExpiredTokenException" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::ExpiredTokenException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ExpiredTokenExceptionBuilder::default();
28 output = crate::protocol_serde::shape_expired_token_exception::de_expired_token_exception_xml_err(_response_body, output)
29 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::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 "IDPCommunicationError" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::IdpCommunicationErrorException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::IdpCommunicationErrorExceptionBuilder::default();
43 output = crate::protocol_serde::shape_idp_communication_error_exception::de_idp_communication_error_exception_xml_err(
44 _response_body,
45 output,
46 )
47 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
48 let output = output.meta(generic);
49 output.build()
50 };
51 if tmp.message.is_none() {
52 tmp.message = _error_message;
53 }
54 tmp
55 }),
56 "IDPRejectedClaim" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::IdpRejectedClaimException({
57 #[allow(unused_mut)]
58 let mut tmp = {
59 #[allow(unused_mut)]
60 let mut output = crate::types::error::builders::IdpRejectedClaimExceptionBuilder::default();
61 output = crate::protocol_serde::shape_idp_rejected_claim_exception::de_idp_rejected_claim_exception_xml_err(_response_body, output)
62 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
63 let output = output.meta(generic);
64 output.build()
65 };
66 if tmp.message.is_none() {
67 tmp.message = _error_message;
68 }
69 tmp
70 }),
71 "InvalidIdentityToken" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::InvalidIdentityTokenException({
72 #[allow(unused_mut)]
73 let mut tmp = {
74 #[allow(unused_mut)]
75 let mut output = crate::types::error::builders::InvalidIdentityTokenExceptionBuilder::default();
76 output = crate::protocol_serde::shape_invalid_identity_token_exception::de_invalid_identity_token_exception_xml_err(
77 _response_body,
78 output,
79 )
80 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
81 let output = output.meta(generic);
82 output.build()
83 };
84 if tmp.message.is_none() {
85 tmp.message = _error_message;
86 }
87 tmp
88 }),
89 "MalformedPolicyDocument" => {
90 crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::MalformedPolicyDocumentException({
91 #[allow(unused_mut)]
92 let mut tmp = {
93 #[allow(unused_mut)]
94 let mut output = crate::types::error::builders::MalformedPolicyDocumentExceptionBuilder::default();
95 output = crate::protocol_serde::shape_malformed_policy_document_exception::de_malformed_policy_document_exception_xml_err(
96 _response_body,
97 output,
98 )
99 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::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 }
109 "PackedPolicyTooLarge" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::PackedPolicyTooLargeException({
110 #[allow(unused_mut)]
111 let mut tmp = {
112 #[allow(unused_mut)]
113 let mut output = crate::types::error::builders::PackedPolicyTooLargeExceptionBuilder::default();
114 output = crate::protocol_serde::shape_packed_policy_too_large_exception::de_packed_policy_too_large_exception_xml_err(
115 _response_body,
116 output,
117 )
118 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
119 let output = output.meta(generic);
120 output.build()
121 };
122 if tmp.message.is_none() {
123 tmp.message = _error_message;
124 }
125 tmp
126 }),
127 "RegionDisabledException" => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::RegionDisabledException({
128 #[allow(unused_mut)]
129 let mut tmp = {
130 #[allow(unused_mut)]
131 let mut output = crate::types::error::builders::RegionDisabledExceptionBuilder::default();
132 output = crate::protocol_serde::shape_region_disabled_exception::de_region_disabled_exception_xml_err(_response_body, output)
133 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
134 let output = output.meta(generic);
135 output.build()
136 };
137 if tmp.message.is_none() {
138 tmp.message = _error_message;
139 }
140 tmp
141 }),
142 _ => crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::generic(generic),
143 })
144}
145
146#[allow(clippy::unnecessary_wraps)]
147pub fn de_assume_role_with_web_identity_http_response(
148 _response_status: u16,
149 _response_headers: &::aws_smithy_runtime_api::http::Headers,
150 _response_body: &[u8],
151) -> std::result::Result<
152 crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityOutput,
153 crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError,
154> {
155 Ok({
156 #[allow(unused_mut)]
157 let mut output = crate::operation::assume_role_with_web_identity::builders::AssumeRoleWithWebIdentityOutputBuilder::default();
158 output = crate::protocol_serde::shape_assume_role_with_web_identity::de_assume_role_with_web_identity(_response_body, output)
159 .map_err(crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::unhandled)?;
160 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
161 output.build()
162 })
163}
164
165#[allow(unused_mut)]
166pub fn de_assume_role_with_web_identity(
167 inp: &[u8],
168 mut builder: crate::operation::assume_role_with_web_identity::builders::AssumeRoleWithWebIdentityOutputBuilder,
169) -> std::result::Result<
170 crate::operation::assume_role_with_web_identity::builders::AssumeRoleWithWebIdentityOutputBuilder,
171 ::aws_smithy_xml::decode::XmlDecodeError,
172> {
173 let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
174
175 #[allow(unused_mut)]
176 let mut decoder = doc.root_element()?;
177 #[allow(unused_variables)]
178 let start_el = decoder.start_el();
179 if !(start_el.matches("AssumeRoleWithWebIdentityResponse")) {
180 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
181 "invalid root, expected AssumeRoleWithWebIdentityResponse got {:?}",
182 start_el
183 )));
184 }
185 if let Some(mut result_tag) = decoder.next_tag() {
186 let start_el = result_tag.start_el();
187 if !(start_el.matches("AssumeRoleWithWebIdentityResult")) {
188 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
189 "invalid result, expected AssumeRoleWithWebIdentityResult got {:?}",
190 start_el
191 )));
192 }
193 while let Some(mut tag) = result_tag.next_tag() {
194 match tag.start_el() {
195 s if s.matches("Credentials") => {
196 let var_1 =
197 Some(
198 crate::protocol_serde::shape_credentials::de_credentials(&mut tag)
199 ?
200 )
201 ;
202 builder = builder.set_credentials(var_1);
203 }
204 ,
205 s if s.matches("SubjectFromWebIdentityToken") => {
206 let var_2 =
207 Some(
208 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
209 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
210 .into()
211 )
212 ?
213 )
214 ;
215 builder = builder.set_subject_from_web_identity_token(var_2);
216 }
217 ,
218 s if s.matches("AssumedRoleUser") => {
219 let var_3 =
220 Some(
221 crate::protocol_serde::shape_assumed_role_user::de_assumed_role_user(&mut tag)
222 ?
223 )
224 ;
225 builder = builder.set_assumed_role_user(var_3);
226 }
227 ,
228 s if s.matches("PackedPolicySize") => {
229 let var_4 =
230 Some(
231 {
232 <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
233 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
234 )
235 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.sts#nonNegativeIntegerType`)"))
236 }
237 ?
238 )
239 ;
240 builder = builder.set_packed_policy_size(var_4);
241 }
242 ,
243 s if s.matches("Provider") => {
244 let var_5 =
245 Some(
246 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
247 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
248 .into()
249 )
250 ?
251 )
252 ;
253 builder = builder.set_provider(var_5);
254 }
255 ,
256 s if s.matches("Audience") => {
257 let var_6 =
258 Some(
259 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
260 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
261 .into()
262 )
263 ?
264 )
265 ;
266 builder = builder.set_audience(var_6);
267 }
268 ,
269 s if s.matches("SourceIdentity") => {
270 let var_7 =
271 Some(
272 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
273 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
274 .into()
275 )
276 ?
277 )
278 ;
279 builder = builder.set_source_identity(var_7);
280 }
281 ,
282 _ => {}
283 }
284 }
285 } else {
286 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
287 "expected AssumeRoleWithWebIdentityResult tag",
288 ));
289 };
290 Ok(builder)
291}