#[allow(clippy::unnecessary_wraps)]
pub fn de_get_alarm_mute_rule_http_error(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleOutput, crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError>
{
#[allow(unused_mut)]
let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
.map_err(crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError::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_alarm_mute_rule::GetAlarmMuteRuleError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"ResourceNotFoundException" => crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError::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_alarm_mute_rule::GetAlarmMuteRuleError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
_ => crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError::generic(generic),
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_get_alarm_mute_rule_http_response(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleOutput, crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError>
{
Ok({
#[allow(unused_mut)]
let mut output = crate::operation::get_alarm_mute_rule::builders::GetAlarmMuteRuleOutputBuilder::default();
output = crate::protocol_serde::shape_get_alarm_mute_rule::de_get_alarm_mute_rule(_response_body, output)
.map_err(crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleError::unhandled)?;
output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
output.build()
})
}
pub fn ser_get_alarm_mute_rule_input(
input: &crate::operation::get_alarm_mute_rule::GetAlarmMuteRuleInput,
) -> ::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_alarm_mute_rule_input::ser_get_alarm_mute_rule_input_input(encoder, input)?;
}
Ok(::aws_smithy_types::body::SdkBody::from(encoder.into_writer()))
}
pub(crate) fn de_get_alarm_mute_rule(
value: &[u8],
mut builder: crate::operation::get_alarm_mute_rule::builders::GetAlarmMuteRuleOutputBuilder,
) -> ::std::result::Result<crate::operation::get_alarm_mute_rule::builders::GetAlarmMuteRuleOutputBuilder, ::aws_smithy_cbor::decode::DeserializeError>
{
#[allow(clippy::match_single_binding)]
fn pair(
mut builder: crate::operation::get_alarm_mute_rule::builders::GetAlarmMuteRuleOutputBuilder,
decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<
crate::operation::get_alarm_mute_rule::builders::GetAlarmMuteRuleOutputBuilder,
::aws_smithy_cbor::decode::DeserializeError,
> {
builder = match decoder.str()?.as_ref() {
"Name" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_name(Some(decoder.string()?))))?,
"AlarmMuteRuleArn" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_alarm_mute_rule_arn(Some(decoder.string()?)))
})?,
"Description" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_description(Some(decoder.string()?))))?
}
"Rule" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_rule(Some(crate::protocol_serde::shape_rule::de_rule(decoder)?)))
})?,
"MuteTargets" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_mute_targets(Some(crate::protocol_serde::shape_mute_targets::de_mute_targets(decoder)?)))
})?,
"StartDate" => {
::aws_smithy_cbor::decode::set_optional(
builder,
decoder,
|builder, decoder| Ok(builder.set_start_date(Some(decoder.timestamp()?))),
)?
}
"ExpireDate" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_expire_date(Some(decoder.timestamp()?)))
})?,
"Status" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_status(Some(decoder.string().map(|s| crate::types::AlarmMuteRuleStatus::from(s.as_ref()))?)))
})?,
"LastUpdatedTimestamp" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_last_updated_timestamp(Some(decoder.timestamp()?)))
})?,
"MuteType" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_mute_type(Some(decoder.string()?))))?
}
_ => {
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)
}