pub(crate) fn de_branch<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
depth: u32,
) -> ::std::result::Result<Option<crate::types::Branch>, ::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::BranchBuilder::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() {
"branchArn" => {
builder = builder.set_branch_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"branchName" => {
builder = builder.set_branch_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"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()?,
);
}
"tags" => {
builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens, _value, depth + 1)?);
}
"stage" => {
builder = builder.set_stage(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| crate::types::Stage::from(u.as_ref())))
.transpose()?,
);
}
"displayName" => {
builder = builder.set_display_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"enableNotification" => {
builder = builder.set_enable_notification(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"createTime" => {
builder = builder.set_create_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
tokens.next(),
::aws_smithy_types::date_time::Format::EpochSeconds,
)?);
}
"updateTime" => {
builder = builder.set_update_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
tokens.next(),
::aws_smithy_types::date_time::Format::EpochSeconds,
)?);
}
"environmentVariables" => {
builder = builder.set_environment_variables(
crate::protocol_serde::shape_environment_variables::de_environment_variables(tokens, _value, depth + 1)?,
);
}
"enableAutoBuild" => {
builder = builder.set_enable_auto_build(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"enableSkewProtection" => {
builder = builder.set_enable_skew_protection(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"customDomains" => {
builder = builder.set_custom_domains(crate::protocol_serde::shape_custom_domains::de_custom_domains(
tokens,
_value,
depth + 1,
)?);
}
"framework" => {
builder = builder.set_framework(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"activeJobId" => {
builder = builder.set_active_job_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"totalNumberOfJobs" => {
builder = builder.set_total_number_of_jobs(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"enableBasicAuth" => {
builder = builder.set_enable_basic_auth(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"enablePerformanceMode" => {
builder = builder.set_enable_performance_mode(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"thumbnailUrl" => {
builder = builder.set_thumbnail_url(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"basicAuthCredentials" => {
builder = builder.set_basic_auth_credentials(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"buildSpec" => {
builder = builder.set_build_spec(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ttl" => {
builder = builder.set_ttl(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"associatedResources" => {
builder = builder.set_associated_resources(crate::protocol_serde::shape_associated_resources::de_associated_resources(
tokens,
_value,
depth + 1,
)?);
}
"enablePullRequestPreview" => {
builder =
builder.set_enable_pull_request_preview(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"pullRequestEnvironmentName" => {
builder = builder.set_pull_request_environment_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"destinationBranch" => {
builder = builder.set_destination_branch(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"sourceBranch" => {
builder = builder.set_source_branch(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"backendEnvironmentArn" => {
builder = builder.set_backend_environment_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"backend" => {
builder = builder.set_backend(crate::protocol_serde::shape_backend::de_backend(tokens, _value, depth + 1)?);
}
"computeRoleArn" => {
builder = builder.set_compute_role_arn(
::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(crate::serde_util::branch_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",
)),
}
}