aws_sdk_ec2/protocol_serde/
shape_capacity_reservation.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_capacity_reservation(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::CapacityReservation, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::CapacityReservation::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("capacityReservationId") /* CapacityReservationId com.amazonaws.ec2#CapacityReservation$CapacityReservationId */ =>  {
11                let var_1 =
12                    Some(
13                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
14                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
15                            .into()
16                        )
17                        ?
18                    )
19                ;
20                builder = builder.set_capacity_reservation_id(var_1);
21            }
22            ,
23            s if s.matches("ownerId") /* OwnerId com.amazonaws.ec2#CapacityReservation$OwnerId */ =>  {
24                let var_2 =
25                    Some(
26                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
27                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
28                            .into()
29                        )
30                        ?
31                    )
32                ;
33                builder = builder.set_owner_id(var_2);
34            }
35            ,
36            s if s.matches("capacityReservationArn") /* CapacityReservationArn com.amazonaws.ec2#CapacityReservation$CapacityReservationArn */ =>  {
37                let var_3 =
38                    Some(
39                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
40                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
41                            .into()
42                        )
43                        ?
44                    )
45                ;
46                builder = builder.set_capacity_reservation_arn(var_3);
47            }
48            ,
49            s if s.matches("availabilityZoneId") /* AvailabilityZoneId com.amazonaws.ec2#CapacityReservation$AvailabilityZoneId */ =>  {
50                let var_4 =
51                    Some(
52                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
53                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
54                            .into()
55                        )
56                        ?
57                    )
58                ;
59                builder = builder.set_availability_zone_id(var_4);
60            }
61            ,
62            s if s.matches("instanceType") /* InstanceType com.amazonaws.ec2#CapacityReservation$InstanceType */ =>  {
63                let var_5 =
64                    Some(
65                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
66                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
67                            .into()
68                        )
69                        ?
70                    )
71                ;
72                builder = builder.set_instance_type(var_5);
73            }
74            ,
75            s if s.matches("instancePlatform") /* InstancePlatform com.amazonaws.ec2#CapacityReservation$InstancePlatform */ =>  {
76                let var_6 =
77                    Some(
78                        Result::<crate::types::CapacityReservationInstancePlatform, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
79                            crate::types::CapacityReservationInstancePlatform::from(
80                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
81                            )
82                        )
83                        ?
84                    )
85                ;
86                builder = builder.set_instance_platform(var_6);
87            }
88            ,
89            s if s.matches("availabilityZone") /* AvailabilityZone com.amazonaws.ec2#CapacityReservation$AvailabilityZone */ =>  {
90                let var_7 =
91                    Some(
92                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
93                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
94                            .into()
95                        )
96                        ?
97                    )
98                ;
99                builder = builder.set_availability_zone(var_7);
100            }
101            ,
102            s if s.matches("tenancy") /* Tenancy com.amazonaws.ec2#CapacityReservation$Tenancy */ =>  {
103                let var_8 =
104                    Some(
105                        Result::<crate::types::CapacityReservationTenancy, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
106                            crate::types::CapacityReservationTenancy::from(
107                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
108                            )
109                        )
110                        ?
111                    )
112                ;
113                builder = builder.set_tenancy(var_8);
114            }
115            ,
116            s if s.matches("totalInstanceCount") /* TotalInstanceCount com.amazonaws.ec2#CapacityReservation$TotalInstanceCount */ =>  {
117                let var_9 =
118                    Some(
119                         {
120                            <i32 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 (integer: `com.amazonaws.ec2#Integer`)"))
124                        }
125                        ?
126                    )
127                ;
128                builder = builder.set_total_instance_count(var_9);
129            }
130            ,
131            s if s.matches("availableInstanceCount") /* AvailableInstanceCount com.amazonaws.ec2#CapacityReservation$AvailableInstanceCount */ =>  {
132                let var_10 =
133                    Some(
134                         {
135                            <i32 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 (integer: `com.amazonaws.ec2#Integer`)"))
139                        }
140                        ?
141                    )
142                ;
143                builder = builder.set_available_instance_count(var_10);
144            }
145            ,
146            s if s.matches("ebsOptimized") /* EbsOptimized com.amazonaws.ec2#CapacityReservation$EbsOptimized */ =>  {
147                let var_11 =
148                    Some(
149                         {
150                            <bool 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 (boolean: `com.amazonaws.ec2#Boolean`)"))
154                        }
155                        ?
156                    )
157                ;
158                builder = builder.set_ebs_optimized(var_11);
159            }
160            ,
161            s if s.matches("ephemeralStorage") /* EphemeralStorage com.amazonaws.ec2#CapacityReservation$EphemeralStorage */ =>  {
162                let var_12 =
163                    Some(
164                         {
165                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
166                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
167                            )
168                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
169                        }
170                        ?
171                    )
172                ;
173                builder = builder.set_ephemeral_storage(var_12);
174            }
175            ,
176            s if s.matches("state") /* State com.amazonaws.ec2#CapacityReservation$State */ =>  {
177                let var_13 =
178                    Some(
179                        Result::<crate::types::CapacityReservationState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
180                            crate::types::CapacityReservationState::from(
181                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
182                            )
183                        )
184                        ?
185                    )
186                ;
187                builder = builder.set_state(var_13);
188            }
189            ,
190            s if s.matches("startDate") /* StartDate com.amazonaws.ec2#CapacityReservation$StartDate */ =>  {
191                let var_14 =
192                    Some(
193                        ::aws_smithy_types::DateTime::from_str(
194                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
195                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
196                        )
197                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
198                        ?
199                    )
200                ;
201                builder = builder.set_start_date(var_14);
202            }
203            ,
204            s if s.matches("endDate") /* EndDate com.amazonaws.ec2#CapacityReservation$EndDate */ =>  {
205                let var_15 =
206                    Some(
207                        ::aws_smithy_types::DateTime::from_str(
208                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
209                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
210                        )
211                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
212                        ?
213                    )
214                ;
215                builder = builder.set_end_date(var_15);
216            }
217            ,
218            s if s.matches("endDateType") /* EndDateType com.amazonaws.ec2#CapacityReservation$EndDateType */ =>  {
219                let var_16 =
220                    Some(
221                        Result::<crate::types::EndDateType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
222                            crate::types::EndDateType::from(
223                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
224                            )
225                        )
226                        ?
227                    )
228                ;
229                builder = builder.set_end_date_type(var_16);
230            }
231            ,
232            s if s.matches("instanceMatchCriteria") /* InstanceMatchCriteria com.amazonaws.ec2#CapacityReservation$InstanceMatchCriteria */ =>  {
233                let var_17 =
234                    Some(
235                        Result::<crate::types::InstanceMatchCriteria, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
236                            crate::types::InstanceMatchCriteria::from(
237                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
238                            )
239                        )
240                        ?
241                    )
242                ;
243                builder = builder.set_instance_match_criteria(var_17);
244            }
245            ,
246            s if s.matches("createDate") /* CreateDate com.amazonaws.ec2#CapacityReservation$CreateDate */ =>  {
247                let var_18 =
248                    Some(
249                        ::aws_smithy_types::DateTime::from_str(
250                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
251                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
252                        )
253                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
254                        ?
255                    )
256                ;
257                builder = builder.set_create_date(var_18);
258            }
259            ,
260            s if s.matches("tagSet") /* Tags com.amazonaws.ec2#CapacityReservation$Tags */ =>  {
261                let var_19 =
262                    Some(
263                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
264                        ?
265                    )
266                ;
267                builder = builder.set_tags(var_19);
268            }
269            ,
270            s if s.matches("outpostArn") /* OutpostArn com.amazonaws.ec2#CapacityReservation$OutpostArn */ =>  {
271                let var_20 =
272                    Some(
273                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
274                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
275                            .into()
276                        )
277                        ?
278                    )
279                ;
280                builder = builder.set_outpost_arn(var_20);
281            }
282            ,
283            s if s.matches("capacityReservationFleetId") /* CapacityReservationFleetId com.amazonaws.ec2#CapacityReservation$CapacityReservationFleetId */ =>  {
284                let var_21 =
285                    Some(
286                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
287                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
288                            .into()
289                        )
290                        ?
291                    )
292                ;
293                builder = builder.set_capacity_reservation_fleet_id(var_21);
294            }
295            ,
296            s if s.matches("placementGroupArn") /* PlacementGroupArn com.amazonaws.ec2#CapacityReservation$PlacementGroupArn */ =>  {
297                let var_22 =
298                    Some(
299                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
300                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
301                            .into()
302                        )
303                        ?
304                    )
305                ;
306                builder = builder.set_placement_group_arn(var_22);
307            }
308            ,
309            s if s.matches("capacityAllocationSet") /* CapacityAllocations com.amazonaws.ec2#CapacityReservation$CapacityAllocations */ =>  {
310                let var_23 =
311                    Some(
312                        crate::protocol_serde::shape_capacity_allocations::de_capacity_allocations(&mut tag)
313                        ?
314                    )
315                ;
316                builder = builder.set_capacity_allocations(var_23);
317            }
318            ,
319            s if s.matches("reservationType") /* ReservationType com.amazonaws.ec2#CapacityReservation$ReservationType */ =>  {
320                let var_24 =
321                    Some(
322                        Result::<crate::types::CapacityReservationType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
323                            crate::types::CapacityReservationType::from(
324                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
325                            )
326                        )
327                        ?
328                    )
329                ;
330                builder = builder.set_reservation_type(var_24);
331            }
332            ,
333            s if s.matches("unusedReservationBillingOwnerId") /* UnusedReservationBillingOwnerId com.amazonaws.ec2#CapacityReservation$UnusedReservationBillingOwnerId */ =>  {
334                let var_25 =
335                    Some(
336                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
337                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
338                            .into()
339                        )
340                        ?
341                    )
342                ;
343                builder = builder.set_unused_reservation_billing_owner_id(var_25);
344            }
345            ,
346            s if s.matches("commitmentInfo") /* CommitmentInfo com.amazonaws.ec2#CapacityReservation$CommitmentInfo */ =>  {
347                let var_26 =
348                    Some(
349                        crate::protocol_serde::shape_capacity_reservation_commitment_info::de_capacity_reservation_commitment_info(&mut tag)
350                        ?
351                    )
352                ;
353                builder = builder.set_commitment_info(var_26);
354            }
355            ,
356            s if s.matches("deliveryPreference") /* DeliveryPreference com.amazonaws.ec2#CapacityReservation$DeliveryPreference */ =>  {
357                let var_27 =
358                    Some(
359                        Result::<crate::types::CapacityReservationDeliveryPreference, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
360                            crate::types::CapacityReservationDeliveryPreference::from(
361                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
362                            )
363                        )
364                        ?
365                    )
366                ;
367                builder = builder.set_delivery_preference(var_27);
368            }
369            ,
370            s if s.matches("capacityBlockId") /* CapacityBlockId com.amazonaws.ec2#CapacityReservation$CapacityBlockId */ =>  {
371                let var_28 =
372                    Some(
373                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
374                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
375                            .into()
376                        )
377                        ?
378                    )
379                ;
380                builder = builder.set_capacity_block_id(var_28);
381            }
382            ,
383            _ => {}
384        }
385    }
386    Ok(builder.build())
387}