#[allow(clippy::unnecessary_wraps)]
pub fn de_get_automation_rule_http_error(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<crate::operation::get_automation_rule::GetAutomationRuleOutput, crate::operation::get_automation_rule::GetAutomationRuleError>
{
#[allow(unused_mut)]
let mut generic_builder = crate::cbor_errors::parse_error_metadata(_response_status, _response_headers, _response_body)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
let generic = generic_builder.build();
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"AccessDeniedException" => crate::operation::get_automation_rule::GetAutomationRuleError::AccessDeniedException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"ForbiddenException" => crate::operation::get_automation_rule::GetAutomationRuleError::ForbiddenException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InternalServerException" => crate::operation::get_automation_rule::GetAutomationRuleError::InternalServerException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidParameterValueException" => crate::operation::get_automation_rule::GetAutomationRuleError::InvalidParameterValueException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_cbor_err(
_response_body,
output,
)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"OptInRequiredException" => crate::operation::get_automation_rule::GetAutomationRuleError::OptInRequiredException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::OptInRequiredExceptionBuilder::default();
output = crate::protocol_serde::shape_opt_in_required_exception::de_opt_in_required_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"ResourceNotFoundException" => crate::operation::get_automation_rule::GetAutomationRuleError::ResourceNotFoundException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"ServiceUnavailableException" => crate::operation::get_automation_rule::GetAutomationRuleError::ServiceUnavailableException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
output =
crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"ThrottlingException" => crate::operation::get_automation_rule::GetAutomationRuleError::ThrottlingException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_cbor_err(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
_ => crate::operation::get_automation_rule::GetAutomationRuleError::generic(generic),
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_get_automation_rule_http_response(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<crate::operation::get_automation_rule::GetAutomationRuleOutput, crate::operation::get_automation_rule::GetAutomationRuleError>
{
Ok({
#[allow(unused_mut)]
let mut output = crate::operation::get_automation_rule::builders::GetAutomationRuleOutputBuilder::default();
output = crate::protocol_serde::shape_get_automation_rule::de_get_automation_rule(_response_body, output)
.map_err(crate::operation::get_automation_rule::GetAutomationRuleError::unhandled)?;
output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
output.build()
})
}
pub fn ser_get_automation_rule_input(
input: &crate::operation::get_automation_rule::GetAutomationRuleInput,
) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
let mut encoder = ::aws_smithy_cbor::Encoder::new(Vec::new());
{
let encoder = &mut encoder;
crate::protocol_serde::shape_get_automation_rule_input::ser_get_automation_rule_input_input(encoder, input)?;
}
Ok(::aws_smithy_types::body::SdkBody::from(encoder.into_writer()))
}
pub(crate) fn de_get_automation_rule(
value: &[u8],
mut builder: crate::operation::get_automation_rule::builders::GetAutomationRuleOutputBuilder,
) -> ::std::result::Result<crate::operation::get_automation_rule::builders::GetAutomationRuleOutputBuilder, ::aws_smithy_cbor::decode::DeserializeError>
{
#[allow(clippy::match_single_binding)]
fn pair(
mut builder: crate::operation::get_automation_rule::builders::GetAutomationRuleOutputBuilder,
decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<
crate::operation::get_automation_rule::builders::GetAutomationRuleOutputBuilder,
::aws_smithy_cbor::decode::DeserializeError,
> {
builder = match decoder.str()?.as_ref() {
"ruleArn" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_rule_arn(Some(decoder.string()?))))?
}
"ruleId" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_rule_id(Some(decoder.string()?))))?
}
"name" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_name(Some(decoder.string()?))))?,
"description" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_description(Some(decoder.string()?))))?
}
"ruleType" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_rule_type(Some(decoder.string().map(|s| crate::types::RuleType::from(s.as_ref()))?)))
})?,
"ruleRevision" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_rule_revision(Some(decoder.long()?))))?
}
"accountId" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_account_id(Some(decoder.string()?))))?
}
"organizationConfiguration" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_organization_configuration(Some(
crate::protocol_serde::shape_organization_configuration::de_organization_configuration(decoder)?,
)))
})?,
"priority" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_priority(Some(decoder.string()?))))?
}
"recommendedActionTypes" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_recommended_action_types(Some(
crate::protocol_serde::shape_recommended_action_type_list::de_recommended_action_type_list(decoder)?,
)))
})?,
"criteria" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_criteria(Some(crate::protocol_serde::shape_criteria::de_criteria(decoder)?)))
})?,
"schedule" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_schedule(Some(crate::protocol_serde::shape_schedule::de_schedule(decoder)?)))
})?,
"status" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_status(Some(decoder.string().map(|s| crate::types::RuleStatus::from(s.as_ref()))?)))
})?,
"tags" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_tags(Some(crate::protocol_serde::shape_tag_list::de_tag_list(decoder)?)))
})?,
"createdTimestamp" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_created_timestamp(Some(decoder.timestamp()?)))
})?,
"lastUpdatedTimestamp" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_last_updated_timestamp(Some(decoder.timestamp()?)))
})?,
_ => {
decoder.skip()?;
builder
}
};
Ok(builder)
}
let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
match decoder.map()? {
None => loop {
match decoder.datatype()? {
::aws_smithy_cbor::data::Type::Break => {
decoder.skip()?;
break;
}
_ => {
builder = pair(builder, decoder)?;
}
};
},
Some(n) => {
for _ in 0..n {
builder = pair(builder, decoder)?;
}
}
};
if decoder.position() != value.len() {
return Err(::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()));
}
Ok(builder)
}