aws_sdk_codedeploy/protocol_serde/
shape_get_deployment_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_deployment_config_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::get_deployment_config::GetDeploymentConfigOutput,
9    crate::operation::get_deployment_config::GetDeploymentConfigError,
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::get_deployment_config::GetDeploymentConfigError::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 => return Err(crate::operation::get_deployment_config::GetDeploymentConfigError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "DeploymentConfigDoesNotExistException" => {
24            crate::operation::get_deployment_config::GetDeploymentConfigError::DeploymentConfigDoesNotExistException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::DeploymentConfigDoesNotExistExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_deployment_config_does_not_exist_exception::de_deployment_config_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::get_deployment_config::GetDeploymentConfigError::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        }
39        "DeploymentConfigNameRequiredException" => {
40            crate::operation::get_deployment_config::GetDeploymentConfigError::DeploymentConfigNameRequiredException({
41                #[allow(unused_mut)]
42                let mut tmp = {
43                    #[allow(unused_mut)]
44                    let mut output = crate::types::error::builders::DeploymentConfigNameRequiredExceptionBuilder::default();
45                    output = crate::protocol_serde::shape_deployment_config_name_required_exception::de_deployment_config_name_required_exception_json_err(_response_body, output).map_err(crate::operation::get_deployment_config::GetDeploymentConfigError::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        }
55        "InvalidComputePlatformException" => crate::operation::get_deployment_config::GetDeploymentConfigError::InvalidComputePlatformException({
56            #[allow(unused_mut)]
57            let mut tmp = {
58                #[allow(unused_mut)]
59                let mut output = crate::types::error::builders::InvalidComputePlatformExceptionBuilder::default();
60                output = crate::protocol_serde::shape_invalid_compute_platform_exception::de_invalid_compute_platform_exception_json_err(
61                    _response_body,
62                    output,
63                )
64                .map_err(crate::operation::get_deployment_config::GetDeploymentConfigError::unhandled)?;
65                let output = output.meta(generic);
66                output.build()
67            };
68            if tmp.message.is_none() {
69                tmp.message = _error_message;
70            }
71            tmp
72        }),
73        "InvalidDeploymentConfigNameException" => {
74            crate::operation::get_deployment_config::GetDeploymentConfigError::InvalidDeploymentConfigNameException({
75                #[allow(unused_mut)]
76                let mut tmp = {
77                    #[allow(unused_mut)]
78                    let mut output = crate::types::error::builders::InvalidDeploymentConfigNameExceptionBuilder::default();
79                    output =
80                        crate::protocol_serde::shape_invalid_deployment_config_name_exception::de_invalid_deployment_config_name_exception_json_err(
81                            _response_body,
82                            output,
83                        )
84                        .map_err(crate::operation::get_deployment_config::GetDeploymentConfigError::unhandled)?;
85                    let output = output.meta(generic);
86                    output.build()
87                };
88                if tmp.message.is_none() {
89                    tmp.message = _error_message;
90                }
91                tmp
92            })
93        }
94        _ => crate::operation::get_deployment_config::GetDeploymentConfigError::generic(generic),
95    })
96}
97
98#[allow(clippy::unnecessary_wraps)]
99pub fn de_get_deployment_config_http_response(
100    _response_status: u16,
101    _response_headers: &::aws_smithy_runtime_api::http::Headers,
102    _response_body: &[u8],
103) -> std::result::Result<
104    crate::operation::get_deployment_config::GetDeploymentConfigOutput,
105    crate::operation::get_deployment_config::GetDeploymentConfigError,
106> {
107    Ok({
108        #[allow(unused_mut)]
109        let mut output = crate::operation::get_deployment_config::builders::GetDeploymentConfigOutputBuilder::default();
110        output = crate::protocol_serde::shape_get_deployment_config::de_get_deployment_config(_response_body, output)
111            .map_err(crate::operation::get_deployment_config::GetDeploymentConfigError::unhandled)?;
112        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
113        output.build()
114    })
115}
116
117pub fn ser_get_deployment_config_input(
118    input: &crate::operation::get_deployment_config::GetDeploymentConfigInput,
119) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
120    let mut out = String::new();
121    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
122    crate::protocol_serde::shape_get_deployment_config_input::ser_get_deployment_config_input_input(&mut object, input)?;
123    object.finish();
124    Ok(::aws_smithy_types::body::SdkBody::from(out))
125}
126
127pub(crate) fn de_get_deployment_config(
128    value: &[u8],
129    mut builder: crate::operation::get_deployment_config::builders::GetDeploymentConfigOutputBuilder,
130) -> ::std::result::Result<
131    crate::operation::get_deployment_config::builders::GetDeploymentConfigOutputBuilder,
132    ::aws_smithy_json::deserialize::error::DeserializeError,
133> {
134    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
135    let tokens = &mut tokens_owned;
136    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
137    loop {
138        match tokens.next().transpose()? {
139            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
140            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
141                "deploymentConfigInfo" => {
142                    builder =
143                        builder.set_deployment_config_info(crate::protocol_serde::shape_deployment_config_info::de_deployment_config_info(tokens)?);
144                }
145                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
146            },
147            other => {
148                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
149                    "expected object key or end object, found: {:?}",
150                    other
151                )))
152            }
153        }
154    }
155    if tokens.next().is_some() {
156        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
157            "found more JSON tokens after completing parsing",
158        ));
159    }
160    Ok(builder)
161}