#[allow(clippy::unnecessary_wraps)]
pub fn de_get_geofence_http_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<
crate::operation::get_geofence::GetGeofenceOutput,
crate::operation::get_geofence::GetGeofenceError,
> {
#[allow(unused_mut)]
let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(response)
.map_err(crate::operation::get_geofence::GetGeofenceError::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::get_geofence::GetGeofenceError::unhandled(
generic,
))
}
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"AccessDeniedException" => {
crate::operation::get_geofence::GetGeofenceError::AccessDeniedException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::types::error::builders::AccessDeniedExceptionBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(response.body().as_ref(), output).map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"InternalServerException" => {
crate::operation::get_geofence::GetGeofenceError::InternalServerException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::types::error::builders::InternalServerExceptionBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(response.body().as_ref(), output).map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ResourceNotFoundException" => {
crate::operation::get_geofence::GetGeofenceError::ResourceNotFoundException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(response.body().as_ref(), output).map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ThrottlingException" => {
crate::operation::get_geofence::GetGeofenceError::ThrottlingException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::types::error::builders::ThrottlingExceptionBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(response.body().as_ref(), output).map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ValidationException" => {
crate::operation::get_geofence::GetGeofenceError::ValidationException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::types::error::builders::ValidationExceptionBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(response.body().as_ref(), output).map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
_ => crate::operation::get_geofence::GetGeofenceError::generic(generic),
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_get_geofence_http_response(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<
crate::operation::get_geofence::GetGeofenceOutput,
crate::operation::get_geofence::GetGeofenceError,
> {
Ok({
#[allow(unused_mut)]
let mut output =
crate::operation::get_geofence::builders::GetGeofenceOutputBuilder::default();
let _ = response;
output = crate::protocol_serde::shape_get_geofence::de_get_geofence(
response.body().as_ref(),
output,
)
.map_err(crate::operation::get_geofence::GetGeofenceError::unhandled)?;
output._set_request_id(
aws_http::request_id::RequestId::request_id(response).map(str::to_string),
);
output.build()
})
}
pub(crate) fn de_get_geofence(
value: &[u8],
mut builder: crate::operation::get_geofence::builders::GetGeofenceOutputBuilder,
) -> Result<
crate::operation::get_geofence::builders::GetGeofenceOutputBuilder,
aws_smithy_json::deserialize::error::DeserializeError,
> {
let mut tokens_owned =
aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
.peekable();
let tokens = &mut tokens_owned;
aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
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() {
"CreateTime" => {
builder = builder.set_create_time(
aws_smithy_json::deserialize::token::expect_timestamp_or_null(
tokens.next(),
aws_smithy_types::date_time::Format::DateTimeWithOffset,
)?,
);
}
"GeofenceId" => {
builder = builder.set_geofence_id(
aws_smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Geometry" => {
builder = builder.set_geometry(
crate::protocol_serde::shape_geofence_geometry::de_geofence_geometry(
tokens,
)?,
);
}
"Status" => {
builder = builder.set_status(
aws_smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"UpdateTime" => {
builder = builder.set_update_time(
aws_smithy_json::deserialize::token::expect_timestamp_or_null(
tokens.next(),
aws_smithy_types::date_time::Format::DateTimeWithOffset,
)?,
);
}
_ => 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
)),
)
}
}
}
if tokens.next().is_some() {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(
"found more JSON tokens after completing parsing",
),
);
}
Ok(builder)
}