aws_sdk_workspacesthinclient/protocol_serde/
shape_get_environment.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_environment_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_environment::GetEnvironmentOutput, crate::operation::get_environment::GetEnvironmentError> {
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_environment::GetEnvironmentError::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_environment::GetEnvironmentError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "AccessDeniedException" => crate::operation::get_environment::GetEnvironmentError::AccessDeniedException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26                    .map_err(crate::operation::get_environment::GetEnvironmentError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        "InternalServerException" => crate::operation::get_environment::GetEnvironmentError::InternalServerException({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
40                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
41                    .map_err(crate::operation::get_environment::GetEnvironmentError::unhandled)?;
42                output = output.set_retry_after_seconds(
43                    crate::protocol_serde::shape_internal_server_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
44                        crate::operation::get_environment::GetEnvironmentError::unhandled(
45                            "Failed to parse retryAfterSeconds from header `Retry-After",
46                        )
47                    })?,
48                );
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        "ResourceNotFoundException" => crate::operation::get_environment::GetEnvironmentError::ResourceNotFoundException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
62                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
63                    .map_err(crate::operation::get_environment::GetEnvironmentError::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        "ThrottlingException" => crate::operation::get_environment::GetEnvironmentError::ThrottlingException({
73            #[allow(unused_mut)]
74            let mut tmp = {
75                #[allow(unused_mut)]
76                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
77                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
78                    .map_err(crate::operation::get_environment::GetEnvironmentError::unhandled)?;
79                output = output.set_retry_after_seconds(
80                    crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
81                        crate::operation::get_environment::GetEnvironmentError::unhandled(
82                            "Failed to parse retryAfterSeconds from header `Retry-After",
83                        )
84                    })?,
85                );
86                let output = output.meta(generic);
87                output.build()
88            };
89            if tmp.message.is_none() {
90                tmp.message = _error_message;
91            }
92            tmp
93        }),
94        "ValidationException" => crate::operation::get_environment::GetEnvironmentError::ValidationException({
95            #[allow(unused_mut)]
96            let mut tmp = {
97                #[allow(unused_mut)]
98                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
99                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
100                    .map_err(crate::operation::get_environment::GetEnvironmentError::unhandled)?;
101                let output = output.meta(generic);
102                output.build()
103            };
104            if tmp.message.is_none() {
105                tmp.message = _error_message;
106            }
107            tmp
108        }),
109        _ => crate::operation::get_environment::GetEnvironmentError::generic(generic),
110    })
111}
112
113#[allow(clippy::unnecessary_wraps)]
114pub fn de_get_environment_http_response(
115    _response_status: u16,
116    _response_headers: &::aws_smithy_runtime_api::http::Headers,
117    _response_body: &[u8],
118) -> std::result::Result<crate::operation::get_environment::GetEnvironmentOutput, crate::operation::get_environment::GetEnvironmentError> {
119    Ok({
120        #[allow(unused_mut)]
121        let mut output = crate::operation::get_environment::builders::GetEnvironmentOutputBuilder::default();
122        output = crate::protocol_serde::shape_get_environment::de_get_environment(_response_body, output)
123            .map_err(crate::operation::get_environment::GetEnvironmentError::unhandled)?;
124        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
125        output.build()
126    })
127}
128
129pub(crate) fn de_get_environment(
130    value: &[u8],
131    mut builder: crate::operation::get_environment::builders::GetEnvironmentOutputBuilder,
132) -> ::std::result::Result<
133    crate::operation::get_environment::builders::GetEnvironmentOutputBuilder,
134    ::aws_smithy_json::deserialize::error::DeserializeError,
135> {
136    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
137    let tokens = &mut tokens_owned;
138    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
139    loop {
140        match tokens.next().transpose()? {
141            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
142            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
143                "environment" => {
144                    builder = builder.set_environment(crate::protocol_serde::shape_environment::de_environment(tokens)?);
145                }
146                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
147            },
148            other => {
149                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
150                    "expected object key or end object, found: {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}