aws_sdk_migrationhubrefactorspaces/protocol_serde/
shape_delete_environment.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_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::delete_environment::DeleteEnvironmentOutput, crate::operation::delete_environment::DeleteEnvironmentError>
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::delete_environment::DeleteEnvironmentError::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::delete_environment::DeleteEnvironmentError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "AccessDeniedException" => crate::operation::delete_environment::DeleteEnvironmentError::AccessDeniedException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
26                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
27                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
28                let output = output.meta(generic);
29                crate::serde_util::access_denied_exception_correct_errors(output)
30                    .build()
31                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
32            };
33            tmp
34        }),
35        "ConflictException" => crate::operation::delete_environment::DeleteEnvironmentError::ConflictException({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
40                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
41                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
42                let output = output.meta(generic);
43                crate::serde_util::conflict_exception_correct_errors(output)
44                    .build()
45                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
46            };
47            tmp
48        }),
49        "InternalServerException" => crate::operation::delete_environment::DeleteEnvironmentError::InternalServerException({
50            #[allow(unused_mut)]
51            let mut tmp = {
52                #[allow(unused_mut)]
53                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
54                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
55                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
56                let output = output.meta(generic);
57                crate::serde_util::internal_server_exception_correct_errors(output)
58                    .build()
59                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
60            };
61            tmp
62        }),
63        "ResourceNotFoundException" => crate::operation::delete_environment::DeleteEnvironmentError::ResourceNotFoundException({
64            #[allow(unused_mut)]
65            let mut tmp = {
66                #[allow(unused_mut)]
67                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
68                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
69                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
70                let output = output.meta(generic);
71                crate::serde_util::resource_not_found_exception_correct_errors(output)
72                    .build()
73                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
74            };
75            tmp
76        }),
77        "ThrottlingException" => crate::operation::delete_environment::DeleteEnvironmentError::ThrottlingException({
78            #[allow(unused_mut)]
79            let mut tmp = {
80                #[allow(unused_mut)]
81                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
82                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
83                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
84                output = output.set_retry_after_seconds(
85                    crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
86                        crate::operation::delete_environment::DeleteEnvironmentError::unhandled(
87                            "Failed to parse RetryAfterSeconds from header `Retry-After",
88                        )
89                    })?,
90                );
91                let output = output.meta(generic);
92                crate::serde_util::throttling_exception_correct_errors(output)
93                    .build()
94                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
95            };
96            tmp
97        }),
98        "ValidationException" => crate::operation::delete_environment::DeleteEnvironmentError::ValidationException({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
103                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
104                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
105                let output = output.meta(generic);
106                crate::serde_util::validation_exception_correct_errors(output)
107                    .build()
108                    .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?
109            };
110            tmp
111        }),
112        _ => crate::operation::delete_environment::DeleteEnvironmentError::generic(generic),
113    })
114}
115
116#[allow(clippy::unnecessary_wraps)]
117pub fn de_delete_environment_http_response(
118    _response_status: u16,
119    _response_headers: &::aws_smithy_runtime_api::http::Headers,
120    _response_body: &[u8],
121) -> std::result::Result<crate::operation::delete_environment::DeleteEnvironmentOutput, crate::operation::delete_environment::DeleteEnvironmentError>
122{
123    Ok({
124        #[allow(unused_mut)]
125        let mut output = crate::operation::delete_environment::builders::DeleteEnvironmentOutputBuilder::default();
126        output = crate::protocol_serde::shape_delete_environment::de_delete_environment(_response_body, output)
127            .map_err(crate::operation::delete_environment::DeleteEnvironmentError::unhandled)?;
128        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
129        output.build()
130    })
131}
132
133pub(crate) fn de_delete_environment(
134    value: &[u8],
135    mut builder: crate::operation::delete_environment::builders::DeleteEnvironmentOutputBuilder,
136) -> ::std::result::Result<
137    crate::operation::delete_environment::builders::DeleteEnvironmentOutputBuilder,
138    ::aws_smithy_json::deserialize::error::DeserializeError,
139> {
140    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
141    let tokens = &mut tokens_owned;
142    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
143    loop {
144        match tokens.next().transpose()? {
145            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
146            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
147                "Arn" => {
148                    builder = builder.set_arn(
149                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
150                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
151                            .transpose()?,
152                    );
153                }
154                "EnvironmentId" => {
155                    builder = builder.set_environment_id(
156                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
157                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
158                            .transpose()?,
159                    );
160                }
161                "LastUpdatedTime" => {
162                    builder = builder.set_last_updated_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
163                        tokens.next(),
164                        ::aws_smithy_types::date_time::Format::EpochSeconds,
165                    )?);
166                }
167                "Name" => {
168                    builder = builder.set_name(
169                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
170                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
171                            .transpose()?,
172                    );
173                }
174                "State" => {
175                    builder = builder.set_state(
176                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
177                            .map(|s| s.to_unescaped().map(|u| crate::types::EnvironmentState::from(u.as_ref())))
178                            .transpose()?,
179                    );
180                }
181                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
182            },
183            other => {
184                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
185                    "expected object key or end object, found: {:?}",
186                    other
187                )))
188            }
189        }
190    }
191    if tokens.next().is_some() {
192        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
193            "found more JSON tokens after completing parsing",
194        ));
195    }
196    Ok(builder)
197}