aws_sdk_codedeploy/protocol_serde/
shape_get_application.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_application_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::get_application::GetApplicationOutput, crate::operation::get_application::GetApplicationError> {
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::get_application::GetApplicationError::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::get_application::GetApplicationError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "ApplicationDoesNotExistException" => crate::operation::get_application::GetApplicationError::ApplicationDoesNotExistException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::ApplicationDoesNotExistExceptionBuilder::default();
25                output = crate::protocol_serde::shape_application_does_not_exist_exception::de_application_does_not_exist_exception_json_err(
26                    _response_body,
27                    output,
28                )
29                .map_err(crate::operation::get_application::GetApplicationError::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        "ApplicationNameRequiredException" => crate::operation::get_application::GetApplicationError::ApplicationNameRequiredException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::ApplicationNameRequiredExceptionBuilder::default();
43                output = crate::protocol_serde::shape_application_name_required_exception::de_application_name_required_exception_json_err(
44                    _response_body,
45                    output,
46                )
47                .map_err(crate::operation::get_application::GetApplicationError::unhandled)?;
48                let output = output.meta(generic);
49                output.build()
50            };
51            if tmp.message.is_none() {
52                tmp.message = _error_message;
53            }
54            tmp
55        }),
56        "InvalidApplicationNameException" => crate::operation::get_application::GetApplicationError::InvalidApplicationNameException({
57            #[allow(unused_mut)]
58            let mut tmp = {
59                #[allow(unused_mut)]
60                let mut output = crate::types::error::builders::InvalidApplicationNameExceptionBuilder::default();
61                output = crate::protocol_serde::shape_invalid_application_name_exception::de_invalid_application_name_exception_json_err(
62                    _response_body,
63                    output,
64                )
65                .map_err(crate::operation::get_application::GetApplicationError::unhandled)?;
66                let output = output.meta(generic);
67                output.build()
68            };
69            if tmp.message.is_none() {
70                tmp.message = _error_message;
71            }
72            tmp
73        }),
74        _ => crate::operation::get_application::GetApplicationError::generic(generic),
75    })
76}
77
78#[allow(clippy::unnecessary_wraps)]
79pub fn de_get_application_http_response(
80    _response_status: u16,
81    _response_headers: &::aws_smithy_runtime_api::http::Headers,
82    _response_body: &[u8],
83) -> std::result::Result<crate::operation::get_application::GetApplicationOutput, crate::operation::get_application::GetApplicationError> {
84    Ok({
85        #[allow(unused_mut)]
86        let mut output = crate::operation::get_application::builders::GetApplicationOutputBuilder::default();
87        output = crate::protocol_serde::shape_get_application::de_get_application(_response_body, output)
88            .map_err(crate::operation::get_application::GetApplicationError::unhandled)?;
89        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
90        output.build()
91    })
92}
93
94pub fn ser_get_application_input(
95    input: &crate::operation::get_application::GetApplicationInput,
96) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
97    let mut out = String::new();
98    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
99    crate::protocol_serde::shape_get_application_input::ser_get_application_input_input(&mut object, input)?;
100    object.finish();
101    Ok(::aws_smithy_types::body::SdkBody::from(out))
102}
103
104pub(crate) fn de_get_application(
105    value: &[u8],
106    mut builder: crate::operation::get_application::builders::GetApplicationOutputBuilder,
107) -> ::std::result::Result<
108    crate::operation::get_application::builders::GetApplicationOutputBuilder,
109    ::aws_smithy_json::deserialize::error::DeserializeError,
110> {
111    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
112    let tokens = &mut tokens_owned;
113    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
114    loop {
115        match tokens.next().transpose()? {
116            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
117            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
118                "application" => {
119                    builder = builder.set_application(crate::protocol_serde::shape_application_info::de_application_info(tokens)?);
120                }
121                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
122            },
123            other => {
124                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
125                    "expected object key or end object, found: {:?}",
126                    other
127                )))
128            }
129        }
130    }
131    if tokens.next().is_some() {
132        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
133            "found more JSON tokens after completing parsing",
134        ));
135    }
136    Ok(builder)
137}