aws_sdk_sts/protocol_serde/
shape_assume_role_with_saml.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[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 {:?}",
160            start_el
161        )));
162    }
163    if let Some(mut result_tag) = decoder.next_tag() {
164        let start_el = result_tag.start_el();
165        if !(start_el.matches("AssumeRoleWithSAMLResult")) {
166            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
167                "invalid result, expected AssumeRoleWithSAMLResult got {:?}",
168                start_el
169            )));
170        }
171        while let Some(mut tag) = result_tag.next_tag() {
172            match tag.start_el() {
173            s if s.matches("Credentials") /* Credentials com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$Credentials */ =>  {
174                let var_1 =
175                    Some(
176                        crate::protocol_serde::shape_credentials::de_credentials(&mut tag)
177                        ?
178                    )
179                ;
180                builder = builder.set_credentials(var_1);
181            }
182            ,
183            s if s.matches("AssumedRoleUser") /* AssumedRoleUser com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$AssumedRoleUser */ =>  {
184                let var_2 =
185                    Some(
186                        crate::protocol_serde::shape_assumed_role_user::de_assumed_role_user(&mut tag)
187                        ?
188                    )
189                ;
190                builder = builder.set_assumed_role_user(var_2);
191            }
192            ,
193            s if s.matches("PackedPolicySize") /* PackedPolicySize com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$PackedPolicySize */ =>  {
194                let var_3 =
195                    Some(
196                         {
197                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
198                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
199                            )
200                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.sts#nonNegativeIntegerType`)"))
201                        }
202                        ?
203                    )
204                ;
205                builder = builder.set_packed_policy_size(var_3);
206            }
207            ,
208            s if s.matches("Subject") /* Subject com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$Subject */ =>  {
209                let var_4 =
210                    Some(
211                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
212                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
213                            .into()
214                        )
215                        ?
216                    )
217                ;
218                builder = builder.set_subject(var_4);
219            }
220            ,
221            s if s.matches("SubjectType") /* SubjectType com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$SubjectType */ =>  {
222                let var_5 =
223                    Some(
224                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
225                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
226                            .into()
227                        )
228                        ?
229                    )
230                ;
231                builder = builder.set_subject_type(var_5);
232            }
233            ,
234            s if s.matches("Issuer") /* Issuer com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$Issuer */ =>  {
235                let var_6 =
236                    Some(
237                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
238                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
239                            .into()
240                        )
241                        ?
242                    )
243                ;
244                builder = builder.set_issuer(var_6);
245            }
246            ,
247            s if s.matches("Audience") /* Audience com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$Audience */ =>  {
248                let var_7 =
249                    Some(
250                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
251                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
252                            .into()
253                        )
254                        ?
255                    )
256                ;
257                builder = builder.set_audience(var_7);
258            }
259            ,
260            s if s.matches("NameQualifier") /* NameQualifier com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$NameQualifier */ =>  {
261                let var_8 =
262                    Some(
263                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
264                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
265                            .into()
266                        )
267                        ?
268                    )
269                ;
270                builder = builder.set_name_qualifier(var_8);
271            }
272            ,
273            s if s.matches("SourceIdentity") /* SourceIdentity com.amazonaws.sts.synthetic#AssumeRoleWithSAMLOutput$SourceIdentity */ =>  {
274                let var_9 =
275                    Some(
276                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
277                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
278                            .into()
279                        )
280                        ?
281                    )
282                ;
283                builder = builder.set_source_identity(var_9);
284            }
285            ,
286            _ => {}
287        }
288        }
289    } else {
290        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected AssumeRoleWithSAMLResult tag"));
291    };
292    Ok(builder)
293}