aws-sdk-redshift 1.106.0

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

    let _error_message = generic.message().map(|msg| msg.to_owned());
    Err(match error_code {
        "ClusterNotFound" => crate::operation::describe_resize::DescribeResizeError::ClusterNotFoundFault({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::ClusterNotFoundFaultBuilder::default();
                output = crate::protocol_serde::shape_cluster_not_found_fault::de_cluster_not_found_fault_xml_err(_response_body, output)
                    .map_err(crate::operation::describe_resize::DescribeResizeError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "ResizeNotFound" => crate::operation::describe_resize::DescribeResizeError::ResizeNotFoundFault({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::ResizeNotFoundFaultBuilder::default();
                output = crate::protocol_serde::shape_resize_not_found_fault::de_resize_not_found_fault_xml_err(_response_body, output)
                    .map_err(crate::operation::describe_resize::DescribeResizeError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        "UnsupportedOperation" => crate::operation::describe_resize::DescribeResizeError::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::describe_resize::DescribeResizeError::unhandled)?;
                let output = output.meta(generic);
                output.build()
            };
            if tmp.message.is_none() {
                tmp.message = _error_message;
            }
            tmp
        }),
        _ => crate::operation::describe_resize::DescribeResizeError::generic(generic),
    })
}

#[allow(clippy::unnecessary_wraps)]
pub fn de_describe_resize_http_response(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::describe_resize::DescribeResizeOutput, crate::operation::describe_resize::DescribeResizeError> {
    Ok({
        #[allow(unused_mut)]
        let mut output = crate::operation::describe_resize::builders::DescribeResizeOutputBuilder::default();
        output = crate::protocol_serde::shape_describe_resize::de_describe_resize(_response_body, output)
            .map_err(crate::operation::describe_resize::DescribeResizeError::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_describe_resize(
    inp: &[u8],
    mut builder: crate::operation::describe_resize::builders::DescribeResizeOutputBuilder,
) -> std::result::Result<crate::operation::describe_resize::builders::DescribeResizeOutputBuilder, ::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("DescribeResizeResponse")) {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
            "invalid root, expected DescribeResizeResponse got {start_el:?}"
        )));
    }
    if let Some(mut result_tag) = decoder.next_tag() {
        let start_el = result_tag.start_el();
        if !(start_el.matches("DescribeResizeResult")) {
            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
                "invalid result, expected DescribeResizeResult got {start_el:?}"
            )));
        }
        while let Some(mut tag) = result_tag.next_tag() {
            match tag.start_el() {
            s if s.matches("TargetNodeType") /* TargetNodeType com.amazonaws.redshift.synthetic#DescribeResizeOutput$TargetNodeType */ =>  {
                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_target_node_type(var_1);
            }
            ,
            s if s.matches("TargetNumberOfNodes") /* TargetNumberOfNodes com.amazonaws.redshift.synthetic#DescribeResizeOutput$TargetNumberOfNodes */ =>  {
                let var_2 =
                    Some(
                         {
                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.redshift#IntegerOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_target_number_of_nodes(var_2);
            }
            ,
            s if s.matches("TargetClusterType") /* TargetClusterType com.amazonaws.redshift.synthetic#DescribeResizeOutput$TargetClusterType */ =>  {
                let var_3 =
                    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_target_cluster_type(var_3);
            }
            ,
            s if s.matches("Status") /* Status com.amazonaws.redshift.synthetic#DescribeResizeOutput$Status */ =>  {
                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_status(var_4);
            }
            ,
            s if s.matches("ImportTablesCompleted") /* ImportTablesCompleted com.amazonaws.redshift.synthetic#DescribeResizeOutput$ImportTablesCompleted */ =>  {
                let var_5 =
                    Some(
                        crate::protocol_serde::shape_import_tables_completed::de_import_tables_completed(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_import_tables_completed(var_5);
            }
            ,
            s if s.matches("ImportTablesInProgress") /* ImportTablesInProgress com.amazonaws.redshift.synthetic#DescribeResizeOutput$ImportTablesInProgress */ =>  {
                let var_6 =
                    Some(
                        crate::protocol_serde::shape_import_tables_in_progress::de_import_tables_in_progress(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_import_tables_in_progress(var_6);
            }
            ,
            s if s.matches("ImportTablesNotStarted") /* ImportTablesNotStarted com.amazonaws.redshift.synthetic#DescribeResizeOutput$ImportTablesNotStarted */ =>  {
                let var_7 =
                    Some(
                        crate::protocol_serde::shape_import_tables_not_started::de_import_tables_not_started(&mut tag)
                        ?
                    )
                ;
                builder = builder.set_import_tables_not_started(var_7);
            }
            ,
            s if s.matches("AvgResizeRateInMegaBytesPerSecond") /* AvgResizeRateInMegaBytesPerSecond com.amazonaws.redshift.synthetic#DescribeResizeOutput$AvgResizeRateInMegaBytesPerSecond */ =>  {
                let var_8 =
                    Some(
                         {
                            <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (double: `com.amazonaws.redshift#DoubleOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_avg_resize_rate_in_mega_bytes_per_second(var_8);
            }
            ,
            s if s.matches("TotalResizeDataInMegaBytes") /* TotalResizeDataInMegaBytes com.amazonaws.redshift.synthetic#DescribeResizeOutput$TotalResizeDataInMegaBytes */ =>  {
                let var_9 =
                    Some(
                         {
                            <i64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.redshift#LongOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_total_resize_data_in_mega_bytes(var_9);
            }
            ,
            s if s.matches("ProgressInMegaBytes") /* ProgressInMegaBytes com.amazonaws.redshift.synthetic#DescribeResizeOutput$ProgressInMegaBytes */ =>  {
                let var_10 =
                    Some(
                         {
                            <i64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.redshift#LongOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_progress_in_mega_bytes(var_10);
            }
            ,
            s if s.matches("ElapsedTimeInSeconds") /* ElapsedTimeInSeconds com.amazonaws.redshift.synthetic#DescribeResizeOutput$ElapsedTimeInSeconds */ =>  {
                let var_11 =
                    Some(
                         {
                            <i64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.redshift#LongOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_elapsed_time_in_seconds(var_11);
            }
            ,
            s if s.matches("EstimatedTimeToCompletionInSeconds") /* EstimatedTimeToCompletionInSeconds com.amazonaws.redshift.synthetic#DescribeResizeOutput$EstimatedTimeToCompletionInSeconds */ =>  {
                let var_12 =
                    Some(
                         {
                            <i64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.redshift#LongOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_estimated_time_to_completion_in_seconds(var_12);
            }
            ,
            s if s.matches("ResizeType") /* ResizeType com.amazonaws.redshift.synthetic#DescribeResizeOutput$ResizeType */ =>  {
                let var_13 =
                    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_resize_type(var_13);
            }
            ,
            s if s.matches("Message") /* Message com.amazonaws.redshift.synthetic#DescribeResizeOutput$Message */ =>  {
                let var_14 =
                    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_message(var_14);
            }
            ,
            s if s.matches("TargetEncryptionType") /* TargetEncryptionType com.amazonaws.redshift.synthetic#DescribeResizeOutput$TargetEncryptionType */ =>  {
                let var_15 =
                    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_target_encryption_type(var_15);
            }
            ,
            s if s.matches("DataTransferProgressPercent") /* DataTransferProgressPercent com.amazonaws.redshift.synthetic#DescribeResizeOutput$DataTransferProgressPercent */ =>  {
                let var_16 =
                    Some(
                         {
                            <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (double: `com.amazonaws.redshift#DoubleOptional`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_data_transfer_progress_percent(var_16);
            }
            ,
            _ => {}
        }
        }
    } else {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected DescribeResizeResult tag"));
    };
    Ok(builder)
}