aws_sdk_sagemaker/protocol_serde/
shape_deployment_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_deployment_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::DeploymentConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.rolling_update_policy {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("RollingUpdatePolicy").start_object();
9        crate::protocol_serde::shape_rolling_deployment_policy::ser_rolling_deployment_policy(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.wait_interval_in_seconds {
13        object.key("WaitIntervalInSeconds").number(
14            #[allow(clippy::useless_conversion)]
15            ::aws_smithy_types::Number::NegInt((*var_3).into()),
16        );
17    }
18    if let Some(var_4) = &input.auto_rollback_configuration {
19        let mut array_5 = object.key("AutoRollbackConfiguration").start_array();
20        for item_6 in var_4 {
21            {
22                #[allow(unused_mut)]
23                let mut object_7 = array_5.value().start_object();
24                crate::protocol_serde::shape_alarm_details::ser_alarm_details(&mut object_7, item_6)?;
25                object_7.finish();
26            }
27        }
28        array_5.finish();
29    }
30    Ok(())
31}
32
33pub(crate) fn de_deployment_configuration<'a, I>(
34    tokens: &mut ::std::iter::Peekable<I>,
35) -> ::std::result::Result<Option<crate::types::DeploymentConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
36where
37    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
38{
39    match tokens.next().transpose()? {
40        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
41        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
42            #[allow(unused_mut)]
43            let mut builder = crate::types::builders::DeploymentConfigurationBuilder::default();
44            loop {
45                match tokens.next().transpose()? {
46                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
47                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
48                        "RollingUpdatePolicy" => {
49                            builder = builder.set_rolling_update_policy(
50                                crate::protocol_serde::shape_rolling_deployment_policy::de_rolling_deployment_policy(tokens)?,
51                            );
52                        }
53                        "WaitIntervalInSeconds" => {
54                            builder = builder.set_wait_interval_in_seconds(
55                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
56                                    .map(i32::try_from)
57                                    .transpose()?,
58                            );
59                        }
60                        "AutoRollbackConfiguration" => {
61                            builder = builder
62                                .set_auto_rollback_configuration(crate::protocol_serde::shape_auto_rollback_alarms::de_auto_rollback_alarms(tokens)?);
63                        }
64                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
65                    },
66                    other => {
67                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
68                            "expected object key or end object, found: {:?}",
69                            other
70                        )))
71                    }
72                }
73            }
74            Ok(Some(builder.build()))
75        }
76        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
77            "expected start object or null",
78        )),
79    }
80}