#[allow(clippy::unnecessary_wraps)]
pub fn de_start_speech_synthesis_task_http_error(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskOutput,
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError,
> {
#[allow(unused_mut)]
let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::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::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled(
generic,
))
}
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"EngineNotSupportedException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::EngineNotSupportedException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::EngineNotSupportedExceptionBuilder::default();
output =
crate::protocol_serde::shape_engine_not_supported_exception::de_engine_not_supported_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidS3BucketException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::InvalidS3BucketException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidS3BucketExceptionBuilder::default();
output = crate::protocol_serde::shape_invalid_s3_bucket_exception::de_invalid_s3_bucket_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidS3KeyException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::InvalidS3KeyException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidS3KeyExceptionBuilder::default();
output = crate::protocol_serde::shape_invalid_s3_key_exception::de_invalid_s3_key_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidSampleRateException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::InvalidSampleRateException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidSampleRateExceptionBuilder::default();
output =
crate::protocol_serde::shape_invalid_sample_rate_exception::de_invalid_sample_rate_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidSnsTopicArnException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::InvalidSnsTopicArnException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidSnsTopicArnExceptionBuilder::default();
output =
crate::protocol_serde::shape_invalid_sns_topic_arn_exception::de_invalid_sns_topic_arn_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"InvalidSsmlException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::InvalidSsmlException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::InvalidSsmlExceptionBuilder::default();
output = crate::protocol_serde::shape_invalid_ssml_exception::de_invalid_ssml_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"LanguageNotSupportedException" => {
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::LanguageNotSupportedException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::LanguageNotSupportedExceptionBuilder::default();
output = crate::protocol_serde::shape_language_not_supported_exception::de_language_not_supported_exception_json_err(
_response_body,
output,
)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"LexiconNotFoundException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::LexiconNotFoundException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::LexiconNotFoundExceptionBuilder::default();
output = crate::protocol_serde::shape_lexicon_not_found_exception::de_lexicon_not_found_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"MarksNotSupportedForFormatException" => {
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::MarksNotSupportedForFormatException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::MarksNotSupportedForFormatExceptionBuilder::default();
output =
crate::protocol_serde::shape_marks_not_supported_for_format_exception::de_marks_not_supported_for_format_exception_json_err(
_response_body,
output,
)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"ServiceFailureException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::ServiceFailureException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ServiceFailureExceptionBuilder::default();
output = crate::protocol_serde::shape_service_failure_exception::de_service_failure_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"SsmlMarksNotSupportedForTextTypeException" => {
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::SsmlMarksNotSupportedForTextTypeException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::SsmlMarksNotSupportedForTextTypeExceptionBuilder::default();
output = crate::protocol_serde::shape_ssml_marks_not_supported_for_text_type_exception::de_ssml_marks_not_supported_for_text_type_exception_json_err(_response_body, output).map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
})
}
"TextLengthExceededException" => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::TextLengthExceededException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::types::error::builders::TextLengthExceededExceptionBuilder::default();
output =
crate::protocol_serde::shape_text_length_exceeded_exception::de_text_length_exceeded_exception_json_err(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
let output = output.meta(generic);
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
_ => crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::generic(generic),
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_start_speech_synthesis_task_http_response(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskOutput,
crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError,
> {
Ok({
#[allow(unused_mut)]
let mut output = crate::operation::start_speech_synthesis_task::builders::StartSpeechSynthesisTaskOutputBuilder::default();
output = crate::protocol_serde::shape_start_speech_synthesis_task::de_start_speech_synthesis_task(_response_body, output)
.map_err(crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskError::unhandled)?;
output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
output.build()
})
}
pub fn ser_start_speech_synthesis_task_input(
input: &crate::operation::start_speech_synthesis_task::StartSpeechSynthesisTaskInput,
) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
let mut out = String::new();
let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
crate::protocol_serde::shape_start_speech_synthesis_task_input::ser_start_speech_synthesis_task_input_input(&mut object, input)?;
object.finish();
Ok(::aws_smithy_types::body::SdkBody::from(out))
}
pub(crate) fn de_start_speech_synthesis_task(
_value: &[u8],
mut builder: crate::operation::start_speech_synthesis_task::builders::StartSpeechSynthesisTaskOutputBuilder,
) -> ::std::result::Result<
crate::operation::start_speech_synthesis_task::builders::StartSpeechSynthesisTaskOutputBuilder,
::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;
#[allow(unused_variables)]
let depth = 0u32;
::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() {
"SynthesisTask" => {
builder = builder.set_synthesis_task(crate::protocol_serde::shape_synthesis_task::de_synthesis_task(tokens, _value, depth + 1)?);
}
_ => ::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)
}