aws-sdk-opsworks 0.27.0

AWS SDK for AWS OpsWorks
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_layer<'a, I>(
    tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::types::Layer>, aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<
        Item = Result<
            aws_smithy_json::deserialize::Token<'a>,
            aws_smithy_json::deserialize::error::DeserializeError,
        >,
    >,
{
    match tokens.next().transpose()? {
        Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::LayerBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                        match key.to_unescaped()?.as_ref() {
                            "Arn" => {
                                builder = builder.set_arn(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "StackId" => {
                                builder = builder.set_stack_id(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "LayerId" => {
                                builder = builder.set_layer_id(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "Type" => {
                                builder = builder.set_type(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| {
                                        s.to_unescaped()
                                            .map(|u| crate::types::LayerType::from(u.as_ref()))
                                    })
                                    .transpose()?,
                                );
                            }
                            "Name" => {
                                builder = builder.set_name(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "Shortname" => {
                                builder = builder.set_shortname(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "Attributes" => {
                                builder = builder.set_attributes(
                                    crate::protocol_serde::shape_layer_attributes::de_layer_attributes(tokens)?
                                );
                            }
                            "CloudWatchLogsConfiguration" => {
                                builder = builder.set_cloud_watch_logs_configuration(
                                    crate::protocol_serde::shape_cloud_watch_logs_configuration::de_cloud_watch_logs_configuration(tokens)?
                                );
                            }
                            "CustomInstanceProfileArn" => {
                                builder = builder.set_custom_instance_profile_arn(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "CustomJson" => {
                                builder = builder.set_custom_json(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "CustomSecurityGroupIds" => {
                                builder = builder.set_custom_security_group_ids(
                                    crate::protocol_serde::shape_strings::de_strings(tokens)?,
                                );
                            }
                            "DefaultSecurityGroupNames" => {
                                builder = builder.set_default_security_group_names(
                                    crate::protocol_serde::shape_strings::de_strings(tokens)?,
                                );
                            }
                            "Packages" => {
                                builder = builder.set_packages(
                                    crate::protocol_serde::shape_strings::de_strings(tokens)?,
                                );
                            }
                            "VolumeConfigurations" => {
                                builder = builder.set_volume_configurations(
                                    crate::protocol_serde::shape_volume_configurations::de_volume_configurations(tokens)?
                                );
                            }
                            "EnableAutoHealing" => {
                                builder = builder.set_enable_auto_healing(
                                    aws_smithy_json::deserialize::token::expect_bool_or_null(
                                        tokens.next(),
                                    )?,
                                );
                            }
                            "AutoAssignElasticIps" => {
                                builder = builder.set_auto_assign_elastic_ips(
                                    aws_smithy_json::deserialize::token::expect_bool_or_null(
                                        tokens.next(),
                                    )?,
                                );
                            }
                            "AutoAssignPublicIps" => {
                                builder = builder.set_auto_assign_public_ips(
                                    aws_smithy_json::deserialize::token::expect_bool_or_null(
                                        tokens.next(),
                                    )?,
                                );
                            }
                            "DefaultRecipes" => {
                                builder = builder.set_default_recipes(
                                    crate::protocol_serde::shape_recipes::de_recipes(tokens)?,
                                );
                            }
                            "CustomRecipes" => {
                                builder = builder.set_custom_recipes(
                                    crate::protocol_serde::shape_recipes::de_recipes(tokens)?,
                                );
                            }
                            "CreatedAt" => {
                                builder = builder.set_created_at(
                                    aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "InstallUpdatesOnBoot" => {
                                builder = builder.set_install_updates_on_boot(
                                    aws_smithy_json::deserialize::token::expect_bool_or_null(
                                        tokens.next(),
                                    )?,
                                );
                            }
                            "UseEbsOptimizedInstances" => {
                                builder = builder.set_use_ebs_optimized_instances(
                                    aws_smithy_json::deserialize::token::expect_bool_or_null(
                                        tokens.next(),
                                    )?,
                                );
                            }
                            "LifecycleEventConfiguration" => {
                                builder = builder.set_lifecycle_event_configuration(
                                    crate::protocol_serde::shape_lifecycle_event_configuration::de_lifecycle_event_configuration(tokens)?
                                );
                            }
                            _ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
                        }
                    }
                    other => {
                        return Err(
                            aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                                "expected object key or end object, found: {:?}",
                                other
                            )),
                        )
                    }
                }
            }
            Ok(Some(builder.build()))
        }
        _ => Err(
            aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ),
        ),
    }
}