pub(crate) fn de_firewall<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::Firewall>, ::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::FirewallBuilder::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() {
"FirewallName" => {
builder = builder.set_firewall_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"FirewallArn" => {
builder = builder.set_firewall_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"FirewallPolicyArn" => {
builder = builder.set_firewall_policy_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.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()?,
);
}
"SubnetMappings" => {
builder = builder.set_subnet_mappings(crate::protocol_serde::shape_subnet_mappings::de_subnet_mappings(tokens, _value)?);
}
"DeleteProtection" => {
builder = builder.set_delete_protection(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"SubnetChangeProtection" => {
builder =
builder.set_subnet_change_protection(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"FirewallPolicyChangeProtection" => {
builder = builder
.set_firewall_policy_change_protection(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"Description" => {
builder = builder.set_description(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"FirewallId" => {
builder = builder.set_firewall_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Tags" => {
builder = builder.set_tags(crate::protocol_serde::shape_tag_list::de_tag_list(tokens, _value)?);
}
"EncryptionConfiguration" => {
builder = builder.set_encryption_configuration(
crate::protocol_serde::shape_encryption_configuration::de_encryption_configuration(tokens, _value)?,
);
}
"NumberOfAssociations" => {
builder = builder.set_number_of_associations(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"EnabledAnalysisTypes" => {
builder = builder.set_enabled_analysis_types(
crate::protocol_serde::shape_enabled_analysis_types::de_enabled_analysis_types(tokens, _value)?,
);
}
"TransitGatewayId" => {
builder = builder.set_transit_gateway_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"TransitGatewayOwnerAccountId" => {
builder = builder.set_transit_gateway_owner_account_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AvailabilityZoneMappings" => {
builder = builder.set_availability_zone_mappings(
crate::protocol_serde::shape_availability_zone_mappings::de_availability_zone_mappings(tokens, _value)?,
);
}
"AvailabilityZoneChangeProtection" => {
builder = builder
.set_availability_zone_change_protection(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
_ => ::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::firewall_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",
)),
}
}