aws-sdk-cloudformation 1.111.0

AWS SDK for AWS CloudFormation
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::unnecessary_wraps)]
pub fn de_get_hook_result_http_error(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::get_hook_result::GetHookResultOutput, crate::operation::get_hook_result::GetHookResultError> {
    #[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_hook_result::GetHookResultError::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_hook_result::GetHookResultError::unhandled(generic)),
    };

    let _error_message = generic.message().map(|msg| msg.to_owned());
    Err(match error_code {
        "HookResultNotFound" => crate::operation::get_hook_result::GetHookResultError::HookResultNotFoundException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::HookResultNotFoundExceptionBuilder::default();
                output =
                    crate::protocol_serde::shape_hook_result_not_found_exception::de_hook_result_not_found_exception_xml_err(_response_body, output)
                        .map_err(crate::operation::get_hook_result::GetHookResultError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        _ => crate::operation::get_hook_result::GetHookResultError::generic(generic),
    })
}

#[allow(clippy::unnecessary_wraps)]
pub fn de_get_hook_result_http_response(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::get_hook_result::GetHookResultOutput, crate::operation::get_hook_result::GetHookResultError> {
    Ok({
        #[allow(unused_mut)]
        let mut output = crate::operation::get_hook_result::builders::GetHookResultOutputBuilder::default();
        output = crate::protocol_serde::shape_get_hook_result::de_get_hook_result(_response_body, output)
            .map_err(crate::operation::get_hook_result::GetHookResultError::unhandled)?;
        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
        output.build()
    })
}

#[allow(unused_mut)]
pub fn de_get_hook_result(
    inp: &[u8],
    mut builder: crate::operation::get_hook_result::builders::GetHookResultOutputBuilder,
) -> std::result::Result<crate::operation::get_hook_result::builders::GetHookResultOutputBuilder, ::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("GetHookResultResponse")) {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
            "invalid root, expected GetHookResultResponse got {start_el:?}"
        )));
    }
    if let Some(mut result_tag) = decoder.next_tag() {
        let start_el = result_tag.start_el();
        if !(start_el.matches("GetHookResultResult")) {
            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
                "invalid result, expected GetHookResultResult got {start_el:?}"
            )));
        }
        while let Some(mut tag) = result_tag.next_tag() {
            match tag.start_el() {
            s if s.matches("HookResultId") /* HookResultId com.amazonaws.cloudformation.synthetic#GetHookResultOutput$HookResultId */ =>  {
                let var_1 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_hook_result_id(var_1);
            }
            ,
            s if s.matches("InvocationPoint") /* InvocationPoint com.amazonaws.cloudformation.synthetic#GetHookResultOutput$InvocationPoint */ =>  {
                let var_2 =
                    Some(
                        Result::<crate::types::HookInvocationPoint, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::HookInvocationPoint::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_invocation_point(var_2);
            }
            ,
            s if s.matches("FailureMode") /* FailureMode com.amazonaws.cloudformation.synthetic#GetHookResultOutput$FailureMode */ =>  {
                let var_3 =
                    Some(
                        Result::<crate::types::HookFailureMode, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::HookFailureMode::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_failure_mode(var_3);
            }
            ,
            s if s.matches("TypeName") /* TypeName com.amazonaws.cloudformation.synthetic#GetHookResultOutput$TypeName */ =>  {
                let var_4 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_type_name(var_4);
            }
            ,
            s if s.matches("OriginalTypeName") /* OriginalTypeName com.amazonaws.cloudformation.synthetic#GetHookResultOutput$OriginalTypeName */ =>  {
                let var_5 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_original_type_name(var_5);
            }
            ,
            s if s.matches("TypeVersionId") /* TypeVersionId com.amazonaws.cloudformation.synthetic#GetHookResultOutput$TypeVersionId */ =>  {
                let var_6 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_type_version_id(var_6);
            }
            ,
            s if s.matches("TypeConfigurationVersionId") /* TypeConfigurationVersionId com.amazonaws.cloudformation.synthetic#GetHookResultOutput$TypeConfigurationVersionId */ =>  {
                let var_7 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_type_configuration_version_id(var_7);
            }
            ,
            s if s.matches("TypeArn") /* TypeArn com.amazonaws.cloudformation.synthetic#GetHookResultOutput$TypeArn */ =>  {
                let var_8 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_type_arn(var_8);
            }
            ,
            s if s.matches("Status") /* Status com.amazonaws.cloudformation.synthetic#GetHookResultOutput$Status */ =>  {
                let var_9 =
                    Some(
                        Result::<crate::types::HookStatus, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::HookStatus::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_status(var_9);
            }
            ,
            s if s.matches("HookStatusReason") /* HookStatusReason com.amazonaws.cloudformation.synthetic#GetHookResultOutput$HookStatusReason */ =>  {
                let var_10 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_hook_status_reason(var_10);
            }
            ,
            s if s.matches("InvokedAt") /* InvokedAt com.amazonaws.cloudformation.synthetic#GetHookResultOutput$InvokedAt */ =>  {
                let var_11 =
                    Some(
                        ::aws_smithy_types::DateTime::from_str(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
                        )
                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.cloudformation#Timestamp`)"))
                        ?
                    )
                ;
                builder = builder.set_invoked_at(var_11);
            }
            ,
            s if s.matches("Target") /* Target com.amazonaws.cloudformation.synthetic#GetHookResultOutput$Target */ =>  {
                let var_12 =
                    Some(
                        crate::protocol_serde::shape_hook_target::de_hook_target(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_target(var_12);
            }
            ,
            s if s.matches("Annotations") /* Annotations com.amazonaws.cloudformation.synthetic#GetHookResultOutput$Annotations */ =>  {
                let var_13 =
                    Some(
                        crate::protocol_serde::shape_annotation_list::de_annotation_list(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_annotations(var_13);
            }
            ,
            _ => {}
        }
        }
    } else {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected GetHookResultResult tag"));
    };
    Ok(builder)
}