aws_sdk_ec2/protocol_serde/
shape_create_volume.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_volume_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_volume::CreateVolumeOutput, crate::operation::create_volume::CreateVolumeError> {
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_volume::CreateVolumeError::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_volume::CreateVolumeError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_create_volume_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_volume::CreateVolumeOutput, crate::operation::create_volume::CreateVolumeError> {
22    Ok({
23        #[allow(unused_mut)]
24        let mut output = crate::operation::create_volume::builders::CreateVolumeOutputBuilder::default();
25        output = crate::protocol_serde::shape_create_volume::de_create_volume(_response_body, output)
26            .map_err(crate::operation::create_volume::CreateVolumeError::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_volume(
34    inp: &[u8],
35    mut builder: crate::operation::create_volume::builders::CreateVolumeOutputBuilder,
36) -> std::result::Result<crate::operation::create_volume::builders::CreateVolumeOutputBuilder, ::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("CreateVolumeResponse")) {
44        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
45            "invalid root, expected CreateVolumeResponse 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("availabilityZoneId") /* AvailabilityZoneId com.amazonaws.ec2.synthetic#CreateVolumeOutput$AvailabilityZoneId */ =>  {
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_availability_zone_id(var_1);
62            }
63            ,
64            s if s.matches("outpostArn") /* OutpostArn com.amazonaws.ec2.synthetic#CreateVolumeOutput$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("iops") /* Iops com.amazonaws.ec2.synthetic#CreateVolumeOutput$Iops */ =>  {
78                let var_3 =
79                    Some(
80                         {
81                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
82                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
83                            )
84                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
85                        }
86                        ?
87                    )
88                ;
89                builder = builder.set_iops(var_3);
90            }
91            ,
92            s if s.matches("tagSet") /* Tags com.amazonaws.ec2.synthetic#CreateVolumeOutput$Tags */ =>  {
93                let var_4 =
94                    Some(
95                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
96                        ?
97                    )
98                ;
99                builder = builder.set_tags(var_4);
100            }
101            ,
102            s if s.matches("volumeType") /* VolumeType com.amazonaws.ec2.synthetic#CreateVolumeOutput$VolumeType */ =>  {
103                let var_5 =
104                    Some(
105                        Result::<crate::types::VolumeType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
106                            crate::types::VolumeType::from(
107                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
108                            )
109                        )
110                        ?
111                    )
112                ;
113                builder = builder.set_volume_type(var_5);
114            }
115            ,
116            s if s.matches("fastRestored") /* FastRestored com.amazonaws.ec2.synthetic#CreateVolumeOutput$FastRestored */ =>  {
117                let var_6 =
118                    Some(
119                         {
120                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
121                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
122                            )
123                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
124                        }
125                        ?
126                    )
127                ;
128                builder = builder.set_fast_restored(var_6);
129            }
130            ,
131            s if s.matches("multiAttachEnabled") /* MultiAttachEnabled com.amazonaws.ec2.synthetic#CreateVolumeOutput$MultiAttachEnabled */ =>  {
132                let var_7 =
133                    Some(
134                         {
135                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
136                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
137                            )
138                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
139                        }
140                        ?
141                    )
142                ;
143                builder = builder.set_multi_attach_enabled(var_7);
144            }
145            ,
146            s if s.matches("throughput") /* Throughput com.amazonaws.ec2.synthetic#CreateVolumeOutput$Throughput */ =>  {
147                let var_8 =
148                    Some(
149                         {
150                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
151                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
152                            )
153                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
154                        }
155                        ?
156                    )
157                ;
158                builder = builder.set_throughput(var_8);
159            }
160            ,
161            s if s.matches("sseType") /* SseType com.amazonaws.ec2.synthetic#CreateVolumeOutput$SseType */ =>  {
162                let var_9 =
163                    Some(
164                        Result::<crate::types::SseType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
165                            crate::types::SseType::from(
166                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
167                            )
168                        )
169                        ?
170                    )
171                ;
172                builder = builder.set_sse_type(var_9);
173            }
174            ,
175            s if s.matches("operator") /* Operator com.amazonaws.ec2.synthetic#CreateVolumeOutput$Operator */ =>  {
176                let var_10 =
177                    Some(
178                        crate::protocol_serde::shape_operator_response::de_operator_response(&mut tag)
179                        ?
180                    )
181                ;
182                builder = builder.set_operator(var_10);
183            }
184            ,
185            s if s.matches("volumeInitializationRate") /* VolumeInitializationRate com.amazonaws.ec2.synthetic#CreateVolumeOutput$VolumeInitializationRate */ =>  {
186                let var_11 =
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.ec2#Integer`)"))
193                        }
194                        ?
195                    )
196                ;
197                builder = builder.set_volume_initialization_rate(var_11);
198            }
199            ,
200            s if s.matches("volumeId") /* VolumeId com.amazonaws.ec2.synthetic#CreateVolumeOutput$VolumeId */ =>  {
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_volume_id(var_12);
211            }
212            ,
213            s if s.matches("size") /* Size com.amazonaws.ec2.synthetic#CreateVolumeOutput$Size */ =>  {
214                let var_13 =
215                    Some(
216                         {
217                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
218                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
219                            )
220                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
221                        }
222                        ?
223                    )
224                ;
225                builder = builder.set_size(var_13);
226            }
227            ,
228            s if s.matches("snapshotId") /* SnapshotId com.amazonaws.ec2.synthetic#CreateVolumeOutput$SnapshotId */ =>  {
229                let var_14 =
230                    Some(
231                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
232                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
233                            .into()
234                        )
235                        ?
236                    )
237                ;
238                builder = builder.set_snapshot_id(var_14);
239            }
240            ,
241            s if s.matches("availabilityZone") /* AvailabilityZone com.amazonaws.ec2.synthetic#CreateVolumeOutput$AvailabilityZone */ =>  {
242                let var_15 =
243                    Some(
244                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
245                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
246                            .into()
247                        )
248                        ?
249                    )
250                ;
251                builder = builder.set_availability_zone(var_15);
252            }
253            ,
254            s if s.matches("status") /* State com.amazonaws.ec2.synthetic#CreateVolumeOutput$State */ =>  {
255                let var_16 =
256                    Some(
257                        Result::<crate::types::VolumeState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
258                            crate::types::VolumeState::from(
259                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
260                            )
261                        )
262                        ?
263                    )
264                ;
265                builder = builder.set_state(var_16);
266            }
267            ,
268            s if s.matches("createTime") /* CreateTime com.amazonaws.ec2.synthetic#CreateVolumeOutput$CreateTime */ =>  {
269                let var_17 =
270                    Some(
271                        ::aws_smithy_types::DateTime::from_str(
272                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
273                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
274                        )
275                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
276                        ?
277                    )
278                ;
279                builder = builder.set_create_time(var_17);
280            }
281            ,
282            s if s.matches("attachmentSet") /* Attachments com.amazonaws.ec2.synthetic#CreateVolumeOutput$Attachments */ =>  {
283                let var_18 =
284                    Some(
285                        crate::protocol_serde::shape_volume_attachment_list::de_volume_attachment_list(&mut tag)
286                        ?
287                    )
288                ;
289                builder = builder.set_attachments(var_18);
290            }
291            ,
292            s if s.matches("encrypted") /* Encrypted com.amazonaws.ec2.synthetic#CreateVolumeOutput$Encrypted */ =>  {
293                let var_19 =
294                    Some(
295                         {
296                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
297                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
298                            )
299                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
300                        }
301                        ?
302                    )
303                ;
304                builder = builder.set_encrypted(var_19);
305            }
306            ,
307            s if s.matches("kmsKeyId") /* KmsKeyId com.amazonaws.ec2.synthetic#CreateVolumeOutput$KmsKeyId */ =>  {
308                let var_20 =
309                    Some(
310                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
311                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
312                            .into()
313                        )
314                        ?
315                    )
316                ;
317                builder = builder.set_kms_key_id(var_20);
318            }
319            ,
320            _ => {}
321        }
322    }
323    Ok(builder)
324}