185 185 | "Failed to parse VocabularyNames from header `x-amzn-transcribe-vocabulary-names",
|
186 186 | )
|
187 187 | })?,
|
188 188 | );
|
189 189 | output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
|
190 190 | output
|
191 191 | .build()
|
192 192 | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?
|
193 193 | })
|
194 194 | }
|
195 - |
|
196 - | #[allow(clippy::unnecessary_wraps)]
|
197 - | pub fn de_start_stream_transcription_http_error(
|
198 - | _response_status: u16,
|
199 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
200 - | _response_body: &[u8],
|
201 - | ) -> std::result::Result<
|
202 - | crate::operation::start_stream_transcription::StartStreamTranscriptionOutput,
|
203 - | crate::operation::start_stream_transcription::StartStreamTranscriptionError,
|
204 - | > {
|
205 - | #[allow(unused_mut)]
|
206 - | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
|
207 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
208 - | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
|
209 - | let generic = generic_builder.build();
|
210 - | let error_code = match generic.code() {
|
211 - | Some(code) => code,
|
212 - | None => {
|
213 - | return Err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled(
|
214 - | generic,
|
215 - | ))
|
216 - | }
|
217 - | };
|
218 - |
|
219 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
220 - | Err(match error_code {
|
221 - | "BadRequestException" => crate::operation::start_stream_transcription::StartStreamTranscriptionError::BadRequestException({
|
222 - | #[allow(unused_mut)]
|
223 - | let mut tmp = {
|
224 - | #[allow(unused_mut)]
|
225 - | let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
|
226 - | output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
|
227 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
228 - | let output = output.meta(generic);
|
229 - | output.build()
|
230 - | };
|
231 - | if tmp.message.is_none() {
|
232 - | tmp.message = _error_message;
|
233 - | }
|
234 - | tmp
|
235 - | }),
|
236 - | "ConflictException" => crate::operation::start_stream_transcription::StartStreamTranscriptionError::ConflictException({
|
237 - | #[allow(unused_mut)]
|
238 - | let mut tmp = {
|
239 - | #[allow(unused_mut)]
|
240 - | let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
|
241 - | output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
|
242 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
243 - | let output = output.meta(generic);
|
244 - | output.build()
|
245 - | };
|
246 - | if tmp.message.is_none() {
|
247 - | tmp.message = _error_message;
|
248 - | }
|
249 - | tmp
|
250 - | }),
|
251 - | "InternalFailureException" => crate::operation::start_stream_transcription::StartStreamTranscriptionError::InternalFailureException({
|
252 - | #[allow(unused_mut)]
|
253 - | let mut tmp = {
|
254 - | #[allow(unused_mut)]
|
255 - | let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
|
256 - | output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
|
257 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
258 - | let output = output.meta(generic);
|
259 - | output.build()
|
260 - | };
|
261 - | if tmp.message.is_none() {
|
262 - | tmp.message = _error_message;
|
263 - | }
|
264 - | tmp
|
265 - | }),
|
266 - | "LimitExceededException" => crate::operation::start_stream_transcription::StartStreamTranscriptionError::LimitExceededException({
|
267 - | #[allow(unused_mut)]
|
268 - | let mut tmp = {
|
269 - | #[allow(unused_mut)]
|
270 - | let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
|
271 - | output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
|
272 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
273 - | let output = output.meta(generic);
|
274 - | output.build()
|
275 - | };
|
276 - | if tmp.message.is_none() {
|
277 - | tmp.message = _error_message;
|
278 - | }
|
279 - | tmp
|
280 - | }),
|
281 - | "ServiceUnavailableException" => crate::operation::start_stream_transcription::StartStreamTranscriptionError::ServiceUnavailableException({
|
282 - | #[allow(unused_mut)]
|
283 - | let mut tmp = {
|
284 - | #[allow(unused_mut)]
|
285 - | let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
|
286 - | output =
|
287 - | crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
|
288 - | .map_err(crate::operation::start_stream_transcription::StartStreamTranscriptionError::unhandled)?;
|
289 - | let output = output.meta(generic);
|
290 - | output.build()
|
291 - | };
|
292 - | if tmp.message.is_none() {
|
293 - | tmp.message = _error_message;
|
294 - | }
|
295 - | tmp
|
296 - | }),
|
297 - | _ => crate::operation::start_stream_transcription::StartStreamTranscriptionError::generic(generic),
|
298 - | })
|
299 - | }
|
300 - |
|
301 - | pub fn ser_start_stream_transcription_headers(
|
302 - | input: &crate::operation::start_stream_transcription::StartStreamTranscriptionInput,
|
303 - | mut builder: ::http_1x::request::Builder,
|
304 - | ) -> std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
305 - | if let ::std::option::Option::Some(inner_1) = &input.language_code {
|
306 - | let formatted_2 = inner_1.as_str();
|
307 - | let header_value = formatted_2;
|
308 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
309 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
310 - | "language_code",
|
311 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
312 - | )
|
313 - | })?;
|
314 - | builder = builder.header("x-amzn-transcribe-language-code", header_value);
|
315 - | }
|
316 - | if let ::std::option::Option::Some(inner_3) = &input.media_sample_rate_hertz {
|
317 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_3);
|
318 - | let formatted_4 = encoder.encode();
|
319 - | let header_value = formatted_4;
|
320 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
321 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
322 - | "media_sample_rate_hertz",
|
323 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
324 - | )
|
325 - | })?;
|
326 - | builder = builder.header("x-amzn-transcribe-sample-rate", header_value);
|
327 - | }
|
328 - | if let ::std::option::Option::Some(inner_5) = &input.media_encoding {
|
329 - | let formatted_6 = inner_5.as_str();
|
330 - | let header_value = formatted_6;
|
331 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
332 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
333 - | "media_encoding",
|
334 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
335 - | )
|
336 - | })?;
|
337 - | builder = builder.header("x-amzn-transcribe-media-encoding", header_value);
|
338 - | }
|
339 - | if let ::std::option::Option::Some(inner_7) = &input.vocabulary_name {
|
340 - | let formatted_8 = inner_7.as_str();
|
341 - | let header_value = formatted_8;
|
342 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
343 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
344 - | "vocabulary_name",
|
345 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
346 - | )
|
347 - | })?;
|
348 - | builder = builder.header("x-amzn-transcribe-vocabulary-name", header_value);
|
349 - | }
|
350 - | if let ::std::option::Option::Some(inner_9) = &input.session_id {
|
351 - | let formatted_10 = inner_9.as_str();
|
352 - | let header_value = formatted_10;
|
353 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
354 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
355 - | "session_id",
|
356 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
357 - | )
|
358 - | })?;
|
359 - | builder = builder.header("x-amzn-transcribe-session-id", header_value);
|
360 - | }
|
361 - | if let ::std::option::Option::Some(inner_11) = &input.vocabulary_filter_name {
|
362 - | let formatted_12 = inner_11.as_str();
|
363 - | let header_value = formatted_12;
|
364 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
365 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
366 - | "vocabulary_filter_name",
|
367 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
368 - | )
|
369 - | })?;
|
370 - | builder = builder.header("x-amzn-transcribe-vocabulary-filter-name", header_value);
|
371 - | }
|
372 - | if let ::std::option::Option::Some(inner_13) = &input.vocabulary_filter_method {
|
373 - | let formatted_14 = inner_13.as_str();
|
374 - | let header_value = formatted_14;
|
375 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
376 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
377 - | "vocabulary_filter_method",
|
378 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
379 - | )
|
380 - | })?;
|
381 - | builder = builder.header("x-amzn-transcribe-vocabulary-filter-method", header_value);
|
382 - | }
|
383 - | if let ::std::option::Option::Some(inner_15) = &input.show_speaker_label {
|
384 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_15);
|
385 - | let formatted_16 = encoder.encode();
|
386 - | let header_value = formatted_16;
|
387 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
388 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
389 - | "show_speaker_label",
|
390 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
391 - | )
|
392 - | })?;
|
393 - | builder = builder.header("x-amzn-transcribe-show-speaker-label", header_value);
|
394 - | }
|
395 - | if let ::std::option::Option::Some(inner_17) = &input.enable_channel_identification {
|
396 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_17);
|
397 - | let formatted_18 = encoder.encode();
|
398 - | let header_value = formatted_18;
|
399 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
400 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
401 - | "enable_channel_identification",
|
402 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
403 - | )
|
404 - | })?;
|
405 - | builder = builder.header("x-amzn-transcribe-enable-channel-identification", header_value);
|
406 - | }
|
407 - | if let ::std::option::Option::Some(inner_19) = &input.number_of_channels {
|
408 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_19);
|
409 - | let formatted_20 = encoder.encode();
|
410 - | let header_value = formatted_20;
|
411 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
412 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
413 - | "number_of_channels",
|
414 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
415 - | )
|
416 - | })?;
|
417 - | builder = builder.header("x-amzn-transcribe-number-of-channels", header_value);
|
418 - | }
|
419 - | if let ::std::option::Option::Some(inner_21) = &input.enable_partial_results_stabilization {
|
420 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_21);
|
421 - | let formatted_22 = encoder.encode();
|
422 - | let header_value = formatted_22;
|
423 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
424 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
425 - | "enable_partial_results_stabilization",
|
426 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
427 - | )
|
428 - | })?;
|
429 - | builder = builder.header("x-amzn-transcribe-enable-partial-results-stabilization", header_value);
|
430 - | }
|
431 - | if let ::std::option::Option::Some(inner_23) = &input.partial_results_stability {
|
432 - | let formatted_24 = inner_23.as_str();
|
433 - | let header_value = formatted_24;
|
434 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
435 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
436 - | "partial_results_stability",
|
437 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
438 - | )
|
439 - | })?;
|
440 - | builder = builder.header("x-amzn-transcribe-partial-results-stability", header_value);
|
441 - | }
|
442 - | if let ::std::option::Option::Some(inner_25) = &input.content_identification_type {
|
443 - | let formatted_26 = inner_25.as_str();
|
444 - | let header_value = formatted_26;
|
445 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
446 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
447 - | "content_identification_type",
|
448 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
449 - | )
|
450 - | })?;
|
451 - | builder = builder.header("x-amzn-transcribe-content-identification-type", header_value);
|
452 - | }
|
453 - | if let ::std::option::Option::Some(inner_27) = &input.content_redaction_type {
|
454 - | let formatted_28 = inner_27.as_str();
|
455 - | let header_value = formatted_28;
|
456 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
457 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
458 - | "content_redaction_type",
|
459 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
460 - | )
|
461 - | })?;
|
462 - | builder = builder.header("x-amzn-transcribe-content-redaction-type", header_value);
|
463 - | }
|
464 - | if let ::std::option::Option::Some(inner_29) = &input.pii_entity_types {
|
465 - | let formatted_30 = inner_29.as_str();
|
466 - | let header_value = formatted_30;
|
467 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
468 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
469 - | "pii_entity_types",
|
470 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
471 - | )
|
472 - | })?;
|
473 - | builder = builder.header("x-amzn-transcribe-pii-entity-types", header_value);
|
474 - | }
|
475 - | if let ::std::option::Option::Some(inner_31) = &input.language_model_name {
|
476 - | let formatted_32 = inner_31.as_str();
|
477 - | let header_value = formatted_32;
|
478 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
479 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
480 - | "language_model_name",
|
481 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
482 - | )
|
483 - | })?;
|
484 - | builder = builder.header("x-amzn-transcribe-language-model-name", header_value);
|
485 - | }
|
486 - | if let ::std::option::Option::Some(inner_33) = &input.identify_language {
|
487 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_33);
|
488 - | let formatted_34 = encoder.encode();
|
489 - | let header_value = formatted_34;
|
490 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
491 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
492 - | "identify_language",
|
493 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
494 - | )
|
495 - | })?;
|
496 - | builder = builder.header("x-amzn-transcribe-identify-language", header_value);
|
497 - | }
|
498 - | if let ::std::option::Option::Some(inner_35) = &input.language_options {
|
499 - | let formatted_36 = inner_35.as_str();
|
500 - | let header_value = formatted_36;
|
501 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
502 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
503 - | "language_options",
|
504 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
505 - | )
|
506 - | })?;
|
507 - | builder = builder.header("x-amzn-transcribe-language-options", header_value);
|
508 - | }
|
509 - | if let ::std::option::Option::Some(inner_37) = &input.preferred_language {
|
510 - | let formatted_38 = inner_37.as_str();
|
511 - | let header_value = formatted_38;
|
512 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
513 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
514 - | "preferred_language",
|
515 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
516 - | )
|
517 - | })?;
|
518 - | builder = builder.header("x-amzn-transcribe-preferred-language", header_value);
|
519 - | }
|
520 - | if let ::std::option::Option::Some(inner_39) = &input.identify_multiple_languages {
|
521 - | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_39);
|
522 - | let formatted_40 = encoder.encode();
|
523 - | let header_value = formatted_40;
|
524 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
525 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
526 - | "identify_multiple_languages",
|
527 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
528 - | )
|
529 - | })?;
|
530 - | builder = builder.header("x-amzn-transcribe-identify-multiple-languages", header_value);
|
531 - | }
|
532 - | if let ::std::option::Option::Some(inner_41) = &input.vocabulary_names {
|
533 - | let formatted_42 = inner_41.as_str();
|
534 - | let header_value = formatted_42;
|
535 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
536 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
537 - | "vocabulary_names",
|
538 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
539 - | )
|
540 - | })?;
|
541 - | builder = builder.header("x-amzn-transcribe-vocabulary-names", header_value);
|
542 - | }
|
543 - | if let ::std::option::Option::Some(inner_43) = &input.vocabulary_filter_names {
|
544 - | let formatted_44 = inner_43.as_str();
|
545 - | let header_value = formatted_44;
|
546 - | let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
|
547 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
548 - | "vocabulary_filter_names",
|
549 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
550 - | )
|
551 - | })?;
|
552 - | builder = builder.header("x-amzn-transcribe-vocabulary-filter-names", header_value);
|
553 - | }
|
554 - | Ok(builder)
|
555 - | }
|