138 142 | ::std::borrow::Cow::Owned(rcb)
|
139 143 | }
|
140 144 | }
|
141 145 |
|
142 146 | #[derive(Debug)]
|
143 147 | struct PutLexiconResponseDeserializer;
|
144 148 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for PutLexiconResponseDeserializer {
|
145 149 | fn deserialize_nonstreaming(
|
146 150 | &self,
|
147 151 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
152 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
148 153 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
149 154 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
150 - | let headers = response.headers();
|
151 - | let body = response.body().bytes().expect("body loaded");
|
152 155 | #[allow(unused_mut)]
|
153 156 | let mut force_error = false;
|
154 157 | ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
|
155 - | let parse_result = if !success && status != 200 || force_error {
|
156 - | crate::protocol_serde::shape_put_lexicon::de_put_lexicon_http_error(status, headers, body)
|
157 - | } else {
|
158 - | crate::protocol_serde::shape_put_lexicon::de_put_lexicon_http_response(status, headers, body)
|
158 + | if !success && status != 200 || force_error {
|
159 + | let headers = response.headers();
|
160 + | let body = response.body().bytes().expect("body loaded");
|
161 + | #[allow(unused_mut)]
|
162 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
163 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
164 + | })?;
|
165 + | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
|
166 + | let generic = generic_builder.build();
|
167 + | let error_code = match generic.code() {
|
168 + | ::std::option::Option::Some(code) => code,
|
169 + | ::std::option::Option::None => {
|
170 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
171 + | ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::put_lexicon::PutLexiconError::unhandled(generic)),
|
172 + | ))
|
173 + | }
|
174 + | };
|
175 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
176 + | let protocol = _cfg
|
177 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
178 + | .expect("a SharedClientProtocol is required");
|
179 + | let err = match error_code {
|
180 + | "InvalidLexiconException" => crate::operation::put_lexicon::PutLexiconError::InvalidLexiconException({
|
181 + | let mut tmp = match protocol
|
182 + | .deserialize_response(response, crate::types::error::InvalidLexiconException::SCHEMA, _cfg)
|
183 + | .and_then(|mut deser| {
|
184 + | crate::types::error::InvalidLexiconException::deserialize_with_response(
|
185 + | &mut *deser,
|
186 + | response.headers(),
|
187 + | response.status().into(),
|
188 + | body,
|
189 + | )
|
190 + | }) {
|
191 + | ::std::result::Result::Ok(val) => val,
|
192 + | ::std::result::Result::Err(e) => {
|
193 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
194 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
195 + | ))
|
196 + | }
|
197 + | };
|
198 + | tmp.meta = generic;
|
199 + | if tmp.message.is_none() {
|
200 + | tmp.message = _error_message;
|
201 + | }
|
202 + | tmp
|
203 + | }),
|
204 + | "LexiconSizeExceededException" => crate::operation::put_lexicon::PutLexiconError::LexiconSizeExceededException({
|
205 + | let mut tmp = match protocol
|
206 + | .deserialize_response(response, crate::types::error::LexiconSizeExceededException::SCHEMA, _cfg)
|
207 + | .and_then(|mut deser| {
|
208 + | crate::types::error::LexiconSizeExceededException::deserialize_with_response(
|
209 + | &mut *deser,
|
210 + | response.headers(),
|
211 + | response.status().into(),
|
212 + | body,
|
213 + | )
|
214 + | }) {
|
215 + | ::std::result::Result::Ok(val) => val,
|
216 + | ::std::result::Result::Err(e) => {
|
217 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
218 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
219 + | ))
|
220 + | }
|
221 + | };
|
222 + | tmp.meta = generic;
|
223 + | if tmp.message.is_none() {
|
224 + | tmp.message = _error_message;
|
225 + | }
|
226 + | tmp
|
227 + | }),
|
228 + | "MaxLexemeLengthExceededException" => crate::operation::put_lexicon::PutLexiconError::MaxLexemeLengthExceededException({
|
229 + | let mut tmp = match protocol
|
230 + | .deserialize_response(response, crate::types::error::MaxLexemeLengthExceededException::SCHEMA, _cfg)
|
231 + | .and_then(|mut deser| {
|
232 + | crate::types::error::MaxLexemeLengthExceededException::deserialize_with_response(
|
233 + | &mut *deser,
|
234 + | response.headers(),
|
235 + | response.status().into(),
|
236 + | body,
|
237 + | )
|
238 + | }) {
|
239 + | ::std::result::Result::Ok(val) => val,
|
240 + | ::std::result::Result::Err(e) => {
|
241 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
242 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
243 + | ))
|
244 + | }
|
245 + | };
|
246 + | tmp.meta = generic;
|
247 + | if tmp.message.is_none() {
|
248 + | tmp.message = _error_message;
|
249 + | }
|
250 + | tmp
|
251 + | }),
|
252 + | "MaxLexiconsNumberExceededException" => crate::operation::put_lexicon::PutLexiconError::MaxLexiconsNumberExceededException({
|
253 + | let mut tmp = match protocol
|
254 + | .deserialize_response(response, crate::types::error::MaxLexiconsNumberExceededException::SCHEMA, _cfg)
|
255 + | .and_then(|mut deser| {
|
256 + | crate::types::error::MaxLexiconsNumberExceededException::deserialize_with_response(
|
257 + | &mut *deser,
|
258 + | response.headers(),
|
259 + | response.status().into(),
|
260 + | body,
|
261 + | )
|
262 + | }) {
|
263 + | ::std::result::Result::Ok(val) => val,
|
264 + | ::std::result::Result::Err(e) => {
|
265 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
266 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
267 + | ))
|
268 + | }
|
269 + | };
|
270 + | tmp.meta = generic;
|
271 + | if tmp.message.is_none() {
|
272 + | tmp.message = _error_message;
|
273 + | }
|
274 + | tmp
|
275 + | }),
|
276 + | "ServiceFailureException" => crate::operation::put_lexicon::PutLexiconError::ServiceFailureException({
|
277 + | let mut tmp = match protocol
|
278 + | .deserialize_response(response, crate::types::error::ServiceFailureException::SCHEMA, _cfg)
|
279 + | .and_then(|mut deser| {
|
280 + | crate::types::error::ServiceFailureException::deserialize_with_response(
|
281 + | &mut *deser,
|
282 + | response.headers(),
|
283 + | response.status().into(),
|
284 + | body,
|
285 + | )
|
286 + | }) {
|
287 + | ::std::result::Result::Ok(val) => val,
|
288 + | ::std::result::Result::Err(e) => {
|
289 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
290 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
291 + | ))
|
292 + | }
|
293 + | };
|
294 + | tmp.meta = generic;
|
295 + | if tmp.message.is_none() {
|
296 + | tmp.message = _error_message;
|
297 + | }
|
298 + | tmp
|
299 + | }),
|
300 + | "UnsupportedPlsAlphabetException" => crate::operation::put_lexicon::PutLexiconError::UnsupportedPlsAlphabetException({
|
301 + | let mut tmp = match protocol
|
302 + | .deserialize_response(response, crate::types::error::UnsupportedPlsAlphabetException::SCHEMA, _cfg)
|
303 + | .and_then(|mut deser| {
|
304 + | crate::types::error::UnsupportedPlsAlphabetException::deserialize_with_response(
|
305 + | &mut *deser,
|
306 + | response.headers(),
|
307 + | response.status().into(),
|
308 + | body,
|
309 + | )
|
310 + | }) {
|
311 + | ::std::result::Result::Ok(val) => val,
|
312 + | ::std::result::Result::Err(e) => {
|
313 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
314 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
315 + | ))
|
316 + | }
|
317 + | };
|
318 + | tmp.meta = generic;
|
319 + | if tmp.message.is_none() {
|
320 + | tmp.message = _error_message;
|
321 + | }
|
322 + | tmp
|
323 + | }),
|
324 + | "UnsupportedPlsLanguageException" => crate::operation::put_lexicon::PutLexiconError::UnsupportedPlsLanguageException({
|
325 + | let mut tmp = match protocol
|
326 + | .deserialize_response(response, crate::types::error::UnsupportedPlsLanguageException::SCHEMA, _cfg)
|
327 + | .and_then(|mut deser| {
|
328 + | crate::types::error::UnsupportedPlsLanguageException::deserialize_with_response(
|
329 + | &mut *deser,
|
330 + | response.headers(),
|
331 + | response.status().into(),
|
332 + | body,
|
333 + | )
|
334 + | }) {
|
335 + | ::std::result::Result::Ok(val) => val,
|
336 + | ::std::result::Result::Err(e) => {
|
337 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
338 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
339 + | ))
|
340 + | }
|
159 341 | };
|
160 - | crate::protocol_serde::type_erase_result(parse_result)
|
342 + | tmp.meta = generic;
|
343 + | if tmp.message.is_none() {
|
344 + | tmp.message = _error_message;
|
345 + | }
|
346 + | tmp
|
347 + | }),
|
348 + | _ => crate::operation::put_lexicon::PutLexiconError::generic(generic),
|
349 + | };
|
350 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
351 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
352 + | ))
|
353 + | } else {
|
354 + | let protocol = _cfg
|
355 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
356 + | .expect("a SharedClientProtocol is required");
|
357 + | let mut deser = protocol.deserialize_response(response, PutLexicon::OUTPUT_SCHEMA, _cfg).map_err(|e| {
|
358 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
359 + | })?;
|
360 + | let body = response.body().bytes().expect("body loaded");
|
361 + | let output = crate::operation::put_lexicon::PutLexiconOutput::deserialize_with_response(
|
362 + | &mut *deser,
|
363 + | response.headers(),
|
364 + | response.status().into(),
|
365 + | body,
|
366 + | )
|
367 + | .map_err(|e| {
|
368 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
369 + | })?;
|
370 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
371 + | }
|
161 372 | }
|
162 373 | }
|
163 374 | #[derive(Debug)]
|
164 375 | struct PutLexiconRequestSerializer;
|
165 376 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for PutLexiconRequestSerializer {
|
166 377 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
167 378 | fn serialize_input(
|
168 379 | &self,
|
169 380 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
170 381 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
171 382 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
172 383 | let input = input.downcast::<crate::operation::put_lexicon::PutLexiconInput>().expect("correct type");
|
173 - | let _header_serialization_settings = _cfg
|
174 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
175 - | .cloned()
|
176 - | .unwrap_or_default();
|
177 - | let mut request_builder = {
|
178 - | #[allow(clippy::uninlined_format_args)]
|
179 - | fn uri_base(
|
180 - | _input: &crate::operation::put_lexicon::PutLexiconInput,
|
181 - | output: &mut ::std::string::String,
|
182 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
183 - | use ::std::fmt::Write as _;
|
184 - | let input_1 = &_input.name;
|
185 - | let input_1 = input_1
|
186 - | .as_ref()
|
187 - | .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("name", "cannot be empty or unset"))?;
|
188 - | let name = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
|
189 - | if name.is_empty() {
|
190 - | return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
|
191 - | "name",
|
192 - | "cannot be empty or unset",
|
193 - | ));
|
384 + | let protocol = _cfg
|
385 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
386 + | .expect("a SharedClientProtocol is required");
|
387 + | if protocol.supports_http_bindings() {
|
388 + | let mut request = protocol
|
389 + | .serialize_body(&input, PutLexicon::INPUT_SCHEMA, "", _cfg)
|
390 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
391 + | {
|
392 + | let mut uri = "/v1/lexicons/{Name}".to_string();
|
393 + | let mut query_params: Vec<(String, String)> = Vec::new();
|
394 + | if let Some(ref val) = input.name {
|
395 + | uri = uri.replace("{Name}", &::aws_smithy_schema::http_protocol::percent_encode(&val.to_string()));
|
396 + | }
|
397 + | if !query_params.is_empty() {
|
398 + | uri.push(if uri.contains('?') { '&' } else { '?' });
|
399 + | let pairs: Vec<String> = query_params
|
400 + | .iter()
|
401 + | .map(|(k, v)| {
|
402 + | format!(
|
403 + | "{}={}",
|
404 + | ::aws_smithy_schema::http_protocol::percent_encode(k),
|
405 + | ::aws_smithy_schema::http_protocol::percent_encode(v)
|
406 + | )
|
407 + | })
|
408 + | .collect();
|
409 + | uri.push_str(&pairs.join("&"));
|
194 410 | }
|
195 - | ::std::write!(output, "/v1/lexicons/{Name}", Name = name).expect("formatting should succeed");
|
196 - | ::std::result::Result::Ok(())
|
411 + | request.set_uri(uri.as_str()).expect("valid URI");
|
197 412 | }
|
198 - | #[allow(clippy::unnecessary_wraps)]
|
199 - | fn update_http_builder(
|
200 - | input: &crate::operation::put_lexicon::PutLexiconInput,
|
201 - | builder: ::http_1x::request::Builder,
|
202 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
203 - | let mut uri = ::std::string::String::new();
|
204 - | uri_base(input, &mut uri)?;
|
205 - | ::std::result::Result::Ok(builder.method("PUT").uri(uri))
|
206 - | }
|
207 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
208 - | builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/json");
|
209 - | builder
|
210 - | };
|
211 - | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_put_lexicon::ser_put_lexicon_input(&input)?);
|
212 - | if let Some(content_length) = body.content_length() {
|
213 - | let content_length = content_length.to_string();
|
214 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
413 + |
|
414 + | return ::std::result::Result::Ok(request);
|
415 + | } else {
|
416 + | let mut request = protocol
|
417 + | .serialize_request(&input, PutLexicon::INPUT_SCHEMA, "", _cfg)
|
418 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
419 + |
|
420 + | return ::std::result::Result::Ok(request);
|
215 421 | }
|
216 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
217 422 | }
|
218 423 | }
|
219 424 | #[derive(Debug)]
|
220 425 | struct PutLexiconEndpointParamsInterceptor;
|
221 426 |
|
222 427 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for PutLexiconEndpointParamsInterceptor {
|
223 428 | fn name(&self) -> &'static str {
|
224 429 | "PutLexiconEndpointParamsInterceptor"
|
225 430 | }
|
226 431 |
|