aws_sdk_appstream/protocol_serde/
shape_create_application.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_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::create_application::CreateApplicationOutput, crate::operation::create_application::CreateApplicationError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    let error_code = match generic.code() {
15        Some(code) => code,
16        None => return Err(crate::operation::create_application::CreateApplicationError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "ConcurrentModificationException" => crate::operation::create_application::CreateApplicationError::ConcurrentModificationException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
26                output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
27                    _response_body,
28                    output,
29                )
30                .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
31                let output = output.meta(generic);
32                output.build()
33            };
34            if tmp.message.is_none() {
35                tmp.message = _error_message;
36            }
37            tmp
38        }),
39        "LimitExceededException" => crate::operation::create_application::CreateApplicationError::LimitExceededException({
40            #[allow(unused_mut)]
41            let mut tmp = {
42                #[allow(unused_mut)]
43                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
44                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
45                    .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
46                let output = output.meta(generic);
47                output.build()
48            };
49            if tmp.message.is_none() {
50                tmp.message = _error_message;
51            }
52            tmp
53        }),
54        "OperationNotPermittedException" => crate::operation::create_application::CreateApplicationError::OperationNotPermittedException({
55            #[allow(unused_mut)]
56            let mut tmp = {
57                #[allow(unused_mut)]
58                let mut output = crate::types::error::builders::OperationNotPermittedExceptionBuilder::default();
59                output = crate::protocol_serde::shape_operation_not_permitted_exception::de_operation_not_permitted_exception_json_err(
60                    _response_body,
61                    output,
62                )
63                .map_err(crate::operation::create_application::CreateApplicationError::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        "ResourceAlreadyExistsException" => crate::operation::create_application::CreateApplicationError::ResourceAlreadyExistsException({
73            #[allow(unused_mut)]
74            let mut tmp = {
75                #[allow(unused_mut)]
76                let mut output = crate::types::error::builders::ResourceAlreadyExistsExceptionBuilder::default();
77                output = crate::protocol_serde::shape_resource_already_exists_exception::de_resource_already_exists_exception_json_err(
78                    _response_body,
79                    output,
80                )
81                .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
82                let output = output.meta(generic);
83                output.build()
84            };
85            if tmp.message.is_none() {
86                tmp.message = _error_message;
87            }
88            tmp
89        }),
90        "ResourceNotFoundException" => crate::operation::create_application::CreateApplicationError::ResourceNotFoundException({
91            #[allow(unused_mut)]
92            let mut tmp = {
93                #[allow(unused_mut)]
94                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
95                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
96                    .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
97                let output = output.meta(generic);
98                output.build()
99            };
100            if tmp.message.is_none() {
101                tmp.message = _error_message;
102            }
103            tmp
104        }),
105        _ => crate::operation::create_application::CreateApplicationError::generic(generic),
106    })
107}
108
109#[allow(clippy::unnecessary_wraps)]
110pub fn de_create_application_http_response(
111    _response_status: u16,
112    _response_headers: &::aws_smithy_runtime_api::http::Headers,
113    _response_body: &[u8],
114) -> std::result::Result<crate::operation::create_application::CreateApplicationOutput, crate::operation::create_application::CreateApplicationError>
115{
116    Ok({
117        #[allow(unused_mut)]
118        let mut output = crate::operation::create_application::builders::CreateApplicationOutputBuilder::default();
119        output = crate::protocol_serde::shape_create_application::de_create_application(_response_body, output)
120            .map_err(crate::operation::create_application::CreateApplicationError::unhandled)?;
121        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
122        output.build()
123    })
124}
125
126pub fn ser_create_application_input(
127    input: &crate::operation::create_application::CreateApplicationInput,
128) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
129    let mut out = String::new();
130    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
131    crate::protocol_serde::shape_create_application_input::ser_create_application_input_input(&mut object, input)?;
132    object.finish();
133    Ok(::aws_smithy_types::body::SdkBody::from(out))
134}
135
136pub(crate) fn de_create_application(
137    value: &[u8],
138    mut builder: crate::operation::create_application::builders::CreateApplicationOutputBuilder,
139) -> ::std::result::Result<
140    crate::operation::create_application::builders::CreateApplicationOutputBuilder,
141    ::aws_smithy_json::deserialize::error::DeserializeError,
142> {
143    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
144    let tokens = &mut tokens_owned;
145    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
146    loop {
147        match tokens.next().transpose()? {
148            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
149            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
150                "Application" => {
151                    builder = builder.set_application(crate::protocol_serde::shape_application::de_application(tokens)?);
152                }
153                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
154            },
155            other => {
156                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
157                    "expected object key or end object, found: {:?}",
158                    other
159                )))
160            }
161        }
162    }
163    if tokens.next().is_some() {
164        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
165            "found more JSON tokens after completing parsing",
166        ));
167    }
168    Ok(builder)
169}