aws_sdk_redshift/protocol_serde/
shape_modify_snapshot_schedule.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_modify_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::modify_snapshot_schedule::ModifySnapshotScheduleOutput,
9 crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError,
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::modify_snapshot_schedule::ModifySnapshotScheduleError::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::modify_snapshot_schedule::ModifySnapshotScheduleError::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::modify_snapshot_schedule::ModifySnapshotScheduleError::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::modify_snapshot_schedule::ModifySnapshotScheduleError::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 "SnapshotScheduleNotFound" => crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::SnapshotScheduleNotFoundFault({
43 #[allow(unused_mut)]
44 let mut tmp = {
45 #[allow(unused_mut)]
46 let mut output = crate::types::error::builders::SnapshotScheduleNotFoundFaultBuilder::default();
47 output = crate::protocol_serde::shape_snapshot_schedule_not_found_fault::de_snapshot_schedule_not_found_fault_xml_err(
48 _response_body,
49 output,
50 )
51 .map_err(crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::unhandled)?;
52 let output = output.meta(generic);
53 output.build()
54 };
55 if tmp.message.is_none() {
56 tmp.message = _error_message;
57 }
58 tmp
59 }),
60 "SnapshotScheduleUpdateInProgress" => {
61 crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::SnapshotScheduleUpdateInProgressFault({
62 #[allow(unused_mut)]
63 let mut tmp = {
64 #[allow(unused_mut)]
65 let mut output = crate::types::error::builders::SnapshotScheduleUpdateInProgressFaultBuilder::default();
66 output = crate::protocol_serde::shape_snapshot_schedule_update_in_progress_fault::de_snapshot_schedule_update_in_progress_fault_xml_err(_response_body, output).map_err(crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::unhandled)?;
67 let output = output.meta(generic);
68 output.build()
69 };
70 if tmp.message.is_none() {
71 tmp.message = _error_message;
72 }
73 tmp
74 })
75 }
76 _ => crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::generic(generic),
77 })
78}
79
80#[allow(clippy::unnecessary_wraps)]
81pub fn de_modify_snapshot_schedule_http_response(
82 _response_status: u16,
83 _response_headers: &::aws_smithy_runtime_api::http::Headers,
84 _response_body: &[u8],
85) -> std::result::Result<
86 crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleOutput,
87 crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError,
88> {
89 Ok({
90 #[allow(unused_mut)]
91 let mut output = crate::operation::modify_snapshot_schedule::builders::ModifySnapshotScheduleOutputBuilder::default();
92 output = crate::protocol_serde::shape_modify_snapshot_schedule::de_modify_snapshot_schedule(_response_body, output)
93 .map_err(crate::operation::modify_snapshot_schedule::ModifySnapshotScheduleError::unhandled)?;
94 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
95 output.build()
96 })
97}
98
99#[allow(unused_mut)]
100pub fn de_modify_snapshot_schedule(
101 inp: &[u8],
102 mut builder: crate::operation::modify_snapshot_schedule::builders::ModifySnapshotScheduleOutputBuilder,
103) -> std::result::Result<
104 crate::operation::modify_snapshot_schedule::builders::ModifySnapshotScheduleOutputBuilder,
105 ::aws_smithy_xml::decode::XmlDecodeError,
106> {
107 let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
108
109 #[allow(unused_mut)]
110 let mut decoder = doc.root_element()?;
111 #[allow(unused_variables)]
112 let start_el = decoder.start_el();
113 if !(start_el.matches("ModifySnapshotScheduleResponse")) {
114 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
115 "invalid root, expected ModifySnapshotScheduleResponse got {:?}",
116 start_el
117 )));
118 }
119 if let Some(mut result_tag) = decoder.next_tag() {
120 let start_el = result_tag.start_el();
121 if !(start_el.matches("ModifySnapshotScheduleResult")) {
122 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
123 "invalid result, expected ModifySnapshotScheduleResult got {:?}",
124 start_el
125 )));
126 }
127 while let Some(mut tag) = result_tag.next_tag() {
128 match tag.start_el() {
129 s if s.matches("ScheduleDefinitions") => {
130 let var_1 =
131 Some(
132 crate::protocol_serde::shape_schedule_definition_list::de_schedule_definition_list(&mut tag)
133 ?
134 )
135 ;
136 builder = builder.set_schedule_definitions(var_1);
137 }
138 ,
139 s if s.matches("ScheduleIdentifier") => {
140 let var_2 =
141 Some(
142 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
143 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
144 .into()
145 )
146 ?
147 )
148 ;
149 builder = builder.set_schedule_identifier(var_2);
150 }
151 ,
152 s if s.matches("ScheduleDescription") => {
153 let var_3 =
154 Some(
155 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
156 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
157 .into()
158 )
159 ?
160 )
161 ;
162 builder = builder.set_schedule_description(var_3);
163 }
164 ,
165 s if s.matches("Tags") => {
166 let var_4 =
167 Some(
168 crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
169 ?
170 )
171 ;
172 builder = builder.set_tags(var_4);
173 }
174 ,
175 s if s.matches("NextInvocations") => {
176 let var_5 =
177 Some(
178 crate::protocol_serde::shape_scheduled_snapshot_time_list::de_scheduled_snapshot_time_list(&mut tag)
179 ?
180 )
181 ;
182 builder = builder.set_next_invocations(var_5);
183 }
184 ,
185 s if s.matches("AssociatedClusterCount") => {
186 let var_6 =
187 Some(
188 {
189 <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
190 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
191 )
192 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.redshift#IntegerOptional`)"))
193 }
194 ?
195 )
196 ;
197 builder = builder.set_associated_cluster_count(var_6);
198 }
199 ,
200 s if s.matches("AssociatedClusters") => {
201 let var_7 =
202 Some(
203 crate::protocol_serde::shape_associated_cluster_list::de_associated_cluster_list(&mut tag)
204 ?
205 )
206 ;
207 builder = builder.set_associated_clusters(var_7);
208 }
209 ,
210 _ => {}
211 }
212 }
213 } else {
214 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
215 "expected ModifySnapshotScheduleResult tag",
216 ));
217 };
218 Ok(builder)
219}