aws_sdk_ec2/protocol_serde/
shape_create_snapshot.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_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::create_snapshot::CreateSnapshotOutput, crate::operation::create_snapshot::CreateSnapshotError> {
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::create_snapshot::CreateSnapshotError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    Err(crate::operation::create_snapshot::CreateSnapshotError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_create_snapshot_http_response(
18    _response_status: u16,
19    _response_headers: &::aws_smithy_runtime_api::http::Headers,
20    _response_body: &[u8],
21) -> std::result::Result<crate::operation::create_snapshot::CreateSnapshotOutput, crate::operation::create_snapshot::CreateSnapshotError> {
22    Ok({
23        #[allow(unused_mut)]
24        let mut output = crate::operation::create_snapshot::builders::CreateSnapshotOutputBuilder::default();
25        output = crate::protocol_serde::shape_create_snapshot::de_create_snapshot(_response_body, output)
26            .map_err(crate::operation::create_snapshot::CreateSnapshotError::unhandled)?;
27        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
28        output.build()
29    })
30}
31
32#[allow(unused_mut)]
33pub fn de_create_snapshot(
34    inp: &[u8],
35    mut builder: crate::operation::create_snapshot::builders::CreateSnapshotOutputBuilder,
36) -> std::result::Result<crate::operation::create_snapshot::builders::CreateSnapshotOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
37    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
38
39    #[allow(unused_mut)]
40    let mut decoder = doc.root_element()?;
41    #[allow(unused_variables)]
42    let start_el = decoder.start_el();
43    if !(start_el.matches("CreateSnapshotResponse")) {
44        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
45            "invalid root, expected CreateSnapshotResponse got {:?}",
46            start_el
47        )));
48    }
49    while let Some(mut tag) = decoder.next_tag() {
50        match tag.start_el() {
51            s if s.matches("ownerAlias") /* OwnerAlias com.amazonaws.ec2.synthetic#CreateSnapshotOutput$OwnerAlias */ =>  {
52                let var_1 =
53                    Some(
54                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
55                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
56                            .into()
57                        )
58                        ?
59                    )
60                ;
61                builder = builder.set_owner_alias(var_1);
62            }
63            ,
64            s if s.matches("outpostArn") /* OutpostArn com.amazonaws.ec2.synthetic#CreateSnapshotOutput$OutpostArn */ =>  {
65                let var_2 =
66                    Some(
67                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
68                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
69                            .into()
70                        )
71                        ?
72                    )
73                ;
74                builder = builder.set_outpost_arn(var_2);
75            }
76            ,
77            s if s.matches("tagSet") /* Tags com.amazonaws.ec2.synthetic#CreateSnapshotOutput$Tags */ =>  {
78                let var_3 =
79                    Some(
80                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
81                        ?
82                    )
83                ;
84                builder = builder.set_tags(var_3);
85            }
86            ,
87            s if s.matches("storageTier") /* StorageTier com.amazonaws.ec2.synthetic#CreateSnapshotOutput$StorageTier */ =>  {
88                let var_4 =
89                    Some(
90                        Result::<crate::types::StorageTier, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
91                            crate::types::StorageTier::from(
92                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
93                            )
94                        )
95                        ?
96                    )
97                ;
98                builder = builder.set_storage_tier(var_4);
99            }
100            ,
101            s if s.matches("restoreExpiryTime") /* RestoreExpiryTime com.amazonaws.ec2.synthetic#CreateSnapshotOutput$RestoreExpiryTime */ =>  {
102                let var_5 =
103                    Some(
104                        ::aws_smithy_types::DateTime::from_str(
105                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
106                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
107                        )
108                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
109                        ?
110                    )
111                ;
112                builder = builder.set_restore_expiry_time(var_5);
113            }
114            ,
115            s if s.matches("sseType") /* SseType com.amazonaws.ec2.synthetic#CreateSnapshotOutput$SseType */ =>  {
116                let var_6 =
117                    Some(
118                        Result::<crate::types::SseType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
119                            crate::types::SseType::from(
120                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
121                            )
122                        )
123                        ?
124                    )
125                ;
126                builder = builder.set_sse_type(var_6);
127            }
128            ,
129            s if s.matches("availabilityZone") /* AvailabilityZone com.amazonaws.ec2.synthetic#CreateSnapshotOutput$AvailabilityZone */ =>  {
130                let var_7 =
131                    Some(
132                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
133                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
134                            .into()
135                        )
136                        ?
137                    )
138                ;
139                builder = builder.set_availability_zone(var_7);
140            }
141            ,
142            s if s.matches("transferType") /* TransferType com.amazonaws.ec2.synthetic#CreateSnapshotOutput$TransferType */ =>  {
143                let var_8 =
144                    Some(
145                        Result::<crate::types::TransferType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
146                            crate::types::TransferType::from(
147                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
148                            )
149                        )
150                        ?
151                    )
152                ;
153                builder = builder.set_transfer_type(var_8);
154            }
155            ,
156            s if s.matches("completionDurationMinutes") /* CompletionDurationMinutes com.amazonaws.ec2.synthetic#CreateSnapshotOutput$CompletionDurationMinutes */ =>  {
157                let var_9 =
158                    Some(
159                         {
160                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
161                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
162                            )
163                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#SnapshotCompletionDurationMinutesResponse`)"))
164                        }
165                        ?
166                    )
167                ;
168                builder = builder.set_completion_duration_minutes(var_9);
169            }
170            ,
171            s if s.matches("completionTime") /* CompletionTime com.amazonaws.ec2.synthetic#CreateSnapshotOutput$CompletionTime */ =>  {
172                let var_10 =
173                    Some(
174                        ::aws_smithy_types::DateTime::from_str(
175                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
176                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
177                        )
178                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
179                        ?
180                    )
181                ;
182                builder = builder.set_completion_time(var_10);
183            }
184            ,
185            s if s.matches("fullSnapshotSizeInBytes") /* FullSnapshotSizeInBytes com.amazonaws.ec2.synthetic#CreateSnapshotOutput$FullSnapshotSizeInBytes */ =>  {
186                let var_11 =
187                    Some(
188                         {
189                            <i64 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 (long: `com.amazonaws.ec2#Long`)"))
193                        }
194                        ?
195                    )
196                ;
197                builder = builder.set_full_snapshot_size_in_bytes(var_11);
198            }
199            ,
200            s if s.matches("snapshotId") /* SnapshotId com.amazonaws.ec2.synthetic#CreateSnapshotOutput$SnapshotId */ =>  {
201                let var_12 =
202                    Some(
203                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
204                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
205                            .into()
206                        )
207                        ?
208                    )
209                ;
210                builder = builder.set_snapshot_id(var_12);
211            }
212            ,
213            s if s.matches("volumeId") /* VolumeId com.amazonaws.ec2.synthetic#CreateSnapshotOutput$VolumeId */ =>  {
214                let var_13 =
215                    Some(
216                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
217                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
218                            .into()
219                        )
220                        ?
221                    )
222                ;
223                builder = builder.set_volume_id(var_13);
224            }
225            ,
226            s if s.matches("status") /* State com.amazonaws.ec2.synthetic#CreateSnapshotOutput$State */ =>  {
227                let var_14 =
228                    Some(
229                        Result::<crate::types::SnapshotState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
230                            crate::types::SnapshotState::from(
231                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
232                            )
233                        )
234                        ?
235                    )
236                ;
237                builder = builder.set_state(var_14);
238            }
239            ,
240            s if s.matches("statusMessage") /* StateMessage com.amazonaws.ec2.synthetic#CreateSnapshotOutput$StateMessage */ =>  {
241                let var_15 =
242                    Some(
243                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
244                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
245                            .into()
246                        )
247                        ?
248                    )
249                ;
250                builder = builder.set_state_message(var_15);
251            }
252            ,
253            s if s.matches("startTime") /* StartTime com.amazonaws.ec2.synthetic#CreateSnapshotOutput$StartTime */ =>  {
254                let var_16 =
255                    Some(
256                        ::aws_smithy_types::DateTime::from_str(
257                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
258                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
259                        )
260                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
261                        ?
262                    )
263                ;
264                builder = builder.set_start_time(var_16);
265            }
266            ,
267            s if s.matches("progress") /* Progress com.amazonaws.ec2.synthetic#CreateSnapshotOutput$Progress */ =>  {
268                let var_17 =
269                    Some(
270                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
271                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
272                            .into()
273                        )
274                        ?
275                    )
276                ;
277                builder = builder.set_progress(var_17);
278            }
279            ,
280            s if s.matches("ownerId") /* OwnerId com.amazonaws.ec2.synthetic#CreateSnapshotOutput$OwnerId */ =>  {
281                let var_18 =
282                    Some(
283                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
284                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
285                            .into()
286                        )
287                        ?
288                    )
289                ;
290                builder = builder.set_owner_id(var_18);
291            }
292            ,
293            s if s.matches("description") /* Description com.amazonaws.ec2.synthetic#CreateSnapshotOutput$Description */ =>  {
294                let var_19 =
295                    Some(
296                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
297                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
298                            .into()
299                        )
300                        ?
301                    )
302                ;
303                builder = builder.set_description(var_19);
304            }
305            ,
306            s if s.matches("volumeSize") /* VolumeSize com.amazonaws.ec2.synthetic#CreateSnapshotOutput$VolumeSize */ =>  {
307                let var_20 =
308                    Some(
309                         {
310                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
311                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
312                            )
313                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
314                        }
315                        ?
316                    )
317                ;
318                builder = builder.set_volume_size(var_20);
319            }
320            ,
321            s if s.matches("encrypted") /* Encrypted com.amazonaws.ec2.synthetic#CreateSnapshotOutput$Encrypted */ =>  {
322                let var_21 =
323                    Some(
324                         {
325                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
326                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
327                            )
328                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
329                        }
330                        ?
331                    )
332                ;
333                builder = builder.set_encrypted(var_21);
334            }
335            ,
336            s if s.matches("kmsKeyId") /* KmsKeyId com.amazonaws.ec2.synthetic#CreateSnapshotOutput$KmsKeyId */ =>  {
337                let var_22 =
338                    Some(
339                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
340                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
341                            .into()
342                        )
343                        ?
344                    )
345                ;
346                builder = builder.set_kms_key_id(var_22);
347            }
348            ,
349            s if s.matches("dataEncryptionKeyId") /* DataEncryptionKeyId com.amazonaws.ec2.synthetic#CreateSnapshotOutput$DataEncryptionKeyId */ =>  {
350                let var_23 =
351                    Some(
352                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
353                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
354                            .into()
355                        )
356                        ?
357                    )
358                ;
359                builder = builder.set_data_encryption_key_id(var_23);
360            }
361            ,
362            _ => {}
363        }
364    }
365    Ok(builder)
366}