aws_sdk_iam/protocol_serde/
shape_generate_credential_report.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_generate_credential_report_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::generate_credential_report::GenerateCredentialReportOutput,
9 crate::operation::generate_credential_report::GenerateCredentialReportError,
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::generate_credential_report::GenerateCredentialReportError::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::generate_credential_report::GenerateCredentialReportError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "LimitExceeded" => crate::operation::generate_credential_report::GenerateCredentialReportError::LimitExceededException({
28 #[allow(unused_mut)]
29 let mut tmp = {
30 #[allow(unused_mut)]
31 let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
32 output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_xml_err(_response_body, output)
33 .map_err(crate::operation::generate_credential_report::GenerateCredentialReportError::unhandled)?;
34 let output = output.meta(generic);
35 output.build()
36 };
37 if tmp.message.is_none() {
38 tmp.message = _error_message;
39 }
40 tmp
41 }),
42 "ServiceFailure" => crate::operation::generate_credential_report::GenerateCredentialReportError::ServiceFailureException({
43 #[allow(unused_mut)]
44 let mut tmp = {
45 #[allow(unused_mut)]
46 let mut output = crate::types::error::builders::ServiceFailureExceptionBuilder::default();
47 output = crate::protocol_serde::shape_service_failure_exception::de_service_failure_exception_xml_err(_response_body, output)
48 .map_err(crate::operation::generate_credential_report::GenerateCredentialReportError::unhandled)?;
49 let output = output.meta(generic);
50 output.build()
51 };
52 if tmp.message.is_none() {
53 tmp.message = _error_message;
54 }
55 tmp
56 }),
57 _ => crate::operation::generate_credential_report::GenerateCredentialReportError::generic(generic),
58 })
59}
60
61#[allow(clippy::unnecessary_wraps)]
62pub fn de_generate_credential_report_http_response(
63 _response_status: u16,
64 _response_headers: &::aws_smithy_runtime_api::http::Headers,
65 _response_body: &[u8],
66) -> std::result::Result<
67 crate::operation::generate_credential_report::GenerateCredentialReportOutput,
68 crate::operation::generate_credential_report::GenerateCredentialReportError,
69> {
70 Ok({
71 #[allow(unused_mut)]
72 let mut output = crate::operation::generate_credential_report::builders::GenerateCredentialReportOutputBuilder::default();
73 output = crate::protocol_serde::shape_generate_credential_report::de_generate_credential_report(_response_body, output)
74 .map_err(crate::operation::generate_credential_report::GenerateCredentialReportError::unhandled)?;
75 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
76 output.build()
77 })
78}
79
80#[allow(unused_mut)]
81pub fn de_generate_credential_report(
82 inp: &[u8],
83 mut builder: crate::operation::generate_credential_report::builders::GenerateCredentialReportOutputBuilder,
84) -> std::result::Result<
85 crate::operation::generate_credential_report::builders::GenerateCredentialReportOutputBuilder,
86 ::aws_smithy_xml::decode::XmlDecodeError,
87> {
88 let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
89
90 #[allow(unused_mut)]
91 let mut decoder = doc.root_element()?;
92 #[allow(unused_variables)]
93 let start_el = decoder.start_el();
94 if !(start_el.matches("GenerateCredentialReportResponse")) {
95 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
96 "invalid root, expected GenerateCredentialReportResponse got {:?}",
97 start_el
98 )));
99 }
100 if let Some(mut result_tag) = decoder.next_tag() {
101 let start_el = result_tag.start_el();
102 if !(start_el.matches("GenerateCredentialReportResult")) {
103 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
104 "invalid result, expected GenerateCredentialReportResult got {:?}",
105 start_el
106 )));
107 }
108 while let Some(mut tag) = result_tag.next_tag() {
109 match tag.start_el() {
110 s if s.matches("State") => {
111 let var_1 =
112 Some(
113 Result::<crate::types::ReportStateType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
114 crate::types::ReportStateType::from(
115 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
116 )
117 )
118 ?
119 )
120 ;
121 builder = builder.set_state(var_1);
122 }
123 ,
124 s if s.matches("Description") => {
125 let var_2 =
126 Some(
127 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
128 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
129 .into()
130 )
131 ?
132 )
133 ;
134 builder = builder.set_description(var_2);
135 }
136 ,
137 _ => {}
138 }
139 }
140 } else {
141 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
142 "expected GenerateCredentialReportResult tag",
143 ));
144 };
145 Ok(builder)
146}