aws_sdk_redshift/protocol_serde/
shape_create_authentication_profile.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_authentication_profile_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_authentication_profile::CreateAuthenticationProfileOutput,
9    crate::operation::create_authentication_profile::CreateAuthenticationProfileError,
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_authentication_profile::CreateAuthenticationProfileError::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_authentication_profile::CreateAuthenticationProfileError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AuthenticationProfileAlreadyExistsFault" => {
24            crate::operation::create_authentication_profile::CreateAuthenticationProfileError::AuthenticationProfileAlreadyExistsFault({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::AuthenticationProfileAlreadyExistsFaultBuilder::default();
29                    output = crate::protocol_serde::shape_authentication_profile_already_exists_fault::de_authentication_profile_already_exists_fault_xml_err(_response_body, output).map_err(crate::operation::create_authentication_profile::CreateAuthenticationProfileError::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        }
39        "AuthenticationProfileQuotaExceededFault" => {
40            crate::operation::create_authentication_profile::CreateAuthenticationProfileError::AuthenticationProfileQuotaExceededFault({
41                #[allow(unused_mut)]
42                let mut tmp = {
43                    #[allow(unused_mut)]
44                    let mut output = crate::types::error::builders::AuthenticationProfileQuotaExceededFaultBuilder::default();
45                    output = crate::protocol_serde::shape_authentication_profile_quota_exceeded_fault::de_authentication_profile_quota_exceeded_fault_xml_err(_response_body, output).map_err(crate::operation::create_authentication_profile::CreateAuthenticationProfileError::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        }
55        "InvalidAuthenticationProfileRequestFault" => {
56            crate::operation::create_authentication_profile::CreateAuthenticationProfileError::InvalidAuthenticationProfileRequestFault({
57                #[allow(unused_mut)]
58                let mut tmp = {
59                    #[allow(unused_mut)]
60                    let mut output = crate::types::error::builders::InvalidAuthenticationProfileRequestFaultBuilder::default();
61                    output = crate::protocol_serde::shape_invalid_authentication_profile_request_fault::de_invalid_authentication_profile_request_fault_xml_err(_response_body, output).map_err(crate::operation::create_authentication_profile::CreateAuthenticationProfileError::unhandled)?;
62                    let output = output.meta(generic);
63                    output.build()
64                };
65                if tmp.message.is_none() {
66                    tmp.message = _error_message;
67                }
68                tmp
69            })
70        }
71        _ => crate::operation::create_authentication_profile::CreateAuthenticationProfileError::generic(generic),
72    })
73}
74
75#[allow(clippy::unnecessary_wraps)]
76pub fn de_create_authentication_profile_http_response(
77    _response_status: u16,
78    _response_headers: &::aws_smithy_runtime_api::http::Headers,
79    _response_body: &[u8],
80) -> std::result::Result<
81    crate::operation::create_authentication_profile::CreateAuthenticationProfileOutput,
82    crate::operation::create_authentication_profile::CreateAuthenticationProfileError,
83> {
84    Ok({
85        #[allow(unused_mut)]
86        let mut output = crate::operation::create_authentication_profile::builders::CreateAuthenticationProfileOutputBuilder::default();
87        output = crate::protocol_serde::shape_create_authentication_profile::de_create_authentication_profile(_response_body, output)
88            .map_err(crate::operation::create_authentication_profile::CreateAuthenticationProfileError::unhandled)?;
89        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
90        output.build()
91    })
92}
93
94#[allow(unused_mut)]
95pub fn de_create_authentication_profile(
96    inp: &[u8],
97    mut builder: crate::operation::create_authentication_profile::builders::CreateAuthenticationProfileOutputBuilder,
98) -> std::result::Result<
99    crate::operation::create_authentication_profile::builders::CreateAuthenticationProfileOutputBuilder,
100    ::aws_smithy_xml::decode::XmlDecodeError,
101> {
102    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
103
104    #[allow(unused_mut)]
105    let mut decoder = doc.root_element()?;
106    #[allow(unused_variables)]
107    let start_el = decoder.start_el();
108    if !(start_el.matches("CreateAuthenticationProfileResponse")) {
109        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
110            "invalid root, expected CreateAuthenticationProfileResponse got {:?}",
111            start_el
112        )));
113    }
114    if let Some(mut result_tag) = decoder.next_tag() {
115        let start_el = result_tag.start_el();
116        if !(start_el.matches("CreateAuthenticationProfileResult")) {
117            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
118                "invalid result, expected CreateAuthenticationProfileResult got {:?}",
119                start_el
120            )));
121        }
122        while let Some(mut tag) = result_tag.next_tag() {
123            match tag.start_el() {
124            s if s.matches("AuthenticationProfileName") /* AuthenticationProfileName com.amazonaws.redshift.synthetic#CreateAuthenticationProfileOutput$AuthenticationProfileName */ =>  {
125                let var_1 =
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_authentication_profile_name(var_1);
135            }
136            ,
137            s if s.matches("AuthenticationProfileContent") /* AuthenticationProfileContent com.amazonaws.redshift.synthetic#CreateAuthenticationProfileOutput$AuthenticationProfileContent */ =>  {
138                let var_2 =
139                    Some(
140                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
141                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
142                            .into()
143                        )
144                        ?
145                    )
146                ;
147                builder = builder.set_authentication_profile_content(var_2);
148            }
149            ,
150            _ => {}
151        }
152        }
153    } else {
154        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
155            "expected CreateAuthenticationProfileResult tag",
156        ));
157    };
158    Ok(builder)
159}