aws-sdk-securityhub 1.109.0

AWS SDK for AWS SecurityHub
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_aws_rds_db_cluster_snapshot_details(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::AwsRdsDbClusterSnapshotDetails,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.availability_zones {
        let mut array_2 = object.key("AvailabilityZones").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.snapshot_create_time {
        object.key("SnapshotCreateTime").string(var_4.as_str());
    }
    if let Some(var_5) = &input.engine {
        object.key("Engine").string(var_5.as_str());
    }
    if let Some(var_6) = &input.allocated_storage {
        object.key("AllocatedStorage").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_6).into()),
        );
    }
    if let Some(var_7) = &input.status {
        object.key("Status").string(var_7.as_str());
    }
    if let Some(var_8) = &input.port {
        object.key("Port").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_8).into()),
        );
    }
    if let Some(var_9) = &input.vpc_id {
        object.key("VpcId").string(var_9.as_str());
    }
    if let Some(var_10) = &input.cluster_create_time {
        object.key("ClusterCreateTime").string(var_10.as_str());
    }
    if let Some(var_11) = &input.master_username {
        object.key("MasterUsername").string(var_11.as_str());
    }
    if let Some(var_12) = &input.engine_version {
        object.key("EngineVersion").string(var_12.as_str());
    }
    if let Some(var_13) = &input.license_model {
        object.key("LicenseModel").string(var_13.as_str());
    }
    if let Some(var_14) = &input.snapshot_type {
        object.key("SnapshotType").string(var_14.as_str());
    }
    if let Some(var_15) = &input.percent_progress {
        object.key("PercentProgress").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_15).into()),
        );
    }
    if let Some(var_16) = &input.storage_encrypted {
        object.key("StorageEncrypted").boolean(*var_16);
    }
    if let Some(var_17) = &input.kms_key_id {
        object.key("KmsKeyId").string(var_17.as_str());
    }
    if let Some(var_18) = &input.db_cluster_identifier {
        object.key("DbClusterIdentifier").string(var_18.as_str());
    }
    if let Some(var_19) = &input.db_cluster_snapshot_identifier {
        object.key("DbClusterSnapshotIdentifier").string(var_19.as_str());
    }
    if let Some(var_20) = &input.iam_database_authentication_enabled {
        object.key("IamDatabaseAuthenticationEnabled").boolean(*var_20);
    }
    if let Some(var_21) = &input.db_cluster_snapshot_attributes {
        let mut array_22 = object.key("DbClusterSnapshotAttributes").start_array();
        for item_23 in var_21 {
            {
                #[allow(unused_mut)]
                let mut object_24 = array_22.value().start_object();
                crate::protocol_serde::shape_aws_rds_db_cluster_snapshot_db_cluster_snapshot_attribute::ser_aws_rds_db_cluster_snapshot_db_cluster_snapshot_attribute(&mut object_24, item_23)?;
                object_24.finish();
            }
        }
        array_22.finish();
    }
    Ok(())
}

pub(crate) fn de_aws_rds_db_cluster_snapshot_details<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::AwsRdsDbClusterSnapshotDetails>, ::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::AwsRdsDbClusterSnapshotDetailsBuilder::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() {
                        "AvailabilityZones" => {
                            builder = builder.set_availability_zones(crate::protocol_serde::shape_string_list::de_string_list(tokens, _value)?);
                        }
                        "SnapshotCreateTime" => {
                            builder = builder.set_snapshot_create_time(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Engine" => {
                            builder = builder.set_engine(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "AllocatedStorage" => {
                            builder = builder.set_allocated_storage(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        "Status" => {
                            builder = builder.set_status(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Port" => {
                            builder = builder.set_port(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        "VpcId" => {
                            builder = builder.set_vpc_id(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "ClusterCreateTime" => {
                            builder = builder.set_cluster_create_time(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "MasterUsername" => {
                            builder = builder.set_master_username(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "EngineVersion" => {
                            builder = builder.set_engine_version(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "LicenseModel" => {
                            builder = builder.set_license_model(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "SnapshotType" => {
                            builder = builder.set_snapshot_type(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "PercentProgress" => {
                            builder = builder.set_percent_progress(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                    .map(i32::try_from)
                                    .transpose()?,
                            );
                        }
                        "StorageEncrypted" => {
                            builder = builder.set_storage_encrypted(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "KmsKeyId" => {
                            builder = builder.set_kms_key_id(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "DbClusterIdentifier" => {
                            builder = builder.set_db_cluster_identifier(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "DbClusterSnapshotIdentifier" => {
                            builder = builder.set_db_cluster_snapshot_identifier(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "IamDatabaseAuthenticationEnabled" => {
                            builder = builder
                                .set_iam_database_authentication_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "DbClusterSnapshotAttributes" => {
                            builder = builder.set_db_cluster_snapshot_attributes(
                                    crate::protocol_serde::shape_aws_rds_db_cluster_snapshot_db_cluster_snapshot_attributes::de_aws_rds_db_cluster_snapshot_db_cluster_snapshot_attributes(tokens, _value)?
                                );
                        }
                        _ => ::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",
        )),
    }
}