aws-sdk-ec2 1.221.0

AWS SDK for Amazon Elastic Compute Cloud
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(unused_mut)]
pub fn ser_spot_fleet_launch_specification(
    mut writer: ::aws_smithy_query::QueryValueWriter,
    input: &crate::types::SpotFleetLaunchSpecification,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1 = writer.prefix("AddressingType");
    if let Some(var_2) = &input.addressing_type {
        scope_1.string(var_2);
    }
    #[allow(unused_mut)]
    let mut scope_3 = writer.prefix("BlockDeviceMapping");
    if let Some(var_4) = &input.block_device_mappings {
        if !var_4.is_empty() {
            let mut list_6 = scope_3.start_list(true, Some("item"));
            for item_5 in var_4 {
                #[allow(unused_mut)]
                let mut entry_7 = list_6.entry();
                crate::protocol_serde::shape_block_device_mapping::ser_block_device_mapping(entry_7, item_5)?;
            }
            list_6.finish();
        }
    }
    #[allow(unused_mut)]
    let mut scope_8 = writer.prefix("EbsOptimized");
    if let Some(var_9) = &input.ebs_optimized {
        scope_8.boolean(*var_9);
    }
    #[allow(unused_mut)]
    let mut scope_10 = writer.prefix("IamInstanceProfile");
    if let Some(var_11) = &input.iam_instance_profile {
        crate::protocol_serde::shape_iam_instance_profile_specification::ser_iam_instance_profile_specification(scope_10, var_11)?;
    }
    #[allow(unused_mut)]
    let mut scope_12 = writer.prefix("ImageId");
    if let Some(var_13) = &input.image_id {
        scope_12.string(var_13);
    }
    #[allow(unused_mut)]
    let mut scope_14 = writer.prefix("InstanceType");
    if let Some(var_15) = &input.instance_type {
        scope_14.string(var_15.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_16 = writer.prefix("KernelId");
    if let Some(var_17) = &input.kernel_id {
        scope_16.string(var_17);
    }
    #[allow(unused_mut)]
    let mut scope_18 = writer.prefix("KeyName");
    if let Some(var_19) = &input.key_name {
        scope_18.string(var_19);
    }
    #[allow(unused_mut)]
    let mut scope_20 = writer.prefix("Monitoring");
    if let Some(var_21) = &input.monitoring {
        crate::protocol_serde::shape_spot_fleet_monitoring::ser_spot_fleet_monitoring(scope_20, var_21)?;
    }
    #[allow(unused_mut)]
    let mut scope_22 = writer.prefix("NetworkInterfaceSet");
    if let Some(var_23) = &input.network_interfaces {
        if !var_23.is_empty() {
            let mut list_25 = scope_22.start_list(true, Some("item"));
            for item_24 in var_23 {
                #[allow(unused_mut)]
                let mut entry_26 = list_25.entry();
                crate::protocol_serde::shape_instance_network_interface_specification::ser_instance_network_interface_specification(
                    entry_26, item_24,
                )?;
            }
            list_25.finish();
        }
    }
    #[allow(unused_mut)]
    let mut scope_27 = writer.prefix("Placement");
    if let Some(var_28) = &input.placement {
        crate::protocol_serde::shape_spot_placement::ser_spot_placement(scope_27, var_28)?;
    }
    #[allow(unused_mut)]
    let mut scope_29 = writer.prefix("RamdiskId");
    if let Some(var_30) = &input.ramdisk_id {
        scope_29.string(var_30);
    }
    #[allow(unused_mut)]
    let mut scope_31 = writer.prefix("SpotPrice");
    if let Some(var_32) = &input.spot_price {
        scope_31.string(var_32);
    }
    #[allow(unused_mut)]
    let mut scope_33 = writer.prefix("SubnetId");
    if let Some(var_34) = &input.subnet_id {
        scope_33.string(var_34);
    }
    #[allow(unused_mut)]
    let mut scope_35 = writer.prefix("UserData");
    if let Some(var_36) = &input.user_data {
        scope_35.string(var_36);
    }
    #[allow(unused_mut)]
    let mut scope_37 = writer.prefix("WeightedCapacity");
    if let Some(var_38) = &input.weighted_capacity {
        scope_37.number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::Float((*var_38).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_39 = writer.prefix("TagSpecificationSet");
    if let Some(var_40) = &input.tag_specifications {
        if !var_40.is_empty() {
            let mut list_42 = scope_39.start_list(true, Some("item"));
            for item_41 in var_40 {
                #[allow(unused_mut)]
                let mut entry_43 = list_42.entry();
                crate::protocol_serde::shape_spot_fleet_tag_specification::ser_spot_fleet_tag_specification(entry_43, item_41)?;
            }
            list_42.finish();
        }
    }
    #[allow(unused_mut)]
    let mut scope_44 = writer.prefix("InstanceRequirements");
    if let Some(var_45) = &input.instance_requirements {
        crate::protocol_serde::shape_instance_requirements::ser_instance_requirements(scope_44, var_45)?;
    }
    #[allow(unused_mut)]
    let mut scope_46 = writer.prefix("GroupSet");
    if let Some(var_47) = &input.security_groups {
        if !var_47.is_empty() {
            let mut list_49 = scope_46.start_list(true, Some("item"));
            for item_48 in var_47 {
                #[allow(unused_mut)]
                let mut entry_50 = list_49.entry();
                crate::protocol_serde::shape_group_identifier::ser_group_identifier(entry_50, item_48)?;
            }
            list_49.finish();
        }
    }
    Ok(())
}

#[allow(clippy::needless_question_mark)]
pub fn de_spot_fleet_launch_specification(
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
) -> ::std::result::Result<crate::types::SpotFleetLaunchSpecification, ::aws_smithy_xml::decode::XmlDecodeError> {
    #[allow(unused_mut)]
    let mut builder = crate::types::SpotFleetLaunchSpecification::builder();
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("addressingType") /* AddressingType com.amazonaws.ec2#SpotFleetLaunchSpecification$AddressingType */ =>  {
                let var_51 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_addressing_type(var_51);
            }
            ,
            s if s.matches("blockDeviceMapping") /* BlockDeviceMappings com.amazonaws.ec2#SpotFleetLaunchSpecification$BlockDeviceMappings */ =>  {
                let var_52 =
                    Some(
                        crate::protocol_serde::shape_block_device_mapping_list::de_block_device_mapping_list(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_block_device_mappings(var_52);
            }
            ,
            s if s.matches("ebsOptimized") /* EbsOptimized com.amazonaws.ec2#SpotFleetLaunchSpecification$EbsOptimized */ =>  {
                let var_53 =
                    Some(
                         {
                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_ebs_optimized(var_53);
            }
            ,
            s if s.matches("iamInstanceProfile") /* IamInstanceProfile com.amazonaws.ec2#SpotFleetLaunchSpecification$IamInstanceProfile */ =>  {
                let var_54 =
                    Some(
                        crate::protocol_serde::shape_iam_instance_profile_specification::de_iam_instance_profile_specification(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_iam_instance_profile(var_54);
            }
            ,
            s if s.matches("imageId") /* ImageId com.amazonaws.ec2#SpotFleetLaunchSpecification$ImageId */ =>  {
                let var_55 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_image_id(var_55);
            }
            ,
            s if s.matches("instanceType") /* InstanceType com.amazonaws.ec2#SpotFleetLaunchSpecification$InstanceType */ =>  {
                let var_56 =
                    Some(
                        Result::<crate::types::InstanceType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::InstanceType::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_instance_type(var_56);
            }
            ,
            s if s.matches("kernelId") /* KernelId com.amazonaws.ec2#SpotFleetLaunchSpecification$KernelId */ =>  {
                let var_57 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_kernel_id(var_57);
            }
            ,
            s if s.matches("keyName") /* KeyName com.amazonaws.ec2#SpotFleetLaunchSpecification$KeyName */ =>  {
                let var_58 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_key_name(var_58);
            }
            ,
            s if s.matches("monitoring") /* Monitoring com.amazonaws.ec2#SpotFleetLaunchSpecification$Monitoring */ =>  {
                let var_59 =
                    Some(
                        crate::protocol_serde::shape_spot_fleet_monitoring::de_spot_fleet_monitoring(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_monitoring(var_59);
            }
            ,
            s if s.matches("networkInterfaceSet") /* NetworkInterfaces com.amazonaws.ec2#SpotFleetLaunchSpecification$NetworkInterfaces */ =>  {
                let var_60 =
                    Some(
                        crate::protocol_serde::shape_instance_network_interface_specification_list::de_instance_network_interface_specification_list(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_network_interfaces(var_60);
            }
            ,
            s if s.matches("placement") /* Placement com.amazonaws.ec2#SpotFleetLaunchSpecification$Placement */ =>  {
                let var_61 =
                    Some(
                        crate::protocol_serde::shape_spot_placement::de_spot_placement(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_placement(var_61);
            }
            ,
            s if s.matches("ramdiskId") /* RamdiskId com.amazonaws.ec2#SpotFleetLaunchSpecification$RamdiskId */ =>  {
                let var_62 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_ramdisk_id(var_62);
            }
            ,
            s if s.matches("spotPrice") /* SpotPrice com.amazonaws.ec2#SpotFleetLaunchSpecification$SpotPrice */ =>  {
                let var_63 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_spot_price(var_63);
            }
            ,
            s if s.matches("subnetId") /* SubnetId com.amazonaws.ec2#SpotFleetLaunchSpecification$SubnetId */ =>  {
                let var_64 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_subnet_id(var_64);
            }
            ,
            s if s.matches("userData") /* UserData com.amazonaws.ec2#SpotFleetLaunchSpecification$UserData */ =>  {
                let var_65 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_user_data(var_65);
            }
            ,
            s if s.matches("weightedCapacity") /* WeightedCapacity com.amazonaws.ec2#SpotFleetLaunchSpecification$WeightedCapacity */ =>  {
                let var_66 =
                    Some(
                         {
                            <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (double: `com.amazonaws.ec2#Double`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_weighted_capacity(var_66);
            }
            ,
            s if s.matches("tagSpecificationSet") /* TagSpecifications com.amazonaws.ec2#SpotFleetLaunchSpecification$TagSpecifications */ =>  {
                let var_67 =
                    Some(
                        crate::protocol_serde::shape_spot_fleet_tag_specification_list::de_spot_fleet_tag_specification_list(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_tag_specifications(var_67);
            }
            ,
            s if s.matches("instanceRequirements") /* InstanceRequirements com.amazonaws.ec2#SpotFleetLaunchSpecification$InstanceRequirements */ =>  {
                let var_68 =
                    Some(
                        crate::protocol_serde::shape_instance_requirements::de_instance_requirements(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_instance_requirements(var_68);
            }
            ,
            s if s.matches("groupSet") /* SecurityGroups com.amazonaws.ec2#SpotFleetLaunchSpecification$SecurityGroups */ =>  {
                let var_69 =
                    Some(
                        crate::protocol_serde::shape_group_identifier_list::de_group_identifier_list(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_security_groups(var_69);
            }
            ,
            _ => {}
        }
    }
    Ok(builder.build())
}