aws_sdk_redshift/protocol_serde/
shape_reboot_cluster.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_reboot_cluster_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::reboot_cluster::RebootClusterOutput, crate::operation::reboot_cluster::RebootClusterError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::reboot_cluster::RebootClusterError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::reboot_cluster::RebootClusterError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "ClusterNotFound" => crate::operation::reboot_cluster::RebootClusterError::ClusterNotFoundFault({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::ClusterNotFoundFaultBuilder::default();
25                output = crate::protocol_serde::shape_cluster_not_found_fault::de_cluster_not_found_fault_xml_err(_response_body, output)
26                    .map_err(crate::operation::reboot_cluster::RebootClusterError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        "InvalidClusterState" => crate::operation::reboot_cluster::RebootClusterError::InvalidClusterStateFault({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::InvalidClusterStateFaultBuilder::default();
40                output = crate::protocol_serde::shape_invalid_cluster_state_fault::de_invalid_cluster_state_fault_xml_err(_response_body, output)
41                    .map_err(crate::operation::reboot_cluster::RebootClusterError::unhandled)?;
42                let output = output.meta(generic);
43                output.build()
44            };
45            if tmp.message.is_none() {
46                tmp.message = _error_message;
47            }
48            tmp
49        }),
50        _ => crate::operation::reboot_cluster::RebootClusterError::generic(generic),
51    })
52}
53
54#[allow(clippy::unnecessary_wraps)]
55pub fn de_reboot_cluster_http_response(
56    _response_status: u16,
57    _response_headers: &::aws_smithy_runtime_api::http::Headers,
58    _response_body: &[u8],
59) -> std::result::Result<crate::operation::reboot_cluster::RebootClusterOutput, crate::operation::reboot_cluster::RebootClusterError> {
60    Ok({
61        #[allow(unused_mut)]
62        let mut output = crate::operation::reboot_cluster::builders::RebootClusterOutputBuilder::default();
63        output = crate::protocol_serde::shape_reboot_cluster::de_reboot_cluster(_response_body, output)
64            .map_err(crate::operation::reboot_cluster::RebootClusterError::unhandled)?;
65        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
66        output.build()
67    })
68}
69
70#[allow(unused_mut)]
71pub fn de_reboot_cluster(
72    inp: &[u8],
73    mut builder: crate::operation::reboot_cluster::builders::RebootClusterOutputBuilder,
74) -> std::result::Result<crate::operation::reboot_cluster::builders::RebootClusterOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
75    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
76
77    #[allow(unused_mut)]
78    let mut decoder = doc.root_element()?;
79    #[allow(unused_variables)]
80    let start_el = decoder.start_el();
81    if !(start_el.matches("RebootClusterResponse")) {
82        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
83            "invalid root, expected RebootClusterResponse got {:?}",
84            start_el
85        )));
86    }
87    if let Some(mut result_tag) = decoder.next_tag() {
88        let start_el = result_tag.start_el();
89        if !(start_el.matches("RebootClusterResult")) {
90            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
91                "invalid result, expected RebootClusterResult got {:?}",
92                start_el
93            )));
94        }
95        while let Some(mut tag) = result_tag.next_tag() {
96            match tag.start_el() {
97            s if s.matches("Cluster") /* Cluster com.amazonaws.redshift.synthetic#RebootClusterOutput$Cluster */ =>  {
98                let var_1 =
99                    Some(
100                        crate::protocol_serde::shape_cluster::de_cluster(&mut tag)
101                        ?
102                    )
103                ;
104                builder = builder.set_cluster(var_1);
105            }
106            ,
107            _ => {}
108        }
109        }
110    } else {
111        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected RebootClusterResult tag"));
112    };
113    Ok(builder)
114}