aws_sdk_directconnect/protocol_serde/
shape_accept_direct_connect_gateway_association_proposal.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_accept_direct_connect_gateway_association_proposal_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalOutput,
9    crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body).map_err(
13        crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::unhandled,
14    )?;
15    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
16    let generic = generic_builder.build();
17    let error_code =
18        match generic.code() {
19            Some(code) => code,
20            None => return Err(
21                crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::unhandled(
22                    generic,
23                ),
24            ),
25        };
26
27    let _error_message = generic.message().map(|msg| msg.to_owned());
28    Err(match error_code {
29        "DirectConnectClientException" => crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::DirectConnectClientException({
30            #[allow(unused_mut)]
31            let mut tmp =
32                 {
33                    #[allow(unused_mut)]
34                    let mut output = crate::types::error::builders::DirectConnectClientExceptionBuilder::default();
35                    output = crate::protocol_serde::shape_direct_connect_client_exception::de_direct_connect_client_exception_json_err(_response_body, output).map_err(crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::unhandled)?;
36                    let output = output.meta(generic);
37                    output.build()
38                }
39            ;
40            if tmp.message.is_none() {
41                                                            tmp.message = _error_message;
42                                                        }
43            tmp
44        }),
45        "DirectConnectServerException" => crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::DirectConnectServerException({
46            #[allow(unused_mut)]
47            let mut tmp =
48                 {
49                    #[allow(unused_mut)]
50                    let mut output = crate::types::error::builders::DirectConnectServerExceptionBuilder::default();
51                    output = crate::protocol_serde::shape_direct_connect_server_exception::de_direct_connect_server_exception_json_err(_response_body, output).map_err(crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::unhandled)?;
52                    let output = output.meta(generic);
53                    output.build()
54                }
55            ;
56            if tmp.message.is_none() {
57                                                            tmp.message = _error_message;
58                                                        }
59            tmp
60        }),
61        _ => crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::generic(generic)
62    })
63}
64
65#[allow(clippy::unnecessary_wraps)]
66pub fn de_accept_direct_connect_gateway_association_proposal_http_response(
67    _response_status: u16,
68    _response_headers: &::aws_smithy_runtime_api::http::Headers,
69    _response_body: &[u8],
70) -> std::result::Result<
71    crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalOutput,
72    crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError,
73> {
74    Ok({
75        #[allow(unused_mut)]
76        let mut output = crate::operation::accept_direct_connect_gateway_association_proposal::builders::AcceptDirectConnectGatewayAssociationProposalOutputBuilder::default();
77        output =
78            crate::protocol_serde::shape_accept_direct_connect_gateway_association_proposal::de_accept_direct_connect_gateway_association_proposal(
79                _response_body,
80                output,
81            )
82            .map_err(
83                crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalError::unhandled,
84            )?;
85        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
86        output.build()
87    })
88}
89
90pub fn ser_accept_direct_connect_gateway_association_proposal_input(
91    input: &crate::operation::accept_direct_connect_gateway_association_proposal::AcceptDirectConnectGatewayAssociationProposalInput,
92) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
93    let mut out = String::new();
94    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
95    crate::protocol_serde::shape_accept_direct_connect_gateway_association_proposal_input::ser_accept_direct_connect_gateway_association_proposal_input_input(&mut object, input)?;
96    object.finish();
97    Ok(::aws_smithy_types::body::SdkBody::from(out))
98}
99
100pub(crate) fn de_accept_direct_connect_gateway_association_proposal(
101    value: &[u8],
102    mut builder: crate::operation::accept_direct_connect_gateway_association_proposal::builders::AcceptDirectConnectGatewayAssociationProposalOutputBuilder,
103) -> ::std::result::Result<
104    crate::operation::accept_direct_connect_gateway_association_proposal::builders::AcceptDirectConnectGatewayAssociationProposalOutputBuilder,
105    ::aws_smithy_json::deserialize::error::DeserializeError,
106> {
107    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
108    let tokens = &mut tokens_owned;
109    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
110    loop {
111        match tokens.next().transpose()? {
112            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
113            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
114                "directConnectGatewayAssociation" => {
115                    builder = builder.set_direct_connect_gateway_association(
116                        crate::protocol_serde::shape_direct_connect_gateway_association::de_direct_connect_gateway_association(tokens)?,
117                    );
118                }
119                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
120            },
121            other => {
122                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
123                    "expected object key or end object, found: {other:?}"
124                )))
125            }
126        }
127    }
128    if tokens.next().is_some() {
129        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
130            "found more JSON tokens after completing parsing",
131        ));
132    }
133    Ok(builder)
134}