aws_sdk_mgn/protocol_serde/
shape_create_launch_configuration_template.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_launch_configuration_template_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateOutput,
9    crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => return Err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => {
24            crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::AccessDeniedException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
30                        .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?;
31                    let output = output.meta(generic);
32                    output.build()
33                };
34                if tmp.message.is_none() {
35                    tmp.message = _error_message;
36                }
37                tmp
38            })
39        }
40        "UninitializedAccountException" => {
41            crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::UninitializedAccountException({
42                #[allow(unused_mut)]
43                let mut tmp = {
44                    #[allow(unused_mut)]
45                    let mut output = crate::types::error::builders::UninitializedAccountExceptionBuilder::default();
46                    output = crate::protocol_serde::shape_uninitialized_account_exception::de_uninitialized_account_exception_json_err(
47                        _response_body,
48                        output,
49                    )
50                    .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?;
51                    let output = output.meta(generic);
52                    output.build()
53                };
54                if tmp.message.is_none() {
55                    tmp.message = _error_message;
56                }
57                tmp
58            })
59        }
60        "ValidationException" => {
61            crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::ValidationException({
62                #[allow(unused_mut)]
63                let mut tmp = {
64                    #[allow(unused_mut)]
65                    let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
66                    output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
67                        .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?;
68                    let output = output.meta(generic);
69                    output.build()
70                };
71                if tmp.message.is_none() {
72                    tmp.message = _error_message;
73                }
74                tmp
75            })
76        }
77        _ => crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::generic(generic),
78    })
79}
80
81#[allow(clippy::unnecessary_wraps)]
82pub fn de_create_launch_configuration_template_http_response(
83    _response_status: u16,
84    _response_headers: &::aws_smithy_runtime_api::http::Headers,
85    _response_body: &[u8],
86) -> std::result::Result<
87    crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateOutput,
88    crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError,
89> {
90    Ok({
91        #[allow(unused_mut)]
92        let mut output = crate::operation::create_launch_configuration_template::builders::CreateLaunchConfigurationTemplateOutputBuilder::default();
93        output = crate::protocol_serde::shape_create_launch_configuration_template::de_create_launch_configuration_template(_response_body, output)
94            .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?;
95        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
96        crate::serde_util::create_launch_configuration_template_output_output_correct_errors(output)
97            .build()
98            .map_err(crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateError::unhandled)?
99    })
100}
101
102pub fn ser_create_launch_configuration_template_input(
103    input: &crate::operation::create_launch_configuration_template::CreateLaunchConfigurationTemplateInput,
104) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
105    let mut out = String::new();
106    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
107    crate::protocol_serde::shape_create_launch_configuration_template_input::ser_create_launch_configuration_template_input_input(
108        &mut object,
109        input,
110    )?;
111    object.finish();
112    Ok(::aws_smithy_types::body::SdkBody::from(out))
113}
114
115pub(crate) fn de_create_launch_configuration_template(
116    value: &[u8],
117    mut builder: crate::operation::create_launch_configuration_template::builders::CreateLaunchConfigurationTemplateOutputBuilder,
118) -> ::std::result::Result<
119    crate::operation::create_launch_configuration_template::builders::CreateLaunchConfigurationTemplateOutputBuilder,
120    ::aws_smithy_json::deserialize::error::DeserializeError,
121> {
122    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
123    let tokens = &mut tokens_owned;
124    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
125    loop {
126        match tokens.next().transpose()? {
127            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
128            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
129                "arn" => {
130                    builder = builder.set_arn(
131                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
132                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
133                            .transpose()?,
134                    );
135                }
136                "associatePublicIpAddress" => {
137                    builder = builder.set_associate_public_ip_address(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
138                }
139                "bootMode" => {
140                    builder = builder.set_boot_mode(
141                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
142                            .map(|s| s.to_unescaped().map(|u| crate::types::BootMode::from(u.as_ref())))
143                            .transpose()?,
144                    );
145                }
146                "copyPrivateIp" => {
147                    builder = builder.set_copy_private_ip(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
148                }
149                "copyTags" => {
150                    builder = builder.set_copy_tags(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
151                }
152                "ec2LaunchTemplateID" => {
153                    builder = builder.set_ec2_launch_template_id(
154                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
155                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
156                            .transpose()?,
157                    );
158                }
159                "enableMapAutoTagging" => {
160                    builder = builder.set_enable_map_auto_tagging(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
161                }
162                "largeVolumeConf" => {
163                    builder = builder.set_large_volume_conf(crate::protocol_serde::shape_launch_template_disk_conf::de_launch_template_disk_conf(
164                        tokens,
165                    )?);
166                }
167                "launchConfigurationTemplateID" => {
168                    builder = builder.set_launch_configuration_template_id(
169                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
170                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
171                            .transpose()?,
172                    );
173                }
174                "launchDisposition" => {
175                    builder = builder.set_launch_disposition(
176                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
177                            .map(|s| s.to_unescaped().map(|u| crate::types::LaunchDisposition::from(u.as_ref())))
178                            .transpose()?,
179                    );
180                }
181                "licensing" => {
182                    builder = builder.set_licensing(crate::protocol_serde::shape_licensing::de_licensing(tokens)?);
183                }
184                "mapAutoTaggingMpeID" => {
185                    builder = builder.set_map_auto_tagging_mpe_id(
186                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
187                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
188                            .transpose()?,
189                    );
190                }
191                "postLaunchActions" => {
192                    builder = builder.set_post_launch_actions(crate::protocol_serde::shape_post_launch_actions::de_post_launch_actions(tokens)?);
193                }
194                "smallVolumeConf" => {
195                    builder = builder.set_small_volume_conf(crate::protocol_serde::shape_launch_template_disk_conf::de_launch_template_disk_conf(
196                        tokens,
197                    )?);
198                }
199                "smallVolumeMaxSize" => {
200                    builder = builder.set_small_volume_max_size(
201                        ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
202                            .map(i64::try_from)
203                            .transpose()?,
204                    );
205                }
206                "tags" => {
207                    builder = builder.set_tags(crate::protocol_serde::shape_tags_map::de_tags_map(tokens)?);
208                }
209                "targetInstanceTypeRightSizingMethod" => {
210                    builder = builder.set_target_instance_type_right_sizing_method(
211                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
212                            .map(|s| {
213                                s.to_unescaped()
214                                    .map(|u| crate::types::TargetInstanceTypeRightSizingMethod::from(u.as_ref()))
215                            })
216                            .transpose()?,
217                    );
218                }
219                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
220            },
221            other => {
222                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
223                    "expected object key or end object, found: {:?}",
224                    other
225                )))
226            }
227        }
228    }
229    if tokens.next().is_some() {
230        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
231            "found more JSON tokens after completing parsing",
232        ));
233    }
234    Ok(builder)
235}