161 167 |
|
162 168 | // If this is an error, defer to the non-streaming parser
|
163 169 | if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
|
164 170 | return ::std::option::Option::None;
|
165 171 | }
|
166 172 | ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
|
167 173 | crate::protocol_serde::shape_invoke_model_with_bidirectional_stream::de_invoke_model_with_bidirectional_stream_http_response(response),
|
168 174 | ))
|
169 175 | }
|
170 176 |
|
171 - | fn deserialize_nonstreaming(
|
177 + | fn deserialize_nonstreaming_with_config(
|
172 178 | &self,
|
173 179 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
180 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
174 181 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
175 182 | // For streaming operations, we only hit this case if its an error
|
176 183 | let body = response.body().bytes().expect("body loaded");
|
177 - | crate::protocol_serde::type_erase_result(
|
178 - | crate::protocol_serde::shape_invoke_model_with_bidirectional_stream::de_invoke_model_with_bidirectional_stream_http_error(
|
179 - | response.status().as_u16(),
|
180 - | response.headers(),
|
181 - | body,
|
182 - | ),
|
183 - | )
|
184 + | let status = response.status().as_u16();
|
185 + | let headers = response.headers();
|
186 + | #[allow(unused_mut)]
|
187 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
188 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
189 + | })?;
|
190 + | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
|
191 + | let generic = generic_builder.build();
|
192 + | let error_code = match generic.code() {
|
193 + | ::std::option::Option::Some(code) => code,
|
194 + | ::std::option::Option::None => {
|
195 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
196 + | ::aws_smithy_runtime_api::box_error::BoxError::from(
|
197 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::unhandled(generic),
|
198 + | ),
|
199 + | ))
|
200 + | }
|
201 + | };
|
202 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
203 + | let protocol = _cfg
|
204 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
205 + | .expect("a SharedClientProtocol is required");
|
206 + | let err = match error_code {
|
207 + | "AccessDeniedException" => {
|
208 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::AccessDeniedException({
|
209 + | let mut tmp = match protocol
|
210 + | .deserialize_response(response, crate::types::error::AccessDeniedException::SCHEMA, _cfg)
|
211 + | .and_then(|mut deser| {
|
212 + | crate::types::error::AccessDeniedException::deserialize_with_response(
|
213 + | &mut *deser,
|
214 + | response.headers(),
|
215 + | response.status().into(),
|
216 + | body,
|
217 + | )
|
218 + | }) {
|
219 + | ::std::result::Result::Ok(val) => val,
|
220 + | ::std::result::Result::Err(e) => {
|
221 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
222 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
223 + | ))
|
224 + | }
|
225 + | };
|
226 + | tmp.meta = generic;
|
227 + | if tmp.message.is_none() {
|
228 + | tmp.message = _error_message;
|
229 + | }
|
230 + | tmp
|
231 + | })
|
232 + | }
|
233 + | "InternalServerException" => {
|
234 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::InternalServerException({
|
235 + | let mut tmp = match protocol
|
236 + | .deserialize_response(response, crate::types::error::InternalServerException::SCHEMA, _cfg)
|
237 + | .and_then(|mut deser| {
|
238 + | crate::types::error::InternalServerException::deserialize_with_response(
|
239 + | &mut *deser,
|
240 + | response.headers(),
|
241 + | response.status().into(),
|
242 + | body,
|
243 + | )
|
244 + | }) {
|
245 + | ::std::result::Result::Ok(val) => val,
|
246 + | ::std::result::Result::Err(e) => {
|
247 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
248 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
249 + | ))
|
250 + | }
|
251 + | };
|
252 + | tmp.meta = generic;
|
253 + | if tmp.message.is_none() {
|
254 + | tmp.message = _error_message;
|
255 + | }
|
256 + | tmp
|
257 + | })
|
258 + | }
|
259 + | "ModelErrorException" => {
|
260 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ModelErrorException({
|
261 + | let mut tmp = match protocol
|
262 + | .deserialize_response(response, crate::types::error::ModelErrorException::SCHEMA, _cfg)
|
263 + | .and_then(|mut deser| {
|
264 + | crate::types::error::ModelErrorException::deserialize_with_response(
|
265 + | &mut *deser,
|
266 + | response.headers(),
|
267 + | response.status().into(),
|
268 + | body,
|
269 + | )
|
270 + | }) {
|
271 + | ::std::result::Result::Ok(val) => val,
|
272 + | ::std::result::Result::Err(e) => {
|
273 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
274 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
275 + | ))
|
276 + | }
|
277 + | };
|
278 + | tmp.meta = generic;
|
279 + | if tmp.message.is_none() {
|
280 + | tmp.message = _error_message;
|
281 + | }
|
282 + | tmp
|
283 + | })
|
284 + | }
|
285 + | "ModelNotReadyException" => {
|
286 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ModelNotReadyException({
|
287 + | let mut tmp = match protocol
|
288 + | .deserialize_response(response, crate::types::error::ModelNotReadyException::SCHEMA, _cfg)
|
289 + | .and_then(|mut deser| {
|
290 + | crate::types::error::ModelNotReadyException::deserialize_with_response(
|
291 + | &mut *deser,
|
292 + | response.headers(),
|
293 + | response.status().into(),
|
294 + | body,
|
295 + | )
|
296 + | }) {
|
297 + | ::std::result::Result::Ok(val) => val,
|
298 + | ::std::result::Result::Err(e) => {
|
299 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
300 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
301 + | ))
|
302 + | }
|
303 + | };
|
304 + | tmp.meta = generic;
|
305 + | if tmp.message.is_none() {
|
306 + | tmp.message = _error_message;
|
307 + | }
|
308 + | tmp
|
309 + | })
|
310 + | }
|
311 + | "ModelStreamErrorException" => {
|
312 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ModelStreamErrorException({
|
313 + | let mut tmp = match protocol
|
314 + | .deserialize_response(response, crate::types::error::ModelStreamErrorException::SCHEMA, _cfg)
|
315 + | .and_then(|mut deser| {
|
316 + | crate::types::error::ModelStreamErrorException::deserialize_with_response(
|
317 + | &mut *deser,
|
318 + | response.headers(),
|
319 + | response.status().into(),
|
320 + | body,
|
321 + | )
|
322 + | }) {
|
323 + | ::std::result::Result::Ok(val) => val,
|
324 + | ::std::result::Result::Err(e) => {
|
325 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
326 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
327 + | ))
|
328 + | }
|
329 + | };
|
330 + | tmp.meta = generic;
|
331 + | if tmp.message.is_none() {
|
332 + | tmp.message = _error_message;
|
333 + | }
|
334 + | tmp
|
335 + | })
|
336 + | }
|
337 + | "ModelTimeoutException" => {
|
338 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ModelTimeoutException({
|
339 + | let mut tmp = match protocol
|
340 + | .deserialize_response(response, crate::types::error::ModelTimeoutException::SCHEMA, _cfg)
|
341 + | .and_then(|mut deser| {
|
342 + | crate::types::error::ModelTimeoutException::deserialize_with_response(
|
343 + | &mut *deser,
|
344 + | response.headers(),
|
345 + | response.status().into(),
|
346 + | body,
|
347 + | )
|
348 + | }) {
|
349 + | ::std::result::Result::Ok(val) => val,
|
350 + | ::std::result::Result::Err(e) => {
|
351 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
352 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
353 + | ))
|
354 + | }
|
355 + | };
|
356 + | tmp.meta = generic;
|
357 + | if tmp.message.is_none() {
|
358 + | tmp.message = _error_message;
|
359 + | }
|
360 + | tmp
|
361 + | })
|
362 + | }
|
363 + | "ResourceNotFoundException" => {
|
364 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ResourceNotFoundException({
|
365 + | let mut tmp = match protocol
|
366 + | .deserialize_response(response, crate::types::error::ResourceNotFoundException::SCHEMA, _cfg)
|
367 + | .and_then(|mut deser| {
|
368 + | crate::types::error::ResourceNotFoundException::deserialize_with_response(
|
369 + | &mut *deser,
|
370 + | response.headers(),
|
371 + | response.status().into(),
|
372 + | body,
|
373 + | )
|
374 + | }) {
|
375 + | ::std::result::Result::Ok(val) => val,
|
376 + | ::std::result::Result::Err(e) => {
|
377 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
378 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
379 + | ))
|
380 + | }
|
381 + | };
|
382 + | tmp.meta = generic;
|
383 + | if tmp.message.is_none() {
|
384 + | tmp.message = _error_message;
|
385 + | }
|
386 + | tmp
|
387 + | })
|
388 + | }
|
389 + | "ServiceQuotaExceededException" => {
|
390 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ServiceQuotaExceededException({
|
391 + | let mut tmp = match protocol
|
392 + | .deserialize_response(response, crate::types::error::ServiceQuotaExceededException::SCHEMA, _cfg)
|
393 + | .and_then(|mut deser| {
|
394 + | crate::types::error::ServiceQuotaExceededException::deserialize_with_response(
|
395 + | &mut *deser,
|
396 + | response.headers(),
|
397 + | response.status().into(),
|
398 + | body,
|
399 + | )
|
400 + | }) {
|
401 + | ::std::result::Result::Ok(val) => val,
|
402 + | ::std::result::Result::Err(e) => {
|
403 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
404 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
405 + | ))
|
406 + | }
|
407 + | };
|
408 + | tmp.meta = generic;
|
409 + | if tmp.message.is_none() {
|
410 + | tmp.message = _error_message;
|
411 + | }
|
412 + | tmp
|
413 + | })
|
414 + | }
|
415 + | "ServiceUnavailableException" => {
|
416 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ServiceUnavailableException({
|
417 + | let mut tmp = match protocol
|
418 + | .deserialize_response(response, crate::types::error::ServiceUnavailableException::SCHEMA, _cfg)
|
419 + | .and_then(|mut deser| {
|
420 + | crate::types::error::ServiceUnavailableException::deserialize_with_response(
|
421 + | &mut *deser,
|
422 + | response.headers(),
|
423 + | response.status().into(),
|
424 + | body,
|
425 + | )
|
426 + | }) {
|
427 + | ::std::result::Result::Ok(val) => val,
|
428 + | ::std::result::Result::Err(e) => {
|
429 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
430 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
431 + | ))
|
432 + | }
|
433 + | };
|
434 + | tmp.meta = generic;
|
435 + | if tmp.message.is_none() {
|
436 + | tmp.message = _error_message;
|
437 + | }
|
438 + | tmp
|
439 + | })
|
440 + | }
|
441 + | "ThrottlingException" => {
|
442 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ThrottlingException({
|
443 + | let mut tmp = match protocol
|
444 + | .deserialize_response(response, crate::types::error::ThrottlingException::SCHEMA, _cfg)
|
445 + | .and_then(|mut deser| {
|
446 + | crate::types::error::ThrottlingException::deserialize_with_response(
|
447 + | &mut *deser,
|
448 + | response.headers(),
|
449 + | response.status().into(),
|
450 + | body,
|
451 + | )
|
452 + | }) {
|
453 + | ::std::result::Result::Ok(val) => val,
|
454 + | ::std::result::Result::Err(e) => {
|
455 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
456 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
457 + | ))
|
458 + | }
|
459 + | };
|
460 + | tmp.meta = generic;
|
461 + | if tmp.message.is_none() {
|
462 + | tmp.message = _error_message;
|
463 + | }
|
464 + | tmp
|
465 + | })
|
466 + | }
|
467 + | "ValidationException" => {
|
468 + | crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::ValidationException({
|
469 + | let mut tmp = match protocol
|
470 + | .deserialize_response(response, crate::types::error::ValidationException::SCHEMA, _cfg)
|
471 + | .and_then(|mut deser| {
|
472 + | crate::types::error::ValidationException::deserialize_with_response(
|
473 + | &mut *deser,
|
474 + | response.headers(),
|
475 + | response.status().into(),
|
476 + | body,
|
477 + | )
|
478 + | }) {
|
479 + | ::std::result::Result::Ok(val) => val,
|
480 + | ::std::result::Result::Err(e) => {
|
481 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
482 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
483 + | ))
|
484 + | }
|
485 + | };
|
486 + | tmp.meta = generic;
|
487 + | if tmp.message.is_none() {
|
488 + | tmp.message = _error_message;
|
489 + | }
|
490 + | tmp
|
491 + | })
|
492 + | }
|
493 + | _ => crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamError::generic(generic),
|
494 + | };
|
495 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
496 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
497 + | ))
|
184 498 | }
|
185 499 | }
|
186 500 | #[derive(Debug)]
|
187 501 | struct InvokeModelWithBidirectionalStreamRequestSerializer;
|
188 502 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for InvokeModelWithBidirectionalStreamRequestSerializer {
|
189 503 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
190 504 | fn serialize_input(
|
191 505 | &self,
|
192 506 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
193 507 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
194 508 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
195 509 | let input = input
|
196 510 | .downcast::<crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamInput>()
|
197 511 | .expect("correct type");
|
198 - | let _header_serialization_settings = _cfg
|
199 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
200 - | .cloned()
|
201 - | .unwrap_or_default();
|
202 - | let mut request_builder = {
|
203 - | #[allow(clippy::uninlined_format_args)]
|
204 - | fn uri_base(
|
205 - | _input: &crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamInput,
|
206 - | output: &mut ::std::string::String,
|
207 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
208 - | use ::std::fmt::Write as _;
|
209 - | let input_1 = &_input.model_id;
|
210 - | let input_1 = input_1
|
211 - | .as_ref()
|
212 - | .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("model_id", "cannot be empty or unset"))?;
|
213 - | let model_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
|
214 - | if model_id.is_empty() {
|
215 - | return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
|
216 - | "model_id",
|
217 - | "cannot be empty or unset",
|
218 - | ));
|
219 - | }
|
220 - | ::std::write!(output, "/model/{modelId}/invoke-with-bidirectional-stream", modelId = model_id).expect("formatting should succeed");
|
221 - | ::std::result::Result::Ok(())
|
222 - | }
|
223 - | #[allow(clippy::unnecessary_wraps)]
|
224 - | fn update_http_builder(
|
225 - | input: &crate::operation::invoke_model_with_bidirectional_stream::InvokeModelWithBidirectionalStreamInput,
|
226 - | builder: ::http_1x::request::Builder,
|
227 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
228 - | let mut uri = ::std::string::String::new();
|
229 - | uri_base(input, &mut uri)?;
|
230 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
231 - | }
|
232 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
233 - | builder =
|
234 - | _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
|
235 - | builder
|
236 - | };
|
237 - | let body = ::aws_smithy_types::body::SdkBody::from({
|
512 + | let protocol = _cfg
|
513 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
514 + | .expect("a SharedClientProtocol is required");
|
515 + | let mut request = protocol
|
516 + | .serialize_request(&input, InvokeModelWithBidirectionalStream::INPUT_SCHEMA, "", _cfg)
|
517 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
518 + | *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
|
238 519 | let error_marshaller = crate::event_stream_serde::InvokeModelWithBidirectionalStreamInputErrorMarshaller::new();
|
239 520 | let marshaller = crate::event_stream_serde::InvokeModelWithBidirectionalStreamInputMarshaller::new();
|
240 521 | let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
|
241 522 | _cfg.interceptor_state().store_put(signer_sender);
|
242 523 | ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.body.into_body_stream(
|
243 524 | marshaller,
|
244 525 | error_marshaller,
|
245 526 | signer,
|
246 527 | )))
|
247 528 | });
|
248 - | if let Some(content_length) = body.content_length() {
|
249 - | let content_length = content_length.to_string();
|
250 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
251 - | }
|
252 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
529 + | // The protocol may have set Content-Length based on the initial empty body.
|
530 + | // Remove it since the event stream body has unknown length.
|
531 + | request.headers_mut().remove("Content-Length");
|
532 + | request.headers_mut().insert("Content-Type", "application/vnd.amazon.eventstream");
|
533 + |
|
534 + | return ::std::result::Result::Ok(request);
|
253 535 | }
|
254 536 | }
|
255 537 | #[derive(Debug)]
|
256 538 | struct InvokeModelWithBidirectionalStreamEndpointParamsInterceptor;
|
257 539 |
|
258 540 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for InvokeModelWithBidirectionalStreamEndpointParamsInterceptor {
|
259 541 | fn name(&self) -> &'static str {
|
260 542 | "InvokeModelWithBidirectionalStreamEndpointParamsInterceptor"
|
261 543 | }
|
262 544 |
|