1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct Chat;
6impl Chat {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::chat::ChatInput,
14 ) -> ::std::result::Result<
15 crate::operation::chat::ChatOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::chat::ChatError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22 ::aws_smithy_runtime_api::client::interceptors::context::Error,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >| { err.map_service_error(|err| err.downcast::<crate::operation::chat::ChatError>().expect("correct error type")) };
25 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
26 .await
27 .map_err(map_err)?;
28 let output = context.finalize().map_err(map_err)?;
29 ::std::result::Result::Ok(output.downcast::<crate::operation::chat::ChatOutput>().expect("correct output type"))
30 }
31
32 pub(crate) async fn orchestrate_with_stop_point(
33 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
34 input: crate::operation::chat::ChatInput,
35 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
36 ) -> ::std::result::Result<
37 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
38 ::aws_smithy_runtime_api::client::result::SdkError<
39 ::aws_smithy_runtime_api::client::interceptors::context::Error,
40 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
41 >,
42 > {
43 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
44 use ::tracing::Instrument;
45 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("QBusiness", "Chat", input, runtime_plugins, stop_point)
46 .instrument(::tracing::debug_span!(
49 "QBusiness.Chat",
50 "rpc.service" = "QBusiness",
51 "rpc.method" = "Chat",
52 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
53 "rpc.system" = "aws-api",
54 ))
55 .await
56 }
57
58 pub(crate) fn operation_runtime_plugins(
59 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
60 client_config: &crate::config::Config,
61 config_override: ::std::option::Option<crate::config::Builder>,
62 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
63 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
64 runtime_plugins = runtime_plugins.with_operation_plugin(crate::client_idempotency_token::IdempotencyTokenRuntimePlugin::new(
65 |token_provider, input| {
66 let input: &mut crate::operation::chat::ChatInput = input.downcast_mut().expect("correct type");
67 if input.client_token.is_none() {
68 input.client_token = ::std::option::Option::Some(token_provider.make_idempotency_token());
69 }
70 },
71 ));
72 if let ::std::option::Option::Some(config_override) = config_override {
73 for plugin in config_override.runtime_plugins.iter().cloned() {
74 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
75 }
76 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
77 config_override,
78 client_config.config.clone(),
79 &client_config.runtime_components,
80 ));
81 }
82 runtime_plugins
83 }
84}
85impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for Chat {
86 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
87 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("Chat");
88
89 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
90 ChatRequestSerializer,
91 ));
92 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
93 ChatResponseDeserializer,
94 ));
95
96 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
97 crate::config::auth::Params::builder()
98 .operation_name("Chat")
99 .build()
100 .expect("required fields set"),
101 ));
102
103 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("Chat", "QBusiness"));
104 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
105 signing_options.double_uri_encode = true;
106 signing_options.content_sha256_header = false;
107 signing_options.normalize_uri_path = true;
108 signing_options.payload_override = Some(::aws_sigv4::http_request::SignableBody::Bytes(&[]));
109
110 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
111 signing_options,
112 ..::std::default::Default::default()
113 });
114
115 ::std::option::Option::Some(cfg.freeze())
116 }
117
118 fn runtime_components(
119 &self,
120 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
121 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
122 #[allow(unused_mut)]
123 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("Chat")
124 .with_interceptor(ChatEndpointParamsInterceptor)
125 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
126 crate::operation::chat::ChatError,
127 >::new())
128 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
129 crate::operation::chat::ChatError,
130 >::new())
131 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
132 crate::operation::chat::ChatError,
133 >::new());
134
135 ::std::borrow::Cow::Owned(rcb)
136 }
137}
138
139#[derive(Debug)]
140struct ChatResponseDeserializer;
141impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ChatResponseDeserializer {
142 fn deserialize_streaming(
143 &self,
144 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
145 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
146 #[allow(unused_mut)]
147 let mut force_error = false;
148 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
149
150 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
152 return ::std::option::Option::None;
153 }
154 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
155 crate::protocol_serde::shape_chat::de_chat_http_response(response),
156 ))
157 }
158
159 fn deserialize_nonstreaming(
160 &self,
161 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
162 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
163 let body = response.body().bytes().expect("body loaded");
165 crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_chat::de_chat_http_error(
166 response.status().as_u16(),
167 response.headers(),
168 body,
169 ))
170 }
171}
172#[derive(Debug)]
173struct ChatRequestSerializer;
174impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ChatRequestSerializer {
175 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
176 fn serialize_input(
177 &self,
178 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
179 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
180 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
181 let input = input.downcast::<crate::operation::chat::ChatInput>().expect("correct type");
182 let _header_serialization_settings = _cfg
183 .load::<crate::serialization_settings::HeaderSerializationSettings>()
184 .cloned()
185 .unwrap_or_default();
186 let mut request_builder = {
187 #[allow(clippy::uninlined_format_args)]
188 fn uri_base(
189 _input: &crate::operation::chat::ChatInput,
190 output: &mut ::std::string::String,
191 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
192 use ::std::fmt::Write as _;
193 let input_1 = &_input.application_id;
194 let input_1 = input_1
195 .as_ref()
196 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("application_id", "cannot be empty or unset"))?;
197 let application_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
198 if application_id.is_empty() {
199 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
200 "application_id",
201 "cannot be empty or unset",
202 ));
203 }
204 ::std::write!(output, "/applications/{applicationId}/conversations", applicationId = application_id)
205 .expect("formatting should succeed");
206 ::std::result::Result::Ok(())
207 }
208 fn uri_query(
209 _input: &crate::operation::chat::ChatInput,
210 mut output: &mut ::std::string::String,
211 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
212 let mut query = ::aws_smithy_http::query::Writer::new(output);
213 if let ::std::option::Option::Some(inner_2) = &_input.user_id {
214 {
215 query.push_kv("userId", &::aws_smithy_http::query::fmt_string(inner_2));
216 }
217 }
218 if let ::std::option::Option::Some(inner_3) = &_input.user_groups {
219 {
220 for inner_4 in inner_3 {
221 query.push_kv("userGroups", &::aws_smithy_http::query::fmt_string(inner_4));
222 }
223 }
224 }
225 if let ::std::option::Option::Some(inner_5) = &_input.conversation_id {
226 {
227 query.push_kv("conversationId", &::aws_smithy_http::query::fmt_string(inner_5));
228 }
229 }
230 if let ::std::option::Option::Some(inner_6) = &_input.parent_message_id {
231 {
232 query.push_kv("parentMessageId", &::aws_smithy_http::query::fmt_string(inner_6));
233 }
234 }
235 if let ::std::option::Option::Some(inner_7) = &_input.client_token {
236 {
237 query.push_kv("clientToken", &::aws_smithy_http::query::fmt_string(inner_7));
238 }
239 }
240 ::std::result::Result::Ok(())
241 }
242 #[allow(clippy::unnecessary_wraps)]
243 fn update_http_builder(
244 input: &crate::operation::chat::ChatInput,
245 builder: ::http::request::Builder,
246 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
247 let mut uri = ::std::string::String::new();
248 uri_base(input, &mut uri)?;
249 uri_query(input, &mut uri)?;
250 ::std::result::Result::Ok(builder.method("POST").uri(uri))
251 }
252 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
253 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
254 builder
255 };
256 let body = ::aws_smithy_types::body::SdkBody::from({
257 let error_marshaller = crate::event_stream_serde::ChatInputStreamErrorMarshaller::new();
258 let marshaller = crate::event_stream_serde::ChatInputStreamMarshaller::new();
259 let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
260 _cfg.interceptor_state().store_put(signer_sender);
261 ::aws_smithy_types::body::SdkBody::from_body_0_4(::hyper::Body::wrap_stream(input.input_stream.into_body_stream(
262 marshaller,
263 error_marshaller,
264 signer,
265 )))
266 });
267 if let Some(content_length) = body.content_length() {
268 let content_length = content_length.to_string();
269 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
270 }
271 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
272 }
273}
274#[derive(Debug)]
275struct ChatEndpointParamsInterceptor;
276
277impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ChatEndpointParamsInterceptor {
278 fn name(&self) -> &'static str {
279 "ChatEndpointParamsInterceptor"
280 }
281
282 fn read_before_execution(
283 &self,
284 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
285 '_,
286 ::aws_smithy_runtime_api::client::interceptors::context::Input,
287 ::aws_smithy_runtime_api::client::interceptors::context::Output,
288 ::aws_smithy_runtime_api::client::interceptors::context::Error,
289 >,
290 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
291 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
292 let _input = context.input().downcast_ref::<ChatInput>().ok_or("failed to downcast to ChatInput")?;
293
294 let params = crate::config::endpoint::Params::builder()
295 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
296 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
297 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
298 .build()
299 .map_err(|err| {
300 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
301 })?;
302 cfg.interceptor_state()
303 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
304 ::std::result::Result::Ok(())
305 }
306}
307
308#[non_exhaustive]
313#[derive(::std::fmt::Debug)]
314pub enum ChatError {
315 AccessDeniedException(crate::types::error::AccessDeniedException),
317 ConflictException(crate::types::error::ConflictException),
319 ExternalResourceException(crate::types::error::ExternalResourceException),
321 InternalServerException(crate::types::error::InternalServerException),
323 LicenseNotFoundException(crate::types::error::LicenseNotFoundException),
325 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
327 ThrottlingException(crate::types::error::ThrottlingException),
329 ValidationException(crate::types::error::ValidationException),
331 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
333 variable wildcard pattern and check `.code()`:
334 \
335 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
336 \
337 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ChatError) for what information is available for the error.")]
338 Unhandled(crate::error::sealed_unhandled::Unhandled),
339}
340impl ChatError {
341 pub fn unhandled(
343 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
344 ) -> Self {
345 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
346 source: err.into(),
347 meta: ::std::default::Default::default(),
348 })
349 }
350
351 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
353 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
354 source: err.clone().into(),
355 meta: err,
356 })
357 }
358 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
363 match self {
364 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
365 Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
366 Self::ExternalResourceException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
367 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
368 Self::LicenseNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
369 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
370 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
371 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
372 Self::Unhandled(e) => &e.meta,
373 }
374 }
375 pub fn is_access_denied_exception(&self) -> bool {
377 matches!(self, Self::AccessDeniedException(_))
378 }
379 pub fn is_conflict_exception(&self) -> bool {
381 matches!(self, Self::ConflictException(_))
382 }
383 pub fn is_external_resource_exception(&self) -> bool {
385 matches!(self, Self::ExternalResourceException(_))
386 }
387 pub fn is_internal_server_exception(&self) -> bool {
389 matches!(self, Self::InternalServerException(_))
390 }
391 pub fn is_license_not_found_exception(&self) -> bool {
393 matches!(self, Self::LicenseNotFoundException(_))
394 }
395 pub fn is_resource_not_found_exception(&self) -> bool {
397 matches!(self, Self::ResourceNotFoundException(_))
398 }
399 pub fn is_throttling_exception(&self) -> bool {
401 matches!(self, Self::ThrottlingException(_))
402 }
403 pub fn is_validation_exception(&self) -> bool {
405 matches!(self, Self::ValidationException(_))
406 }
407}
408impl ::std::error::Error for ChatError {
409 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
410 match self {
411 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
412 Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
413 Self::ExternalResourceException(_inner) => ::std::option::Option::Some(_inner),
414 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
415 Self::LicenseNotFoundException(_inner) => ::std::option::Option::Some(_inner),
416 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
417 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
418 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
419 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
420 }
421 }
422}
423impl ::std::fmt::Display for ChatError {
424 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
425 match self {
426 Self::AccessDeniedException(_inner) => _inner.fmt(f),
427 Self::ConflictException(_inner) => _inner.fmt(f),
428 Self::ExternalResourceException(_inner) => _inner.fmt(f),
429 Self::InternalServerException(_inner) => _inner.fmt(f),
430 Self::LicenseNotFoundException(_inner) => _inner.fmt(f),
431 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
432 Self::ThrottlingException(_inner) => _inner.fmt(f),
433 Self::ValidationException(_inner) => _inner.fmt(f),
434 Self::Unhandled(_inner) => {
435 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
436 write!(f, "unhandled error ({code})")
437 } else {
438 f.write_str("unhandled error")
439 }
440 }
441 }
442 }
443}
444impl ::aws_smithy_types::retry::ProvideErrorKind for ChatError {
445 fn code(&self) -> ::std::option::Option<&str> {
446 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
447 }
448 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
449 ::std::option::Option::None
450 }
451}
452impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ChatError {
453 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
454 match self {
455 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
456 Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
457 Self::ExternalResourceException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
458 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
459 Self::LicenseNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
460 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
461 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
462 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
463 Self::Unhandled(_inner) => &_inner.meta,
464 }
465 }
466}
467impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ChatError {
468 fn create_unhandled_error(
469 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
470 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
471 ) -> Self {
472 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
473 source,
474 meta: meta.unwrap_or_default(),
475 })
476 }
477}
478impl ::aws_types::request_id::RequestId for crate::operation::chat::ChatError {
479 fn request_id(&self) -> Option<&str> {
480 self.meta().request_id()
481 }
482}
483
484pub use crate::operation::chat::_chat_output::ChatOutput;
485
486pub use crate::operation::chat::_chat_input::ChatInput;
487
488mod _chat_input;
489
490mod _chat_output;
491
492pub mod builders;