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