aws-sdk-ssm 1.112.0

AWS SDK for Amazon Simple Systems Manager (SSM)
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_target_location(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::TargetLocation,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.accounts {
        let mut array_2 = object.key("Accounts").start_array();
        for item_3 in var_1 {
            {
                array_2.value().string(item_3.as_str());
            }
        }
        array_2.finish();
    }
    if let Some(var_4) = &input.regions {
        let mut array_5 = object.key("Regions").start_array();
        for item_6 in var_4 {
            {
                array_5.value().string(item_6.as_str());
            }
        }
        array_5.finish();
    }
    if let Some(var_7) = &input.target_location_max_concurrency {
        object.key("TargetLocationMaxConcurrency").string(var_7.as_str());
    }
    if let Some(var_8) = &input.target_location_max_errors {
        object.key("TargetLocationMaxErrors").string(var_8.as_str());
    }
    if let Some(var_9) = &input.execution_role_name {
        object.key("ExecutionRoleName").string(var_9.as_str());
    }
    if let Some(var_10) = &input.target_location_alarm_configuration {
        #[allow(unused_mut)]
        let mut object_11 = object.key("TargetLocationAlarmConfiguration").start_object();
        crate::protocol_serde::shape_alarm_configuration::ser_alarm_configuration(&mut object_11, var_10)?;
        object_11.finish();
    }
    if input.include_child_organization_units {
        object
            .key("IncludeChildOrganizationUnits")
            .boolean(input.include_child_organization_units);
    }
    if let Some(var_12) = &input.exclude_accounts {
        let mut array_13 = object.key("ExcludeAccounts").start_array();
        for item_14 in var_12 {
            {
                array_13.value().string(item_14.as_str());
            }
        }
        array_13.finish();
    }
    if let Some(var_15) = &input.targets {
        let mut array_16 = object.key("Targets").start_array();
        for item_17 in var_15 {
            {
                #[allow(unused_mut)]
                let mut object_18 = array_16.value().start_object();
                crate::protocol_serde::shape_target::ser_target(&mut object_18, item_17)?;
                object_18.finish();
            }
        }
        array_16.finish();
    }
    if let Some(var_19) = &input.targets_max_concurrency {
        object.key("TargetsMaxConcurrency").string(var_19.as_str());
    }
    if let Some(var_20) = &input.targets_max_errors {
        object.key("TargetsMaxErrors").string(var_20.as_str());
    }
    Ok(())
}

pub(crate) fn de_target_location<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
    depth: u32,
) -> ::std::result::Result<Option<crate::types::TargetLocation>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    if depth >= 128u32 {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "maximum nesting depth exceeded",
        ));
    }
    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::TargetLocationBuilder::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() {
                        "Accounts" => {
                            builder = builder.set_accounts(crate::protocol_serde::shape_accounts::de_accounts(tokens, _value, depth + 1)?);
                        }
                        "Regions" => {
                            builder = builder.set_regions(crate::protocol_serde::shape_regions::de_regions(tokens, _value, depth + 1)?);
                        }
                        "TargetLocationMaxConcurrency" => {
                            builder = builder.set_target_location_max_concurrency(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "TargetLocationMaxErrors" => {
                            builder = builder.set_target_location_max_errors(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "ExecutionRoleName" => {
                            builder = builder.set_execution_role_name(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "TargetLocationAlarmConfiguration" => {
                            builder = builder.set_target_location_alarm_configuration(
                                crate::protocol_serde::shape_alarm_configuration::de_alarm_configuration(tokens, _value, depth + 1)?,
                            );
                        }
                        "IncludeChildOrganizationUnits" => {
                            builder = builder
                                .set_include_child_organization_units(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "ExcludeAccounts" => {
                            builder = builder.set_exclude_accounts(crate::protocol_serde::shape_exclude_accounts::de_exclude_accounts(
                                tokens,
                                _value,
                                depth + 1,
                            )?);
                        }
                        "Targets" => {
                            builder = builder.set_targets(crate::protocol_serde::shape_targets::de_targets(tokens, _value, depth + 1)?);
                        }
                        "TargetsMaxConcurrency" => {
                            builder = builder.set_targets_max_concurrency(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "TargetsMaxErrors" => {
                            builder = builder.set_targets_max_errors(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .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(builder.build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}