aws_sdk_datasync/protocol_serde/
shape_describe_location_object_storage.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_location_object_storage_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::describe_location_object_storage::DescribeLocationObjectStorageOutput,
9 crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError,
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::describe_location_object_storage::DescribeLocationObjectStorageError::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::describe_location_object_storage::DescribeLocationObjectStorageError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "InternalException" => crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::InternalException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
28 output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output)
29 .map_err(crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::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 "InvalidRequestException" => {
39 crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::InvalidRequestException({
40 #[allow(unused_mut)]
41 let mut tmp = {
42 #[allow(unused_mut)]
43 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
44 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
45 .map_err(crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::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 _ => crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::generic(generic),
56 })
57}
58
59#[allow(clippy::unnecessary_wraps)]
60pub fn de_describe_location_object_storage_http_response(
61 _response_status: u16,
62 _response_headers: &::aws_smithy_runtime_api::http::Headers,
63 _response_body: &[u8],
64) -> std::result::Result<
65 crate::operation::describe_location_object_storage::DescribeLocationObjectStorageOutput,
66 crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError,
67> {
68 Ok({
69 #[allow(unused_mut)]
70 let mut output = crate::operation::describe_location_object_storage::builders::DescribeLocationObjectStorageOutputBuilder::default();
71 output = crate::protocol_serde::shape_describe_location_object_storage::de_describe_location_object_storage(_response_body, output)
72 .map_err(crate::operation::describe_location_object_storage::DescribeLocationObjectStorageError::unhandled)?;
73 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
74 output.build()
75 })
76}
77
78pub fn ser_describe_location_object_storage_input(
79 input: &crate::operation::describe_location_object_storage::DescribeLocationObjectStorageInput,
80) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
81 let mut out = String::new();
82 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
83 crate::protocol_serde::shape_describe_location_object_storage_input::ser_describe_location_object_storage_input_input(&mut object, input)?;
84 object.finish();
85 Ok(::aws_smithy_types::body::SdkBody::from(out))
86}
87
88pub(crate) fn de_describe_location_object_storage(
89 value: &[u8],
90 mut builder: crate::operation::describe_location_object_storage::builders::DescribeLocationObjectStorageOutputBuilder,
91) -> ::std::result::Result<
92 crate::operation::describe_location_object_storage::builders::DescribeLocationObjectStorageOutputBuilder,
93 ::aws_smithy_json::deserialize::error::DeserializeError,
94> {
95 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
96 let tokens = &mut tokens_owned;
97 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
98 loop {
99 match tokens.next().transpose()? {
100 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
101 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
102 "LocationArn" => {
103 builder = builder.set_location_arn(
104 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
105 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
106 .transpose()?,
107 );
108 }
109 "LocationUri" => {
110 builder = builder.set_location_uri(
111 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
112 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
113 .transpose()?,
114 );
115 }
116 "AccessKey" => {
117 builder = builder.set_access_key(
118 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
119 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
120 .transpose()?,
121 );
122 }
123 "ServerPort" => {
124 builder = builder.set_server_port(
125 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
126 .map(i32::try_from)
127 .transpose()?,
128 );
129 }
130 "ServerProtocol" => {
131 builder = builder.set_server_protocol(
132 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
133 .map(|s| s.to_unescaped().map(|u| crate::types::ObjectStorageServerProtocol::from(u.as_ref())))
134 .transpose()?,
135 );
136 }
137 "AgentArns" => {
138 builder = builder.set_agent_arns(crate::protocol_serde::shape_agent_arn_list::de_agent_arn_list(tokens)?);
139 }
140 "CreationTime" => {
141 builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
142 tokens.next(),
143 ::aws_smithy_types::date_time::Format::EpochSeconds,
144 )?);
145 }
146 "ServerCertificate" => {
147 builder = builder.set_server_certificate(::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?);
148 }
149 "ManagedSecretConfig" => {
150 builder =
151 builder.set_managed_secret_config(crate::protocol_serde::shape_managed_secret_config::de_managed_secret_config(tokens)?);
152 }
153 "CmkSecretConfig" => {
154 builder = builder.set_cmk_secret_config(crate::protocol_serde::shape_cmk_secret_config::de_cmk_secret_config(tokens)?);
155 }
156 "CustomSecretConfig" => {
157 builder = builder.set_custom_secret_config(crate::protocol_serde::shape_custom_secret_config::de_custom_secret_config(tokens)?);
158 }
159 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
160 },
161 other => {
162 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
163 "expected object key or end object, found: {:?}",
164 other
165 )))
166 }
167 }
168 }
169 if tokens.next().is_some() {
170 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
171 "found more JSON tokens after completing parsing",
172 ));
173 }
174 Ok(builder)
175}