aws_sdk_iotsitewise/operation/invoke_assistant/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::invoke_assistant::_invoke_assistant_output::InvokeAssistantOutputBuilder;
3
4pub use crate::operation::invoke_assistant::_invoke_assistant_input::InvokeAssistantInputBuilder;
5
6impl crate::operation::invoke_assistant::builders::InvokeAssistantInputBuilder {
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::invoke_assistant::InvokeAssistantOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::invoke_assistant::InvokeAssistantError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.invoke_assistant();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `InvokeAssistant`.
24///
25/// <p>Invokes SiteWise Assistant to start or continue a conversation.</p>
26#[derive(::std::clone::Clone, ::std::fmt::Debug)]
27pub struct InvokeAssistantFluentBuilder {
28    handle: ::std::sync::Arc<crate::client::Handle>,
29    inner: crate::operation::invoke_assistant::builders::InvokeAssistantInputBuilder,
30    config_override: ::std::option::Option<crate::config::Builder>,
31}
32impl
33    crate::client::customize::internal::CustomizableSend<
34        crate::operation::invoke_assistant::InvokeAssistantOutput,
35        crate::operation::invoke_assistant::InvokeAssistantError,
36    > for InvokeAssistantFluentBuilder
37{
38    fn send(
39        self,
40        config_override: crate::config::Builder,
41    ) -> crate::client::customize::internal::BoxFuture<
42        crate::client::customize::internal::SendResult<
43            crate::operation::invoke_assistant::InvokeAssistantOutput,
44            crate::operation::invoke_assistant::InvokeAssistantError,
45        >,
46    > {
47        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
48    }
49}
50impl InvokeAssistantFluentBuilder {
51    /// Creates a new `InvokeAssistantFluentBuilder`.
52    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
53        Self {
54            handle,
55            inner: ::std::default::Default::default(),
56            config_override: ::std::option::Option::None,
57        }
58    }
59    /// Access the InvokeAssistant as a reference.
60    pub fn as_input(&self) -> &crate::operation::invoke_assistant::builders::InvokeAssistantInputBuilder {
61        &self.inner
62    }
63    /// Sends the request and returns the response.
64    ///
65    /// If an error occurs, an `SdkError` will be returned with additional details that
66    /// can be matched against.
67    ///
68    /// By default, any retryable failures will be retried twice. Retry behavior
69    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
70    /// set when configuring the client.
71    pub async fn send(
72        self,
73    ) -> ::std::result::Result<
74        crate::operation::invoke_assistant::InvokeAssistantOutput,
75        ::aws_smithy_runtime_api::client::result::SdkError<
76            crate::operation::invoke_assistant::InvokeAssistantError,
77            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
78        >,
79    > {
80        let input = self
81            .inner
82            .build()
83            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
84        let runtime_plugins = crate::operation::invoke_assistant::InvokeAssistant::operation_runtime_plugins(
85            self.handle.runtime_plugins.clone(),
86            &self.handle.conf,
87            self.config_override,
88        );
89        let mut output = crate::operation::invoke_assistant::InvokeAssistant::orchestrate(&runtime_plugins, input).await?;
90
91        // Converts any error encountered beyond this point into an `SdkError` response error
92        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
93        // function, the original `HttpResponse` is no longer available and cannot be restored.
94        // This means that header information from the original response has been lost.
95        //
96        // Note that the response body would have been consumed by the deserializer
97        // regardless, even if the initial message was hypothetically processed during
98        // the orchestrator's deserialization phase but later resulted in an error.
99        fn response_error(
100            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
101        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
102            crate::operation::invoke_assistant::InvokeAssistantError,
103            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
104        > {
105            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
106                err,
107                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
108                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
109                    ::aws_smithy_types::body::SdkBody::empty(),
110                ),
111            )
112        }
113
114        let message = output.body.try_recv_initial_response().await.map_err(response_error)?;
115
116        match message {
117            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
118            ::std::option::Option::None => ::std::result::Result::Ok(output),
119        }
120    }
121
122    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
123    pub fn customize(
124        self,
125    ) -> crate::client::customize::CustomizableOperation<
126        crate::operation::invoke_assistant::InvokeAssistantOutput,
127        crate::operation::invoke_assistant::InvokeAssistantError,
128        Self,
129    > {
130        crate::client::customize::CustomizableOperation::new(self)
131    }
132    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
133        self.set_config_override(::std::option::Option::Some(config_override.into()));
134        self
135    }
136
137    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
138        self.config_override = config_override;
139        self
140    }
141    /// <p>The ID assigned to a conversation. IoT SiteWise automatically generates a unique ID for you, and this parameter is never required. However, if you prefer to have your own ID, you must specify it here in UUID format. If you specify your own ID, it must be globally unique.</p>
142    pub fn conversation_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
143        self.inner = self.inner.conversation_id(input.into());
144        self
145    }
146    /// <p>The ID assigned to a conversation. IoT SiteWise automatically generates a unique ID for you, and this parameter is never required. However, if you prefer to have your own ID, you must specify it here in UUID format. If you specify your own ID, it must be globally unique.</p>
147    pub fn set_conversation_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
148        self.inner = self.inner.set_conversation_id(input);
149        self
150    }
151    /// <p>The ID assigned to a conversation. IoT SiteWise automatically generates a unique ID for you, and this parameter is never required. However, if you prefer to have your own ID, you must specify it here in UUID format. If you specify your own ID, it must be globally unique.</p>
152    pub fn get_conversation_id(&self) -> &::std::option::Option<::std::string::String> {
153        self.inner.get_conversation_id()
154    }
155    /// <p>A text message sent to the SiteWise Assistant by the user.</p>
156    pub fn message(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
157        self.inner = self.inner.message(input.into());
158        self
159    }
160    /// <p>A text message sent to the SiteWise Assistant by the user.</p>
161    pub fn set_message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
162        self.inner = self.inner.set_message(input);
163        self
164    }
165    /// <p>A text message sent to the SiteWise Assistant by the user.</p>
166    pub fn get_message(&self) -> &::std::option::Option<::std::string::String> {
167        self.inner.get_message()
168    }
169    /// <p>Specifies if to turn trace on or not. It is used to track the SiteWise Assistant's reasoning, and data access process.</p>
170    pub fn enable_trace(mut self, input: bool) -> Self {
171        self.inner = self.inner.enable_trace(input);
172        self
173    }
174    /// <p>Specifies if to turn trace on or not. It is used to track the SiteWise Assistant's reasoning, and data access process.</p>
175    pub fn set_enable_trace(mut self, input: ::std::option::Option<bool>) -> Self {
176        self.inner = self.inner.set_enable_trace(input);
177        self
178    }
179    /// <p>Specifies if to turn trace on or not. It is used to track the SiteWise Assistant's reasoning, and data access process.</p>
180    pub fn get_enable_trace(&self) -> &::std::option::Option<bool> {
181        self.inner.get_enable_trace()
182    }
183}