aws-sdk-computeoptimizer 1.102.0

AWS SDK for AWS Compute Optimizer
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_license_recommendation<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::LicenseRecommendation>, ::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::LicenseRecommendationBuilder::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() {
                        "resourceArn" => {
                            builder = builder.set_resource_arn(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "accountId" => {
                            builder = builder.set_account_id(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "currentLicenseConfiguration" => {
                            builder = builder.set_current_license_configuration(
                                crate::protocol_serde::shape_license_configuration::de_license_configuration(tokens, _value)?,
                            );
                        }
                        "lookbackPeriodInDays" => {
                            builder = builder.set_lookback_period_in_days(
                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy()),
                            );
                        }
                        "lastRefreshTimestamp" => {
                            builder = builder.set_last_refresh_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
                                tokens.next(),
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
                            )?);
                        }
                        "finding" => {
                            builder = builder.set_finding(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::LicenseFinding::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "findingReasonCodes" => {
                            builder = builder.set_finding_reason_codes(
                                crate::protocol_serde::shape_license_finding_reason_codes::de_license_finding_reason_codes(tokens, _value)?,
                            );
                        }
                        "licenseRecommendationOptions" => {
                            builder = builder.set_license_recommendation_options(
                                crate::protocol_serde::shape_license_recommendation_options::de_license_recommendation_options(tokens, _value)?,
                            );
                        }
                        "tags" => {
                            builder = builder.set_tags(crate::protocol_serde::shape_tags::de_tags(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",
        )),
    }
}