aws_sdk_workdocs/protocol_serde/
shape_update_user.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_user_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::update_user::UpdateUserOutput, crate::operation::update_user::UpdateUserError> {
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::update_user::UpdateUserError::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::update_user::UpdateUserError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "DeactivatingLastSystemUserException" => crate::operation::update_user::UpdateUserError::DeactivatingLastSystemUserException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::DeactivatingLastSystemUserExceptionBuilder::default();
25                output = crate::protocol_serde::shape_deactivating_last_system_user_exception::de_deactivating_last_system_user_exception_json_err(
26                    _response_body,
27                    output,
28                )
29                .map_err(crate::operation::update_user::UpdateUserError::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        "EntityNotExistsException" => crate::operation::update_user::UpdateUserError::EntityNotExistsException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::EntityNotExistsExceptionBuilder::default();
43                output = crate::protocol_serde::shape_entity_not_exists_exception::de_entity_not_exists_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "FailedDependencyException" => crate::operation::update_user::UpdateUserError::FailedDependencyException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::FailedDependencyExceptionBuilder::default();
58                output = crate::protocol_serde::shape_failed_dependency_exception::de_failed_dependency_exception_json_err(_response_body, output)
59                    .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
60                let output = output.meta(generic);
61                output.build()
62            };
63            if tmp.message.is_none() {
64                tmp.message = _error_message;
65            }
66            tmp
67        }),
68        "IllegalUserStateException" => crate::operation::update_user::UpdateUserError::IllegalUserStateException({
69            #[allow(unused_mut)]
70            let mut tmp = {
71                #[allow(unused_mut)]
72                let mut output = crate::types::error::builders::IllegalUserStateExceptionBuilder::default();
73                output = crate::protocol_serde::shape_illegal_user_state_exception::de_illegal_user_state_exception_json_err(_response_body, output)
74                    .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
75                let output = output.meta(generic);
76                output.build()
77            };
78            if tmp.message.is_none() {
79                tmp.message = _error_message;
80            }
81            tmp
82        }),
83        "InvalidArgumentException" => crate::operation::update_user::UpdateUserError::InvalidArgumentException({
84            #[allow(unused_mut)]
85            let mut tmp = {
86                #[allow(unused_mut)]
87                let mut output = crate::types::error::builders::InvalidArgumentExceptionBuilder::default();
88                output = crate::protocol_serde::shape_invalid_argument_exception::de_invalid_argument_exception_json_err(_response_body, output)
89                    .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
90                let output = output.meta(generic);
91                output.build()
92            };
93            if tmp.message.is_none() {
94                tmp.message = _error_message;
95            }
96            tmp
97        }),
98        "ProhibitedStateException" => crate::operation::update_user::UpdateUserError::ProhibitedStateException({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::ProhibitedStateExceptionBuilder::default();
103                output = crate::protocol_serde::shape_prohibited_state_exception::de_prohibited_state_exception_json_err(_response_body, output)
104                    .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
105                let output = output.meta(generic);
106                output.build()
107            };
108            if tmp.message.is_none() {
109                tmp.message = _error_message;
110            }
111            tmp
112        }),
113        "ServiceUnavailableException" => crate::operation::update_user::UpdateUserError::ServiceUnavailableException({
114            #[allow(unused_mut)]
115            let mut tmp = {
116                #[allow(unused_mut)]
117                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
118                output =
119                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
120                        .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
121                let output = output.meta(generic);
122                output.build()
123            };
124            if tmp.message.is_none() {
125                tmp.message = _error_message;
126            }
127            tmp
128        }),
129        "UnauthorizedOperationException" => crate::operation::update_user::UpdateUserError::UnauthorizedOperationException({
130            #[allow(unused_mut)]
131            let mut tmp = {
132                #[allow(unused_mut)]
133                let mut output = crate::types::error::builders::UnauthorizedOperationExceptionBuilder::default();
134                output = crate::protocol_serde::shape_unauthorized_operation_exception::de_unauthorized_operation_exception_json_err(
135                    _response_body,
136                    output,
137                )
138                .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
139                let output = output.meta(generic);
140                output.build()
141            };
142            if tmp.message.is_none() {
143                tmp.message = _error_message;
144            }
145            tmp
146        }),
147        "UnauthorizedResourceAccessException" => crate::operation::update_user::UpdateUserError::UnauthorizedResourceAccessException({
148            #[allow(unused_mut)]
149            let mut tmp = {
150                #[allow(unused_mut)]
151                let mut output = crate::types::error::builders::UnauthorizedResourceAccessExceptionBuilder::default();
152                output = crate::protocol_serde::shape_unauthorized_resource_access_exception::de_unauthorized_resource_access_exception_json_err(
153                    _response_body,
154                    output,
155                )
156                .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
157                let output = output.meta(generic);
158                output.build()
159            };
160            if tmp.message.is_none() {
161                tmp.message = _error_message;
162            }
163            tmp
164        }),
165        _ => crate::operation::update_user::UpdateUserError::generic(generic),
166    })
167}
168
169#[allow(clippy::unnecessary_wraps)]
170pub fn de_update_user_http_response(
171    _response_status: u16,
172    _response_headers: &::aws_smithy_runtime_api::http::Headers,
173    _response_body: &[u8],
174) -> std::result::Result<crate::operation::update_user::UpdateUserOutput, crate::operation::update_user::UpdateUserError> {
175    Ok({
176        #[allow(unused_mut)]
177        let mut output = crate::operation::update_user::builders::UpdateUserOutputBuilder::default();
178        output = crate::protocol_serde::shape_update_user::de_update_user(_response_body, output)
179            .map_err(crate::operation::update_user::UpdateUserError::unhandled)?;
180        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
181        output.build()
182    })
183}
184
185pub fn ser_update_user_headers(
186    input: &crate::operation::update_user::UpdateUserInput,
187    mut builder: ::http::request::Builder,
188) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
189    if let ::std::option::Option::Some(inner_1) = &input.authentication_token {
190        let formatted_2 = inner_1.as_str();
191        let header_value = formatted_2;
192        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
193            ::aws_smithy_types::error::operation::BuildError::invalid_field(
194                "authentication_token",
195                format!("`{}` cannot be used as a header value: {}", &"*** Sensitive Data Redacted ***", err),
196            )
197        })?;
198        builder = builder.header("Authentication", header_value);
199    }
200    Ok(builder)
201}
202
203pub fn ser_update_user_input(
204    input: &crate::operation::update_user::UpdateUserInput,
205) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
206    let mut out = String::new();
207    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
208    crate::protocol_serde::shape_update_user_input::ser_update_user_input_input(&mut object, input)?;
209    object.finish();
210    Ok(::aws_smithy_types::body::SdkBody::from(out))
211}
212
213pub(crate) fn de_update_user(
214    value: &[u8],
215    mut builder: crate::operation::update_user::builders::UpdateUserOutputBuilder,
216) -> ::std::result::Result<crate::operation::update_user::builders::UpdateUserOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
217{
218    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
219    let tokens = &mut tokens_owned;
220    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
221    loop {
222        match tokens.next().transpose()? {
223            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
224            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
225                "User" => {
226                    builder = builder.set_user(crate::protocol_serde::shape_user::de_user(tokens)?);
227                }
228                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
229            },
230            other => {
231                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
232                    "expected object key or end object, found: {:?}",
233                    other
234                )))
235            }
236        }
237    }
238    if tokens.next().is_some() {
239        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
240            "found more JSON tokens after completing parsing",
241        ));
242    }
243    Ok(builder)
244}