aws_sdk_redshift/protocol_serde/
shape_create_custom_domain_association.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_custom_domain_association_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_custom_domain_association::CreateCustomDomainAssociationOutput,
9    crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError,
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_custom_domain_association::CreateCustomDomainAssociationError::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_custom_domain_association::CreateCustomDomainAssociationError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "ClusterNotFound" => crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::ClusterNotFoundFault({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::ClusterNotFoundFaultBuilder::default();
28                output = crate::protocol_serde::shape_cluster_not_found_fault::de_cluster_not_found_fault_xml_err(_response_body, output)
29                    .map_err(crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::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        "CustomCnameAssociationFault" => {
39            crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::CustomCnameAssociationFault({
40                #[allow(unused_mut)]
41                let mut tmp = {
42                    #[allow(unused_mut)]
43                    let mut output = crate::types::error::builders::CustomCnameAssociationFaultBuilder::default();
44                    output = crate::protocol_serde::shape_custom_cname_association_fault::de_custom_cname_association_fault_xml_err(
45                        _response_body,
46                        output,
47                    )
48                    .map_err(crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::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        }
58        "UnsupportedOperation" => {
59            crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::UnsupportedOperationFault({
60                #[allow(unused_mut)]
61                let mut tmp = {
62                    #[allow(unused_mut)]
63                    let mut output = crate::types::error::builders::UnsupportedOperationFaultBuilder::default();
64                    output = crate::protocol_serde::shape_unsupported_operation_fault::de_unsupported_operation_fault_xml_err(_response_body, output)
65                        .map_err(crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::unhandled)?;
66                    let output = output.meta(generic);
67                    output.build()
68                };
69                if tmp.message.is_none() {
70                    tmp.message = _error_message;
71                }
72                tmp
73            })
74        }
75        _ => crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::generic(generic),
76    })
77}
78
79#[allow(clippy::unnecessary_wraps)]
80pub fn de_create_custom_domain_association_http_response(
81    _response_status: u16,
82    _response_headers: &::aws_smithy_runtime_api::http::Headers,
83    _response_body: &[u8],
84) -> std::result::Result<
85    crate::operation::create_custom_domain_association::CreateCustomDomainAssociationOutput,
86    crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError,
87> {
88    Ok({
89        #[allow(unused_mut)]
90        let mut output = crate::operation::create_custom_domain_association::builders::CreateCustomDomainAssociationOutputBuilder::default();
91        output = crate::protocol_serde::shape_create_custom_domain_association::de_create_custom_domain_association(_response_body, output)
92            .map_err(crate::operation::create_custom_domain_association::CreateCustomDomainAssociationError::unhandled)?;
93        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
94        output.build()
95    })
96}
97
98#[allow(unused_mut)]
99pub fn de_create_custom_domain_association(
100    inp: &[u8],
101    mut builder: crate::operation::create_custom_domain_association::builders::CreateCustomDomainAssociationOutputBuilder,
102) -> std::result::Result<
103    crate::operation::create_custom_domain_association::builders::CreateCustomDomainAssociationOutputBuilder,
104    ::aws_smithy_xml::decode::XmlDecodeError,
105> {
106    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
107
108    #[allow(unused_mut)]
109    let mut decoder = doc.root_element()?;
110    #[allow(unused_variables)]
111    let start_el = decoder.start_el();
112    if !(start_el.matches("CreateCustomDomainAssociationResponse")) {
113        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
114            "invalid root, expected CreateCustomDomainAssociationResponse got {:?}",
115            start_el
116        )));
117    }
118    if let Some(mut result_tag) = decoder.next_tag() {
119        let start_el = result_tag.start_el();
120        if !(start_el.matches("CreateCustomDomainAssociationResult")) {
121            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
122                "invalid result, expected CreateCustomDomainAssociationResult got {:?}",
123                start_el
124            )));
125        }
126        while let Some(mut tag) = result_tag.next_tag() {
127            match tag.start_el() {
128            s if s.matches("CustomDomainName") /* CustomDomainName com.amazonaws.redshift.synthetic#CreateCustomDomainAssociationOutput$CustomDomainName */ =>  {
129                let var_1 =
130                    Some(
131                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
132                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
133                            .into()
134                        )
135                        ?
136                    )
137                ;
138                builder = builder.set_custom_domain_name(var_1);
139            }
140            ,
141            s if s.matches("CustomDomainCertificateArn") /* CustomDomainCertificateArn com.amazonaws.redshift.synthetic#CreateCustomDomainAssociationOutput$CustomDomainCertificateArn */ =>  {
142                let var_2 =
143                    Some(
144                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
145                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
146                            .into()
147                        )
148                        ?
149                    )
150                ;
151                builder = builder.set_custom_domain_certificate_arn(var_2);
152            }
153            ,
154            s if s.matches("ClusterIdentifier") /* ClusterIdentifier com.amazonaws.redshift.synthetic#CreateCustomDomainAssociationOutput$ClusterIdentifier */ =>  {
155                let var_3 =
156                    Some(
157                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
158                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
159                            .into()
160                        )
161                        ?
162                    )
163                ;
164                builder = builder.set_cluster_identifier(var_3);
165            }
166            ,
167            s if s.matches("CustomDomainCertExpiryTime") /* CustomDomainCertExpiryTime com.amazonaws.redshift.synthetic#CreateCustomDomainAssociationOutput$CustomDomainCertExpiryTime */ =>  {
168                let var_4 =
169                    Some(
170                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
171                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
172                            .into()
173                        )
174                        ?
175                    )
176                ;
177                builder = builder.set_custom_domain_cert_expiry_time(var_4);
178            }
179            ,
180            _ => {}
181        }
182        }
183    } else {
184        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
185            "expected CreateCustomDomainAssociationResult tag",
186        ));
187    };
188    Ok(builder)
189}