aws_sdk_apprunner/protocol_serde/
shape_create_service.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_service_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::create_service::CreateServiceOutput, crate::operation::create_service::CreateServiceError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::create_service::CreateServiceError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::create_service::CreateServiceError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "InternalServiceErrorException" => crate::operation::create_service::CreateServiceError::InternalServiceErrorException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::InternalServiceErrorExceptionBuilder::default();
25                output = crate::protocol_serde::shape_internal_service_error_exception::de_internal_service_error_exception_json_err(
26                    _response_body,
27                    output,
28                )
29                .map_err(crate::operation::create_service::CreateServiceError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "InvalidRequestException" => crate::operation::create_service::CreateServiceError::InvalidRequestException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
43                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::create_service::CreateServiceError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "ServiceQuotaExceededException" => crate::operation::create_service::CreateServiceError::ServiceQuotaExceededException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
58                output = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
59                    _response_body,
60                    output,
61                )
62                .map_err(crate::operation::create_service::CreateServiceError::unhandled)?;
63                let output = output.meta(generic);
64                output.build()
65            };
66            if tmp.message.is_none() {
67                tmp.message = _error_message;
68            }
69            tmp
70        }),
71        _ => crate::operation::create_service::CreateServiceError::generic(generic),
72    })
73}
74
75#[allow(clippy::unnecessary_wraps)]
76pub fn de_create_service_http_response(
77    _response_status: u16,
78    _response_headers: &::aws_smithy_runtime_api::http::Headers,
79    _response_body: &[u8],
80) -> std::result::Result<crate::operation::create_service::CreateServiceOutput, crate::operation::create_service::CreateServiceError> {
81    Ok({
82        #[allow(unused_mut)]
83        let mut output = crate::operation::create_service::builders::CreateServiceOutputBuilder::default();
84        output = crate::protocol_serde::shape_create_service::de_create_service(_response_body, output)
85            .map_err(crate::operation::create_service::CreateServiceError::unhandled)?;
86        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
87        crate::serde_util::create_service_output_output_correct_errors(output)
88            .build()
89            .map_err(crate::operation::create_service::CreateServiceError::unhandled)?
90    })
91}
92
93pub fn ser_create_service_input(
94    input: &crate::operation::create_service::CreateServiceInput,
95) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
96    let mut out = String::new();
97    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
98    crate::protocol_serde::shape_create_service_input::ser_create_service_input_input(&mut object, input)?;
99    object.finish();
100    Ok(::aws_smithy_types::body::SdkBody::from(out))
101}
102
103pub(crate) fn de_create_service(
104    value: &[u8],
105    mut builder: crate::operation::create_service::builders::CreateServiceOutputBuilder,
106) -> ::std::result::Result<
107    crate::operation::create_service::builders::CreateServiceOutputBuilder,
108    ::aws_smithy_json::deserialize::error::DeserializeError,
109> {
110    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
111    let tokens = &mut tokens_owned;
112    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
113    loop {
114        match tokens.next().transpose()? {
115            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
116            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
117                "Service" => {
118                    builder = builder.set_service(crate::protocol_serde::shape_service::de_service(tokens)?);
119                }
120                "OperationId" => {
121                    builder = builder.set_operation_id(
122                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
123                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
124                            .transpose()?,
125                    );
126                }
127                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
128            },
129            other => {
130                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
131                    "expected object key or end object, found: {:?}",
132                    other
133                )))
134            }
135        }
136    }
137    if tokens.next().is_some() {
138        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
139            "found more JSON tokens after completing parsing",
140        ));
141    }
142    Ok(builder)
143}