aws_sdk_redshift/protocol_serde/
shape_create_snapshot_schedule.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_snapshot_schedule_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_snapshot_schedule::CreateSnapshotScheduleOutput,
9    crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError,
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_snapshot_schedule::CreateSnapshotScheduleError::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::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "InvalidSchedule" => crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::InvalidScheduleFault({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::InvalidScheduleFaultBuilder::default();
32                output = crate::protocol_serde::shape_invalid_schedule_fault::de_invalid_schedule_fault_xml_err(_response_body, output)
33                    .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::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        "InvalidTagFault" => crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::InvalidTagFault({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InvalidTagFaultBuilder::default();
47                output = crate::protocol_serde::shape_invalid_tag_fault::de_invalid_tag_fault_xml_err(_response_body, output)
48                    .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::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        "ScheduleDefinitionTypeUnsupported" => {
58            crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::ScheduleDefinitionTypeUnsupportedFault({
59                #[allow(unused_mut)]
60                let mut tmp = {
61                    #[allow(unused_mut)]
62                    let mut output = crate::types::error::builders::ScheduleDefinitionTypeUnsupportedFaultBuilder::default();
63                    output = crate::protocol_serde::shape_schedule_definition_type_unsupported_fault::de_schedule_definition_type_unsupported_fault_xml_err(_response_body, output).map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled)?;
64                    let output = output.meta(generic);
65                    output.build()
66                };
67                if tmp.message.is_none() {
68                    tmp.message = _error_message;
69                }
70                tmp
71            })
72        }
73        "SnapshotScheduleAlreadyExists" => {
74            crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::SnapshotScheduleAlreadyExistsFault({
75                #[allow(unused_mut)]
76                let mut tmp = {
77                    #[allow(unused_mut)]
78                    let mut output = crate::types::error::builders::SnapshotScheduleAlreadyExistsFaultBuilder::default();
79                    output = crate::protocol_serde::shape_snapshot_schedule_already_exists_fault::de_snapshot_schedule_already_exists_fault_xml_err(
80                        _response_body,
81                        output,
82                    )
83                    .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled)?;
84                    let output = output.meta(generic);
85                    output.build()
86                };
87                if tmp.message.is_none() {
88                    tmp.message = _error_message;
89                }
90                tmp
91            })
92        }
93        "SnapshotScheduleQuotaExceeded" => {
94            crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::SnapshotScheduleQuotaExceededFault({
95                #[allow(unused_mut)]
96                let mut tmp = {
97                    #[allow(unused_mut)]
98                    let mut output = crate::types::error::builders::SnapshotScheduleQuotaExceededFaultBuilder::default();
99                    output = crate::protocol_serde::shape_snapshot_schedule_quota_exceeded_fault::de_snapshot_schedule_quota_exceeded_fault_xml_err(
100                        _response_body,
101                        output,
102                    )
103                    .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled)?;
104                    let output = output.meta(generic);
105                    output.build()
106                };
107                if tmp.message.is_none() {
108                    tmp.message = _error_message;
109                }
110                tmp
111            })
112        }
113        "TagLimitExceededFault" => crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::TagLimitExceededFault({
114            #[allow(unused_mut)]
115            let mut tmp = {
116                #[allow(unused_mut)]
117                let mut output = crate::types::error::builders::TagLimitExceededFaultBuilder::default();
118                output = crate::protocol_serde::shape_tag_limit_exceeded_fault::de_tag_limit_exceeded_fault_xml_err(_response_body, output)
119                    .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled)?;
120                let output = output.meta(generic);
121                output.build()
122            };
123            if tmp.message.is_none() {
124                tmp.message = _error_message;
125            }
126            tmp
127        }),
128        _ => crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::generic(generic),
129    })
130}
131
132#[allow(clippy::unnecessary_wraps)]
133pub fn de_create_snapshot_schedule_http_response(
134    _response_status: u16,
135    _response_headers: &::aws_smithy_runtime_api::http::Headers,
136    _response_body: &[u8],
137) -> std::result::Result<
138    crate::operation::create_snapshot_schedule::CreateSnapshotScheduleOutput,
139    crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError,
140> {
141    Ok({
142        #[allow(unused_mut)]
143        let mut output = crate::operation::create_snapshot_schedule::builders::CreateSnapshotScheduleOutputBuilder::default();
144        output = crate::protocol_serde::shape_create_snapshot_schedule::de_create_snapshot_schedule(_response_body, output)
145            .map_err(crate::operation::create_snapshot_schedule::CreateSnapshotScheduleError::unhandled)?;
146        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
147        output.build()
148    })
149}
150
151#[allow(unused_mut)]
152pub fn de_create_snapshot_schedule(
153    inp: &[u8],
154    mut builder: crate::operation::create_snapshot_schedule::builders::CreateSnapshotScheduleOutputBuilder,
155) -> std::result::Result<
156    crate::operation::create_snapshot_schedule::builders::CreateSnapshotScheduleOutputBuilder,
157    ::aws_smithy_xml::decode::XmlDecodeError,
158> {
159    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
160
161    #[allow(unused_mut)]
162    let mut decoder = doc.root_element()?;
163    #[allow(unused_variables)]
164    let start_el = decoder.start_el();
165    if !(start_el.matches("CreateSnapshotScheduleResponse")) {
166        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
167            "invalid root, expected CreateSnapshotScheduleResponse got {:?}",
168            start_el
169        )));
170    }
171    if let Some(mut result_tag) = decoder.next_tag() {
172        let start_el = result_tag.start_el();
173        if !(start_el.matches("CreateSnapshotScheduleResult")) {
174            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
175                "invalid result, expected CreateSnapshotScheduleResult got {:?}",
176                start_el
177            )));
178        }
179        while let Some(mut tag) = result_tag.next_tag() {
180            match tag.start_el() {
181            s if s.matches("ScheduleDefinitions") /* ScheduleDefinitions com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$ScheduleDefinitions */ =>  {
182                let var_1 =
183                    Some(
184                        crate::protocol_serde::shape_schedule_definition_list::de_schedule_definition_list(&mut tag)
185                        ?
186                    )
187                ;
188                builder = builder.set_schedule_definitions(var_1);
189            }
190            ,
191            s if s.matches("ScheduleIdentifier") /* ScheduleIdentifier com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$ScheduleIdentifier */ =>  {
192                let var_2 =
193                    Some(
194                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
195                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
196                            .into()
197                        )
198                        ?
199                    )
200                ;
201                builder = builder.set_schedule_identifier(var_2);
202            }
203            ,
204            s if s.matches("ScheduleDescription") /* ScheduleDescription com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$ScheduleDescription */ =>  {
205                let var_3 =
206                    Some(
207                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
208                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
209                            .into()
210                        )
211                        ?
212                    )
213                ;
214                builder = builder.set_schedule_description(var_3);
215            }
216            ,
217            s if s.matches("Tags") /* Tags com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$Tags */ =>  {
218                let var_4 =
219                    Some(
220                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
221                        ?
222                    )
223                ;
224                builder = builder.set_tags(var_4);
225            }
226            ,
227            s if s.matches("NextInvocations") /* NextInvocations com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$NextInvocations */ =>  {
228                let var_5 =
229                    Some(
230                        crate::protocol_serde::shape_scheduled_snapshot_time_list::de_scheduled_snapshot_time_list(&mut tag)
231                        ?
232                    )
233                ;
234                builder = builder.set_next_invocations(var_5);
235            }
236            ,
237            s if s.matches("AssociatedClusterCount") /* AssociatedClusterCount com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$AssociatedClusterCount */ =>  {
238                let var_6 =
239                    Some(
240                         {
241                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
242                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
243                            )
244                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.redshift#IntegerOptional`)"))
245                        }
246                        ?
247                    )
248                ;
249                builder = builder.set_associated_cluster_count(var_6);
250            }
251            ,
252            s if s.matches("AssociatedClusters") /* AssociatedClusters com.amazonaws.redshift.synthetic#CreateSnapshotScheduleOutput$AssociatedClusters */ =>  {
253                let var_7 =
254                    Some(
255                        crate::protocol_serde::shape_associated_cluster_list::de_associated_cluster_list(&mut tag)
256                        ?
257                    )
258                ;
259                builder = builder.set_associated_clusters(var_7);
260            }
261            ,
262            _ => {}
263        }
264        }
265    } else {
266        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
267            "expected CreateSnapshotScheduleResult tag",
268        ));
269    };
270    Ok(builder)
271}