aws_sdk_elasticsearch/protocol_serde/
shape_start_elasticsearch_service_software_update.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_start_elasticsearch_service_software_update_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::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateOutput,
9 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError,
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::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::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 => {
19 return Err(
20 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled(generic),
21 )
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "BaseException" => {
28 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::BaseException({
29 #[allow(unused_mut)]
30 let mut tmp = {
31 #[allow(unused_mut)]
32 let mut output = crate::types::error::builders::BaseExceptionBuilder::default();
33 output = crate::protocol_serde::shape_base_exception::de_base_exception_json_err(_response_body, output).map_err(
34 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled,
35 )?;
36 let output = output.meta(generic);
37 output.build()
38 };
39 if tmp.message.is_none() {
40 tmp.message = _error_message;
41 }
42 tmp
43 })
44 }
45 "InternalException" => {
46 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::InternalException({
47 #[allow(unused_mut)]
48 let mut tmp = {
49 #[allow(unused_mut)]
50 let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
51 output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output).map_err(
52 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled,
53 )?;
54 let output = output.meta(generic);
55 output.build()
56 };
57 if tmp.message.is_none() {
58 tmp.message = _error_message;
59 }
60 tmp
61 })
62 }
63 "ResourceNotFoundException" => {
64 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::ResourceNotFoundException({
65 #[allow(unused_mut)]
66 let mut tmp = {
67 #[allow(unused_mut)]
68 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
69 output =
70 crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
71 .map_err(
72 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled,
73 )?;
74 let output = output.meta(generic);
75 output.build()
76 };
77 if tmp.message.is_none() {
78 tmp.message = _error_message;
79 }
80 tmp
81 })
82 }
83 "ValidationException" => {
84 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::ValidationException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
89 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output).map_err(
90 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled,
91 )?;
92 let output = output.meta(generic);
93 output.build()
94 };
95 if tmp.message.is_none() {
96 tmp.message = _error_message;
97 }
98 tmp
99 })
100 }
101 _ => crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::generic(generic),
102 })
103}
104
105#[allow(clippy::unnecessary_wraps)]
106pub fn de_start_elasticsearch_service_software_update_http_response(
107 _response_status: u16,
108 _response_headers: &::aws_smithy_runtime_api::http::Headers,
109 _response_body: &[u8],
110) -> std::result::Result<
111 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateOutput,
112 crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError,
113> {
114 Ok({
115 #[allow(unused_mut)]
116 let mut output =
117 crate::operation::start_elasticsearch_service_software_update::builders::StartElasticsearchServiceSoftwareUpdateOutputBuilder::default();
118 output = crate::protocol_serde::shape_start_elasticsearch_service_software_update::de_start_elasticsearch_service_software_update(
119 _response_body,
120 output,
121 )
122 .map_err(crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateError::unhandled)?;
123 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
124 output.build()
125 })
126}
127
128pub fn ser_start_elasticsearch_service_software_update_input(
129 input: &crate::operation::start_elasticsearch_service_software_update::StartElasticsearchServiceSoftwareUpdateInput,
130) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
131 let mut out = String::new();
132 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
133 crate::protocol_serde::shape_start_elasticsearch_service_software_update_input::ser_start_elasticsearch_service_software_update_input_input(
134 &mut object,
135 input,
136 )?;
137 object.finish();
138 Ok(::aws_smithy_types::body::SdkBody::from(out))
139}
140
141pub(crate) fn de_start_elasticsearch_service_software_update(
142 value: &[u8],
143 mut builder: crate::operation::start_elasticsearch_service_software_update::builders::StartElasticsearchServiceSoftwareUpdateOutputBuilder,
144) -> ::std::result::Result<
145 crate::operation::start_elasticsearch_service_software_update::builders::StartElasticsearchServiceSoftwareUpdateOutputBuilder,
146 ::aws_smithy_json::deserialize::error::DeserializeError,
147> {
148 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
149 let tokens = &mut tokens_owned;
150 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
151 loop {
152 match tokens.next().transpose()? {
153 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
154 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
155 "ServiceSoftwareOptions" => {
156 builder = builder.set_service_software_options(
157 crate::protocol_serde::shape_service_software_options::de_service_software_options(tokens)?,
158 );
159 }
160 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
161 },
162 other => {
163 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
164 "expected object key or end object, found: {:?}",
165 other
166 )))
167 }
168 }
169 }
170 if tokens.next().is_some() {
171 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
172 "found more JSON tokens after completing parsing",
173 ));
174 }
175 Ok(builder)
176}