aws_sdk_apigatewayv2/protocol_serde/
shape_create_integration_response.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_integration_response_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::create_integration_response::CreateIntegrationResponseOutput,
9    crate::operation::create_integration_response::CreateIntegrationResponseError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => {
19            return Err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "BadRequestException" => crate::operation::create_integration_response::CreateIntegrationResponseError::BadRequestException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
32                output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
34                let output = output.meta(generic);
35                output.build()
36            };
37            if tmp.message.is_none() {
38                tmp.message = _error_message;
39            }
40            tmp
41        }),
42        "ConflictException" => crate::operation::create_integration_response::CreateIntegrationResponseError::ConflictException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
47                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        "NotFoundException" => crate::operation::create_integration_response::CreateIntegrationResponseError::NotFoundException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
62                output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
63                    .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
64                let output = output.meta(generic);
65                output.build()
66            };
67            if tmp.message.is_none() {
68                tmp.message = _error_message;
69            }
70            tmp
71        }),
72        "TooManyRequestsException" => crate::operation::create_integration_response::CreateIntegrationResponseError::TooManyRequestsException({
73            #[allow(unused_mut)]
74            let mut tmp = {
75                #[allow(unused_mut)]
76                let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
77                output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
78                    .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
79                let output = output.meta(generic);
80                output.build()
81            };
82            if tmp.message.is_none() {
83                tmp.message = _error_message;
84            }
85            tmp
86        }),
87        _ => crate::operation::create_integration_response::CreateIntegrationResponseError::generic(generic),
88    })
89}
90
91#[allow(clippy::unnecessary_wraps)]
92pub fn de_create_integration_response_http_response(
93    _response_status: u16,
94    _response_headers: &::aws_smithy_runtime_api::http::Headers,
95    _response_body: &[u8],
96) -> std::result::Result<
97    crate::operation::create_integration_response::CreateIntegrationResponseOutput,
98    crate::operation::create_integration_response::CreateIntegrationResponseError,
99> {
100    Ok({
101        #[allow(unused_mut)]
102        let mut output = crate::operation::create_integration_response::builders::CreateIntegrationResponseOutputBuilder::default();
103        output = crate::protocol_serde::shape_create_integration_response::de_create_integration_response(_response_body, output)
104            .map_err(crate::operation::create_integration_response::CreateIntegrationResponseError::unhandled)?;
105        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
106        output.build()
107    })
108}
109
110pub fn ser_create_integration_response_input(
111    input: &crate::operation::create_integration_response::CreateIntegrationResponseInput,
112) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
113    let mut out = String::new();
114    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
115    crate::protocol_serde::shape_create_integration_response_input::ser_create_integration_response_input_input(&mut object, input)?;
116    object.finish();
117    Ok(::aws_smithy_types::body::SdkBody::from(out))
118}
119
120pub(crate) fn de_create_integration_response(
121    value: &[u8],
122    mut builder: crate::operation::create_integration_response::builders::CreateIntegrationResponseOutputBuilder,
123) -> ::std::result::Result<
124    crate::operation::create_integration_response::builders::CreateIntegrationResponseOutputBuilder,
125    ::aws_smithy_json::deserialize::error::DeserializeError,
126> {
127    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
128    let tokens = &mut tokens_owned;
129    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
130    loop {
131        match tokens.next().transpose()? {
132            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
133            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
134                "contentHandlingStrategy" => {
135                    builder = builder.set_content_handling_strategy(
136                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
137                            .map(|s| s.to_unescaped().map(|u| crate::types::ContentHandlingStrategy::from(u.as_ref())))
138                            .transpose()?,
139                    );
140                }
141                "integrationResponseId" => {
142                    builder = builder.set_integration_response_id(
143                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
144                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
145                            .transpose()?,
146                    );
147                }
148                "integrationResponseKey" => {
149                    builder = builder.set_integration_response_key(
150                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
151                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
152                            .transpose()?,
153                    );
154                }
155                "responseParameters" => {
156                    builder =
157                        builder.set_response_parameters(crate::protocol_serde::shape_integration_parameters::de_integration_parameters(tokens)?);
158                }
159                "responseTemplates" => {
160                    builder = builder.set_response_templates(crate::protocol_serde::shape_template_map::de_template_map(tokens)?);
161                }
162                "templateSelectionExpression" => {
163                    builder = builder.set_template_selection_expression(
164                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
165                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
166                            .transpose()?,
167                    );
168                }
169                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
170            },
171            other => {
172                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
173                    "expected object key or end object, found: {:?}",
174                    other
175                )))
176            }
177        }
178    }
179    if tokens.next().is_some() {
180        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
181            "found more JSON tokens after completing parsing",
182        ));
183    }
184    Ok(builder)
185}