#[allow(clippy::unnecessary_wraps)]
pub fn de_purchase_reserved_node_offering_http_error(
_response_status: u16,
_response_headers: &::http::header::HeaderMap,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingOutput,
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError,
> {
#[allow(unused_mut)]
let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
generic_builder = ::aws_http::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::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"ReservedNodeAlreadyExists" => {
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::ReservedNodeAlreadyExistsFault({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ReservedNodeAlreadyExistsFaultBuilder::default();
output = crate::protocol_serde::shape_reserved_node_already_exists_fault::de_reserved_node_already_exists_fault_xml_err(
_response_body,
output,
)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ReservedNodeOfferingNotFound" => {
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::ReservedNodeOfferingNotFoundFault({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ReservedNodeOfferingNotFoundFaultBuilder::default();
output = crate::protocol_serde::shape_reserved_node_offering_not_found_fault::de_reserved_node_offering_not_found_fault_xml_err(
_response_body,
output,
)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ReservedNodeQuotaExceeded" => {
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::ReservedNodeQuotaExceededFault({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ReservedNodeQuotaExceededFaultBuilder::default();
output = crate::protocol_serde::shape_reserved_node_quota_exceeded_fault::de_reserved_node_quota_exceeded_fault_xml_err(
_response_body,
output,
)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"UnsupportedOperation" => crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::UnsupportedOperationFault({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::UnsupportedOperationFaultBuilder::default();
output = crate::protocol_serde::shape_unsupported_operation_fault::de_unsupported_operation_fault_xml_err(_response_body, output)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
_ => crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::generic(generic),
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_purchase_reserved_node_offering_http_response(
_response_status: u16,
_response_headers: &::http::header::HeaderMap,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingOutput,
crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError,
> {
Ok({
#[allow(unused_mut)]
let mut output = crate::operation::purchase_reserved_node_offering::builders::PurchaseReservedNodeOfferingOutputBuilder::default();
output = crate::protocol_serde::shape_purchase_reserved_node_offering::de_purchase_reserved_node_offering(_response_body, output)
.map_err(crate::operation::purchase_reserved_node_offering::PurchaseReservedNodeOfferingError::unhandled)?;
output._set_request_id(::aws_http::request_id::RequestId::request_id(_response_headers).map(str::to_string));
output.build()
})
}
#[allow(unused_mut)]
pub fn de_purchase_reserved_node_offering(
inp: &[u8],
mut builder: crate::operation::purchase_reserved_node_offering::builders::PurchaseReservedNodeOfferingOutputBuilder,
) -> Result<
crate::operation::purchase_reserved_node_offering::builders::PurchaseReservedNodeOfferingOutputBuilder,
::aws_smithy_xml::decode::XmlDecodeError,
> {
let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
#[allow(unused_mut)]
let mut decoder = doc.root_element()?;
#[allow(unused_variables)]
let start_el = decoder.start_el();
if !(start_el.matches("PurchaseReservedNodeOfferingResponse")) {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
"invalid root, expected PurchaseReservedNodeOfferingResponse got {:?}",
start_el
)));
}
if let Some(mut result_tag) = decoder.next_tag() {
let start_el = result_tag.start_el();
if !(start_el.matches("PurchaseReservedNodeOfferingResult")) {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
"invalid result, expected PurchaseReservedNodeOfferingResult got {:?}",
start_el
)));
}
while let Some(mut tag) = result_tag.next_tag() {
match tag.start_el() {
s if s.matches("ReservedNode") => {
let var_1 =
Some(
crate::protocol_serde::shape_reserved_node::de_reserved_node(&mut tag)
?
)
;
builder = builder.set_reserved_node(var_1);
}
,
_ => {}
}
}
} else {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
"expected PurchaseReservedNodeOfferingResult tag",
));
};
Ok(builder)
}