aws_sdk_qbusiness/operation/chat/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::chat::_chat_output::ChatOutputBuilder;
3
4pub use crate::operation::chat::_chat_input::ChatInputBuilder;
5
6impl crate::operation::chat::builders::ChatInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::chat::ChatOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::chat::ChatError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.chat();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `Chat`.
24///
25/// <p>Starts or continues a streaming Amazon Q Business conversation.</p>
26#[derive(::std::fmt::Debug)]
27pub struct ChatFluentBuilder {
28    handle: ::std::sync::Arc<crate::client::Handle>,
29    inner: crate::operation::chat::builders::ChatInputBuilder,
30    config_override: ::std::option::Option<crate::config::Builder>,
31}
32impl crate::client::customize::internal::CustomizableSend<crate::operation::chat::ChatOutput, crate::operation::chat::ChatError>
33    for ChatFluentBuilder
34{
35    fn send(
36        self,
37        config_override: crate::config::Builder,
38    ) -> crate::client::customize::internal::BoxFuture<
39        crate::client::customize::internal::SendResult<crate::operation::chat::ChatOutput, crate::operation::chat::ChatError>,
40    > {
41        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
42    }
43}
44impl ChatFluentBuilder {
45    /// Creates a new `ChatFluentBuilder`.
46    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
47        Self {
48            handle,
49            inner: ::std::default::Default::default(),
50            config_override: ::std::option::Option::None,
51        }
52    }
53    /// Access the Chat as a reference.
54    pub fn as_input(&self) -> &crate::operation::chat::builders::ChatInputBuilder {
55        &self.inner
56    }
57    /// Sends the request and returns the response.
58    ///
59    /// If an error occurs, an `SdkError` will be returned with additional details that
60    /// can be matched against.
61    ///
62    /// By default, any retryable failures will be retried twice. Retry behavior
63    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
64    /// set when configuring the client.
65    pub async fn send(
66        self,
67    ) -> ::std::result::Result<
68        crate::operation::chat::ChatOutput,
69        ::aws_smithy_runtime_api::client::result::SdkError<
70            crate::operation::chat::ChatError,
71            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
72        >,
73    > {
74        let input = self
75            .inner
76            .build()
77            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
78        let runtime_plugins =
79            crate::operation::chat::Chat::operation_runtime_plugins(self.handle.runtime_plugins.clone(), &self.handle.conf, self.config_override);
80        let mut output = crate::operation::chat::Chat::orchestrate(&runtime_plugins, input).await?;
81
82        // Converts any error encountered beyond this point into an `SdkError` response error
83        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
84        // function, the original `HttpResponse` is no longer available and cannot be restored.
85        // This means that header information from the original response has been lost.
86        //
87        // Note that the response body would have been consumed by the deserializer
88        // regardless, even if the initial message was hypothetically processed during
89        // the orchestrator's deserialization phase but later resulted in an error.
90        fn response_error(
91            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
92        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
93            crate::operation::chat::ChatError,
94            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
95        > {
96            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
97                err,
98                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
99                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
100                    ::aws_smithy_types::body::SdkBody::empty(),
101                ),
102            )
103        }
104
105        let message = output.output_stream.try_recv_initial_response().await.map_err(response_error)?;
106
107        match message {
108            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
109            ::std::option::Option::None => ::std::result::Result::Ok(output),
110        }
111    }
112
113    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
114    pub fn customize(
115        self,
116    ) -> crate::client::customize::CustomizableOperation<crate::operation::chat::ChatOutput, crate::operation::chat::ChatError, Self> {
117        crate::client::customize::CustomizableOperation::new(self)
118    }
119    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
120        self.set_config_override(::std::option::Option::Some(config_override.into()));
121        self
122    }
123
124    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
125        self.config_override = config_override;
126        self
127    }
128    /// <p>The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.</p>
129    pub fn application_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
130        self.inner = self.inner.application_id(input.into());
131        self
132    }
133    /// <p>The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.</p>
134    pub fn set_application_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
135        self.inner = self.inner.set_application_id(input);
136        self
137    }
138    /// <p>The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.</p>
139    pub fn get_application_id(&self) -> &::std::option::Option<::std::string::String> {
140        self.inner.get_application_id()
141    }
142    /// <p>The identifier of the user attached to the chat input.</p>
143    pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
144        self.inner = self.inner.user_id(input.into());
145        self
146    }
147    /// <p>The identifier of the user attached to the chat input.</p>
148    pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
149        self.inner = self.inner.set_user_id(input);
150        self
151    }
152    /// <p>The identifier of the user attached to the chat input.</p>
153    pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
154        self.inner.get_user_id()
155    }
156    ///
157    /// Appends an item to `userGroups`.
158    ///
159    /// To override the contents of this collection use [`set_user_groups`](Self::set_user_groups).
160    ///
161    /// <p>The group names that a user associated with the chat input belongs to.</p>
162    pub fn user_groups(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
163        self.inner = self.inner.user_groups(input.into());
164        self
165    }
166    /// <p>The group names that a user associated with the chat input belongs to.</p>
167    pub fn set_user_groups(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
168        self.inner = self.inner.set_user_groups(input);
169        self
170    }
171    /// <p>The group names that a user associated with the chat input belongs to.</p>
172    pub fn get_user_groups(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
173        self.inner.get_user_groups()
174    }
175    /// <p>The identifier of the Amazon Q Business conversation.</p>
176    pub fn conversation_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
177        self.inner = self.inner.conversation_id(input.into());
178        self
179    }
180    /// <p>The identifier of the Amazon Q Business conversation.</p>
181    pub fn set_conversation_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
182        self.inner = self.inner.set_conversation_id(input);
183        self
184    }
185    /// <p>The identifier of the Amazon Q Business conversation.</p>
186    pub fn get_conversation_id(&self) -> &::std::option::Option<::std::string::String> {
187        self.inner.get_conversation_id()
188    }
189    /// <p>The identifier used to associate a user message with a AI generated response.</p>
190    pub fn parent_message_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
191        self.inner = self.inner.parent_message_id(input.into());
192        self
193    }
194    /// <p>The identifier used to associate a user message with a AI generated response.</p>
195    pub fn set_parent_message_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
196        self.inner = self.inner.set_parent_message_id(input);
197        self
198    }
199    /// <p>The identifier used to associate a user message with a AI generated response.</p>
200    pub fn get_parent_message_id(&self) -> &::std::option::Option<::std::string::String> {
201        self.inner.get_parent_message_id()
202    }
203    /// <p>A token that you provide to identify the chat input.</p>
204    pub fn client_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
205        self.inner = self.inner.client_token(input.into());
206        self
207    }
208    /// <p>A token that you provide to identify the chat input.</p>
209    pub fn set_client_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
210        self.inner = self.inner.set_client_token(input);
211        self
212    }
213    /// <p>A token that you provide to identify the chat input.</p>
214    pub fn get_client_token(&self) -> &::std::option::Option<::std::string::String> {
215        self.inner.get_client_token()
216    }
217    /// <p>The streaming input for the <code>Chat</code> API.</p>
218    pub fn input_stream(
219        mut self,
220        input: ::aws_smithy_http::event_stream::EventStreamSender<crate::types::ChatInputStream, crate::types::error::ChatInputStreamError>,
221    ) -> Self {
222        self.inner = self.inner.input_stream(input);
223        self
224    }
225    /// <p>The streaming input for the <code>Chat</code> API.</p>
226    pub fn set_input_stream(
227        mut self,
228        input: ::std::option::Option<
229            ::aws_smithy_http::event_stream::EventStreamSender<crate::types::ChatInputStream, crate::types::error::ChatInputStreamError>,
230        >,
231    ) -> Self {
232        self.inner = self.inner.set_input_stream(input);
233        self
234    }
235    /// <p>The streaming input for the <code>Chat</code> API.</p>
236    pub fn get_input_stream(
237        &self,
238    ) -> &::std::option::Option<
239        ::aws_smithy_http::event_stream::EventStreamSender<crate::types::ChatInputStream, crate::types::error::ChatInputStreamError>,
240    > {
241        self.inner.get_input_stream()
242    }
243}