Skip to main content

aws_sdk_directory/protocol_serde/
shape_reject_shared_directory.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_reject_shared_directory_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::reject_shared_directory::RejectSharedDirectoryOutput,
9    crate::operation::reject_shared_directory::RejectSharedDirectoryError,
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::reject_shared_directory::RejectSharedDirectoryError::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::reject_shared_directory::RejectSharedDirectoryError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "ClientException" => crate::operation::reject_shared_directory::RejectSharedDirectoryError::ClientException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::ClientExceptionBuilder::default();
28                output = crate::protocol_serde::shape_client_exception::de_client_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::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        "DirectoryAlreadySharedException" => {
39            crate::operation::reject_shared_directory::RejectSharedDirectoryError::DirectoryAlreadySharedException({
40                #[allow(unused_mut)]
41                let mut tmp = {
42                    #[allow(unused_mut)]
43                    let mut output = crate::types::error::builders::DirectoryAlreadySharedExceptionBuilder::default();
44                    output = crate::protocol_serde::shape_directory_already_shared_exception::de_directory_already_shared_exception_json_err(
45                        _response_body,
46                        output,
47                    )
48                    .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::unhandled)?;
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        }
58        "EntityDoesNotExistException" => crate::operation::reject_shared_directory::RejectSharedDirectoryError::EntityDoesNotExistException({
59            #[allow(unused_mut)]
60            let mut tmp = {
61                #[allow(unused_mut)]
62                let mut output = crate::types::error::builders::EntityDoesNotExistExceptionBuilder::default();
63                output =
64                    crate::protocol_serde::shape_entity_does_not_exist_exception::de_entity_does_not_exist_exception_json_err(_response_body, output)
65                        .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::unhandled)?;
66                let output = output.meta(generic);
67                output.build()
68            };
69            if tmp.message.is_none() {
70                tmp.message = _error_message;
71            }
72            tmp
73        }),
74        "InvalidParameterException" => crate::operation::reject_shared_directory::RejectSharedDirectoryError::InvalidParameterException({
75            #[allow(unused_mut)]
76            let mut tmp = {
77                #[allow(unused_mut)]
78                let mut output = crate::types::error::builders::InvalidParameterExceptionBuilder::default();
79                output = crate::protocol_serde::shape_invalid_parameter_exception::de_invalid_parameter_exception_json_err(_response_body, output)
80                    .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::unhandled)?;
81                let output = output.meta(generic);
82                output.build()
83            };
84            if tmp.message.is_none() {
85                tmp.message = _error_message;
86            }
87            tmp
88        }),
89        "ServiceException" => crate::operation::reject_shared_directory::RejectSharedDirectoryError::ServiceException({
90            #[allow(unused_mut)]
91            let mut tmp = {
92                #[allow(unused_mut)]
93                let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
94                output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
95                    .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::unhandled)?;
96                let output = output.meta(generic);
97                output.build()
98            };
99            if tmp.message.is_none() {
100                tmp.message = _error_message;
101            }
102            tmp
103        }),
104        _ => crate::operation::reject_shared_directory::RejectSharedDirectoryError::generic(generic),
105    })
106}
107
108#[allow(clippy::unnecessary_wraps)]
109pub fn de_reject_shared_directory_http_response(
110    _response_status: u16,
111    _response_headers: &::aws_smithy_runtime_api::http::Headers,
112    _response_body: &[u8],
113) -> std::result::Result<
114    crate::operation::reject_shared_directory::RejectSharedDirectoryOutput,
115    crate::operation::reject_shared_directory::RejectSharedDirectoryError,
116> {
117    Ok({
118        #[allow(unused_mut)]
119        let mut output = crate::operation::reject_shared_directory::builders::RejectSharedDirectoryOutputBuilder::default();
120        output = crate::protocol_serde::shape_reject_shared_directory::de_reject_shared_directory(_response_body, output)
121            .map_err(crate::operation::reject_shared_directory::RejectSharedDirectoryError::unhandled)?;
122        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
123        output.build()
124    })
125}
126
127pub fn ser_reject_shared_directory_input(
128    input: &crate::operation::reject_shared_directory::RejectSharedDirectoryInput,
129) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
130    let mut out = String::new();
131    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
132    crate::protocol_serde::shape_reject_shared_directory_input::ser_reject_shared_directory_input_input(&mut object, input)?;
133    object.finish();
134    Ok(::aws_smithy_types::body::SdkBody::from(out))
135}
136
137pub(crate) fn de_reject_shared_directory(
138    _value: &[u8],
139    mut builder: crate::operation::reject_shared_directory::builders::RejectSharedDirectoryOutputBuilder,
140) -> ::std::result::Result<
141    crate::operation::reject_shared_directory::builders::RejectSharedDirectoryOutputBuilder,
142    ::aws_smithy_json::deserialize::error::DeserializeError,
143> {
144    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
145    let tokens = &mut tokens_owned;
146    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
147    loop {
148        match tokens.next().transpose()? {
149            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
150            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
151                "SharedDirectoryId" => {
152                    builder = builder.set_shared_directory_id(
153                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
154                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
155                            .transpose()?,
156                    );
157                }
158                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
159            },
160            other => {
161                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
162                    "expected object key or end object, found: {other:?}"
163                )))
164            }
165        }
166    }
167    if tokens.next().is_some() {
168        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
169            "found more JSON tokens after completing parsing",
170        ));
171    }
172    Ok(builder)
173}