aws_sdk_imagebuilder/protocol_serde/
shape_image.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_image<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::Image>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::ImageBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "arn" => {
18                            builder = builder.set_arn(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "type" => {
25                            builder = builder.set_type(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| crate::types::ImageType::from(u.as_ref())))
28                                    .transpose()?,
29                            );
30                        }
31                        "name" => {
32                            builder = builder.set_name(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "version" => {
39                            builder = builder.set_version(
40                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
41                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
42                                    .transpose()?,
43                            );
44                        }
45                        "platform" => {
46                            builder = builder.set_platform(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| crate::types::Platform::from(u.as_ref())))
49                                    .transpose()?,
50                            );
51                        }
52                        "enhancedImageMetadataEnabled" => {
53                            builder = builder
54                                .set_enhanced_image_metadata_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
55                        }
56                        "osVersion" => {
57                            builder = builder.set_os_version(
58                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60                                    .transpose()?,
61                            );
62                        }
63                        "state" => {
64                            builder = builder.set_state(crate::protocol_serde::shape_image_state::de_image_state(tokens)?);
65                        }
66                        "imageRecipe" => {
67                            builder = builder.set_image_recipe(crate::protocol_serde::shape_image_recipe::de_image_recipe(tokens)?);
68                        }
69                        "containerRecipe" => {
70                            builder = builder.set_container_recipe(crate::protocol_serde::shape_container_recipe::de_container_recipe(tokens)?);
71                        }
72                        "sourcePipelineName" => {
73                            builder = builder.set_source_pipeline_name(
74                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
75                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
76                                    .transpose()?,
77                            );
78                        }
79                        "sourcePipelineArn" => {
80                            builder = builder.set_source_pipeline_arn(
81                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
82                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
83                                    .transpose()?,
84                            );
85                        }
86                        "infrastructureConfiguration" => {
87                            builder = builder.set_infrastructure_configuration(
88                                crate::protocol_serde::shape_infrastructure_configuration::de_infrastructure_configuration(tokens)?,
89                            );
90                        }
91                        "distributionConfiguration" => {
92                            builder = builder.set_distribution_configuration(
93                                crate::protocol_serde::shape_distribution_configuration::de_distribution_configuration(tokens)?,
94                            );
95                        }
96                        "imageTestsConfiguration" => {
97                            builder = builder.set_image_tests_configuration(
98                                crate::protocol_serde::shape_image_tests_configuration::de_image_tests_configuration(tokens)?,
99                            );
100                        }
101                        "dateCreated" => {
102                            builder = builder.set_date_created(
103                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
104                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
105                                    .transpose()?,
106                            );
107                        }
108                        "outputResources" => {
109                            builder = builder.set_output_resources(crate::protocol_serde::shape_output_resources::de_output_resources(tokens)?);
110                        }
111                        "tags" => {
112                            builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
113                        }
114                        "buildType" => {
115                            builder = builder.set_build_type(
116                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
117                                    .map(|s| s.to_unescaped().map(|u| crate::types::BuildType::from(u.as_ref())))
118                                    .transpose()?,
119                            );
120                        }
121                        "imageSource" => {
122                            builder = builder.set_image_source(
123                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
124                                    .map(|s| s.to_unescaped().map(|u| crate::types::ImageSource::from(u.as_ref())))
125                                    .transpose()?,
126                            );
127                        }
128                        "scanState" => {
129                            builder = builder.set_scan_state(crate::protocol_serde::shape_image_scan_state::de_image_scan_state(tokens)?);
130                        }
131                        "imageScanningConfiguration" => {
132                            builder = builder.set_image_scanning_configuration(
133                                crate::protocol_serde::shape_image_scanning_configuration::de_image_scanning_configuration(tokens)?,
134                            );
135                        }
136                        "deprecationTime" => {
137                            builder = builder.set_deprecation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
138                                tokens.next(),
139                                ::aws_smithy_types::date_time::Format::EpochSeconds,
140                            )?);
141                        }
142                        "lifecycleExecutionId" => {
143                            builder = builder.set_lifecycle_execution_id(
144                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
145                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
146                                    .transpose()?,
147                            );
148                        }
149                        "executionRole" => {
150                            builder = builder.set_execution_role(
151                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
152                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
153                                    .transpose()?,
154                            );
155                        }
156                        "workflows" => {
157                            builder = builder.set_workflows(
158                                crate::protocol_serde::shape_workflow_configuration_list::de_workflow_configuration_list(tokens)?,
159                            );
160                        }
161                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
162                    },
163                    other => {
164                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
165                            "expected object key or end object, found: {:?}",
166                            other
167                        )))
168                    }
169                }
170            }
171            Ok(Some(builder.build()))
172        }
173        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
174            "expected start object or null",
175        )),
176    }
177}