aws-sdk-dataexchange 1.102.0

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

    let _error_message = generic.message().map(|msg| msg.to_owned());
    Err(match error_code {
        "AccessDeniedException" => crate::operation::send_api_asset::SendApiAssetError::AccessDeniedException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?;
                let output = output.meta(generic);
                crate::serde_util::access_denied_exception_correct_errors(output)
                    .build()
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?
            };
            tmp
        }),
        "InternalServerException" => crate::operation::send_api_asset::SendApiAssetError::InternalServerException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?;
                let output = output.meta(generic);
                crate::serde_util::internal_server_exception_correct_errors(output)
                    .build()
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?
            };
            tmp
        }),
        "ResourceNotFoundException" => crate::operation::send_api_asset::SendApiAssetError::ResourceNotFoundException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?;
                let output = output.meta(generic);
                crate::serde_util::resource_not_found_exception_correct_errors(output)
                    .build()
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?
            };
            tmp
        }),
        "ThrottlingException" => crate::operation::send_api_asset::SendApiAssetError::ThrottlingException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?;
                let output = output.meta(generic);
                crate::serde_util::throttling_exception_correct_errors(output)
                    .build()
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?
            };
            tmp
        }),
        "ValidationException" => crate::operation::send_api_asset::SendApiAssetError::ValidationException({
            #[allow(unused_mut)]
            let mut tmp = {
                #[allow(unused_mut)]
                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?;
                let output = output.meta(generic);
                crate::serde_util::validation_exception_correct_errors(output)
                    .build()
                    .map_err(crate::operation::send_api_asset::SendApiAssetError::unhandled)?
            };
            tmp
        }),
        _ => crate::operation::send_api_asset::SendApiAssetError::generic(generic),
    })
}

#[allow(clippy::unnecessary_wraps)]
pub fn de_send_api_asset_http_response(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<crate::operation::send_api_asset::SendApiAssetOutput, crate::operation::send_api_asset::SendApiAssetError> {
    Ok({
        #[allow(unused_mut)]
        let mut output = crate::operation::send_api_asset::builders::SendApiAssetOutputBuilder::default();
        output = output.set_body(crate::protocol_serde::shape_send_api_asset_output::de_body_payload(_response_body)?);
        output = output.set_response_headers(
            crate::protocol_serde::shape_send_api_asset_output::de_response_headers_prefix_header(_response_headers).map_err(|_| {
                crate::operation::send_api_asset::SendApiAssetError::unhandled("Failed to parse ResponseHeaders from prefix header `")
            })?,
        );
        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
        output.build()
    })
}

pub fn ser_send_api_asset_headers(
    input: &crate::operation::send_api_asset::SendApiAssetInput,
    mut builder: ::http_1x::request::Builder,
) -> std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
    if let ::std::option::Option::Some(inner_1) = &input.asset_id {
        let formatted_2 = inner_1.as_str();
        let header_value = formatted_2;
        let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
                "asset_id",
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
            )
        })?;
        builder = builder.header("x-amzn-dataexchange-asset-id", header_value);
    }
    if let ::std::option::Option::Some(inner_3) = &input.data_set_id {
        let formatted_4 = inner_3.as_str();
        let header_value = formatted_4;
        let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
                "data_set_id",
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
            )
        })?;
        builder = builder.header("x-amzn-dataexchange-data-set-id", header_value);
    }
    if let ::std::option::Option::Some(inner_5) = &input.method {
        let formatted_6 = inner_5.as_str();
        let header_value = formatted_6;
        let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
                "method",
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
            )
        })?;
        builder = builder.header("x-amzn-dataexchange-http-method", header_value);
    }
    if let ::std::option::Option::Some(inner_7) = &input.path {
        let formatted_8 = inner_7.as_str();
        let header_value = formatted_8;
        let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
                "path",
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
            )
        })?;
        builder = builder.header("x-amzn-dataexchange-path", header_value);
    }
    if let ::std::option::Option::Some(inner_9) = &input.revision_id {
        let formatted_10 = inner_9.as_str();
        let header_value = formatted_10;
        let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
                "revision_id",
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
            )
        })?;
        builder = builder.header("x-amzn-dataexchange-revision-id", header_value);
    }
    if let ::std::option::Option::Some(inner_11) = &input.request_headers {
        {
            for (k, v) in inner_11 {
                use std::str::FromStr;
                let header_name = ::http_1x::HeaderName::from_str(&format!("{}{}", "x-amzn-dataexchange-header-", &k)).map_err(|err| {
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
                        "request_headers",
                        format!("`{k}` cannot be used as a header name: {err}"),
                    )
                })?;
                let header_value = v.as_str();
                let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
                        "request_headers",
                        format!("`{v}` cannot be used as a header value: {err}"),
                    )
                })?;
                builder = builder.header(header_name, header_value);
            }
        }
    }
    Ok(builder)
}