// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::unnecessary_wraps)]
pub fn de_put_lexicon_http_error(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::put_lexicon::PutLexiconOutput, crate::operation::put_lexicon::PutLexiconError> {
    #[allow(unused_mut)]
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
        .map_err(crate::operation::put_lexicon::PutLexiconError::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::put_lexicon::PutLexiconError::unhandled(generic)),
    };

    let _error_message = generic.message().map(|msg| msg.to_owned());
    Err(match error_code {
        "InvalidLexiconException" => crate::operation::put_lexicon::PutLexiconError::InvalidLexiconException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::InvalidLexiconExceptionBuilder::default();
                output = crate::protocol_serde::shape_invalid_lexicon_exception::de_invalid_lexicon_exception_json_err(_response_body, output)
                    .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "LexiconSizeExceededException" => crate::operation::put_lexicon::PutLexiconError::LexiconSizeExceededException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::LexiconSizeExceededExceptionBuilder::default();
                output =
                    crate::protocol_serde::shape_lexicon_size_exceeded_exception::de_lexicon_size_exceeded_exception_json_err(_response_body, output)
                        .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "MaxLexemeLengthExceededException" => crate::operation::put_lexicon::PutLexiconError::MaxLexemeLengthExceededException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::MaxLexemeLengthExceededExceptionBuilder::default();
                output = crate::protocol_serde::shape_max_lexeme_length_exceeded_exception::de_max_lexeme_length_exceeded_exception_json_err(
                    _response_body,
                    output,
                )
                .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "MaxLexiconsNumberExceededException" => crate::operation::put_lexicon::PutLexiconError::MaxLexiconsNumberExceededException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::MaxLexiconsNumberExceededExceptionBuilder::default();
                output = crate::protocol_serde::shape_max_lexicons_number_exceeded_exception::de_max_lexicons_number_exceeded_exception_json_err(
                    _response_body,
                    output,
                )
                .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "ServiceFailureException" => crate::operation::put_lexicon::PutLexiconError::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::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "UnsupportedPlsAlphabetException" => crate::operation::put_lexicon::PutLexiconError::UnsupportedPlsAlphabetException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::UnsupportedPlsAlphabetExceptionBuilder::default();
                output = crate::protocol_serde::shape_unsupported_pls_alphabet_exception::de_unsupported_pls_alphabet_exception_json_err(
                    _response_body,
                    output,
                )
                .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "UnsupportedPlsLanguageException" => crate::operation::put_lexicon::PutLexiconError::UnsupportedPlsLanguageException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::UnsupportedPlsLanguageExceptionBuilder::default();
                output = crate::protocol_serde::shape_unsupported_pls_language_exception::de_unsupported_pls_language_exception_json_err(
                    _response_body,
                    output,
                )
                .map_err(crate::operation::put_lexicon::PutLexiconError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        _ => crate::operation::put_lexicon::PutLexiconError::generic(generic),
    })
}

#[allow(clippy::unnecessary_wraps)]
pub fn de_put_lexicon_http_response(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::put_lexicon::PutLexiconOutput, crate::operation::put_lexicon::PutLexiconError> {
    Ok({
        #[allow(unused_mut)]
        let mut output = crate::operation::put_lexicon::builders::PutLexiconOutputBuilder::default();
        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
        output.build()
    })
}

pub fn ser_put_lexicon_input(
    input: &crate::operation::put_lexicon::PutLexiconInput,
) -> ::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_put_lexicon_input::ser_put_lexicon_input_input(&mut object, input)?;
    object.finish();
    Ok(::aws_smithy_types::body::SdkBody::from(out))
}
