aws-sdk-imagebuilder 1.111.0

AWS SDK for EC2 Image Builder
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_image<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::Image>, ::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::ImageBuilder::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()?,
                            );
                        }
                        "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::ImageType::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()?,
                            );
                        }
                        "version" => {
                            builder = builder.set_version(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "platform" => {
                            builder = builder.set_platform(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::Platform::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "enhancedImageMetadataEnabled" => {
                            builder = builder
                                .set_enhanced_image_metadata_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "osVersion" => {
                            builder = builder.set_os_version(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "state" => {
                            builder = builder.set_state(crate::protocol_serde::shape_image_state::de_image_state(tokens, _value)?);
                        }
                        "imageRecipe" => {
                            builder = builder.set_image_recipe(crate::protocol_serde::shape_image_recipe::de_image_recipe(tokens, _value)?);
                        }
                        "containerRecipe" => {
                            builder =
                                builder.set_container_recipe(crate::protocol_serde::shape_container_recipe::de_container_recipe(tokens, _value)?);
                        }
                        "sourcePipelineName" => {
                            builder = builder.set_source_pipeline_name(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "sourcePipelineArn" => {
                            builder = builder.set_source_pipeline_arn(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "infrastructureConfiguration" => {
                            builder = builder.set_infrastructure_configuration(
                                crate::protocol_serde::shape_infrastructure_configuration::de_infrastructure_configuration(tokens, _value)?,
                            );
                        }
                        "distributionConfiguration" => {
                            builder = builder.set_distribution_configuration(
                                crate::protocol_serde::shape_distribution_configuration::de_distribution_configuration(tokens, _value)?,
                            );
                        }
                        "imageTestsConfiguration" => {
                            builder = builder.set_image_tests_configuration(
                                crate::protocol_serde::shape_image_tests_configuration::de_image_tests_configuration(tokens, _value)?,
                            );
                        }
                        "dateCreated" => {
                            builder = builder.set_date_created(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "outputResources" => {
                            builder =
                                builder.set_output_resources(crate::protocol_serde::shape_output_resources::de_output_resources(tokens, _value)?);
                        }
                        "tags" => {
                            builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens, _value)?);
                        }
                        "buildType" => {
                            builder = builder.set_build_type(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::BuildType::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "imageSource" => {
                            builder = builder.set_image_source(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::ImageSource::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "scanState" => {
                            builder = builder.set_scan_state(crate::protocol_serde::shape_image_scan_state::de_image_scan_state(tokens, _value)?);
                        }
                        "imageScanningConfiguration" => {
                            builder = builder.set_image_scanning_configuration(
                                crate::protocol_serde::shape_image_scanning_configuration::de_image_scanning_configuration(tokens, _value)?,
                            );
                        }
                        "deprecationTime" => {
                            builder = builder.set_deprecation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
                                tokens.next(),
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
                            )?);
                        }
                        "lifecycleExecutionId" => {
                            builder = builder.set_lifecycle_execution_id(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "executionRole" => {
                            builder = builder.set_execution_role(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "workflows" => {
                            builder = builder.set_workflows(
                                crate::protocol_serde::shape_workflow_configuration_list::de_workflow_configuration_list(tokens, _value)?,
                            );
                        }
                        "loggingConfiguration" => {
                            builder = builder.set_logging_configuration(
                                crate::protocol_serde::shape_image_logging_configuration::de_image_logging_configuration(tokens, _value)?,
                            );
                        }
                        _ => ::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",
        )),
    }
}