1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_target_tracking_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::TargetTrackingConfiguration,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.predefined_scaling_metric_specification {
        #[allow(unused_mut)]
        let mut object_2 = object.key("PredefinedScalingMetricSpecification").start_object();
        crate::protocol_serde::shape_predefined_scaling_metric_specification::ser_predefined_scaling_metric_specification(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.customized_scaling_metric_specification {
        #[allow(unused_mut)]
        let mut object_4 = object.key("CustomizedScalingMetricSpecification").start_object();
        crate::protocol_serde::shape_customized_scaling_metric_specification::ser_customized_scaling_metric_specification(&mut object_4, var_3)?;
        object_4.finish();
    }
    {
        object.key("TargetValue").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::Float((input.target_value).into()),
        );
    }
    if let Some(var_5) = &input.disable_scale_in {
        object.key("DisableScaleIn").boolean(*var_5);
    }
    if let Some(var_6) = &input.scale_out_cooldown {
        object.key("ScaleOutCooldown").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_6).into()),
        );
    }
    if let Some(var_7) = &input.scale_in_cooldown {
        object.key("ScaleInCooldown").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_7).into()),
        );
    }
    if let Some(var_8) = &input.estimated_instance_warmup {
        object.key("EstimatedInstanceWarmup").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_8).into()),
        );
    }
    Ok(())
}

pub(crate) fn de_target_tracking_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::TargetTrackingConfiguration>, ::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::TargetTrackingConfigurationBuilder::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() {
                        "PredefinedScalingMetricSpecification" => {
                            builder = builder.set_predefined_scaling_metric_specification(
                                crate::protocol_serde::shape_predefined_scaling_metric_specification::de_predefined_scaling_metric_specification(
                                    tokens,
                                )?,
                            );
                        }
                        "CustomizedScalingMetricSpecification" => {
                            builder = builder.set_customized_scaling_metric_specification(
                                crate::protocol_serde::shape_customized_scaling_metric_specification::de_customized_scaling_metric_specification(
                                    tokens,
                                )?,
                            );
                        }
                        "TargetValue" => {
                            builder = builder.set_target_value(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy()),
                            );
                        }
                        "DisableScaleIn" => {
                            builder = builder.set_disable_scale_in(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "ScaleOutCooldown" => {
                            builder = builder.set_scale_out_cooldown(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        "ScaleInCooldown" => {
                            builder = builder.set_scale_in_cooldown(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        "EstimatedInstanceWarmup" => {
                            builder = builder.set_estimated_instance_warmup(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        _ => ::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(
                crate::serde_util::target_tracking_configuration_correct_errors(builder)
                    .build()
                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
            ))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}