Skip to main content

aws_sdk_devopsagent/operation/send_message/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::send_message::_send_message_input::SendMessageInputBuilder;
3
4pub use crate::operation::send_message::_send_message_output::SendMessageOutputBuilder;
5
6impl crate::operation::send_message::builders::SendMessageInputBuilder {
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::send_message::SendMessageOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::send_message::SendMessageError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.send_message();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `SendMessage`.
24///
25/// Sends a chat message and streams the response for the specified agent space execution
26#[derive(::std::clone::Clone, ::std::fmt::Debug)]
27pub struct SendMessageFluentBuilder {
28    handle: ::std::sync::Arc<crate::client::Handle>,
29    inner: crate::operation::send_message::builders::SendMessageInputBuilder,
30    config_override: ::std::option::Option<crate::config::Builder>,
31}
32impl
33    crate::client::customize::internal::CustomizableSend<
34        crate::operation::send_message::SendMessageOutput,
35        crate::operation::send_message::SendMessageError,
36    > for SendMessageFluentBuilder
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::send_message::SendMessageOutput,
44            crate::operation::send_message::SendMessageError,
45        >,
46    > {
47        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
48    }
49}
50impl SendMessageFluentBuilder {
51    /// Creates a new `SendMessageFluentBuilder`.
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 SendMessage as a reference.
60    pub fn as_input(&self) -> &crate::operation::send_message::builders::SendMessageInputBuilder {
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::send_message::SendMessageOutput,
75        ::aws_smithy_runtime_api::client::result::SdkError<
76            crate::operation::send_message::SendMessageError,
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::send_message::SendMessage::operation_runtime_plugins(
85            self.handle.runtime_plugins.clone(),
86            &self.handle.conf,
87            self.config_override,
88        );
89        let mut output = crate::operation::send_message::SendMessage::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::send_message::SendMessageError,
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.events.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::send_message::SendMessageOutput,
127        crate::operation::send_message::SendMessageError,
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    /// The agent space identifier
142    pub fn agent_space_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
143        self.inner = self.inner.agent_space_id(input.into());
144        self
145    }
146    /// The agent space identifier
147    pub fn set_agent_space_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
148        self.inner = self.inner.set_agent_space_id(input);
149        self
150    }
151    /// The agent space identifier
152    pub fn get_agent_space_id(&self) -> &::std::option::Option<::std::string::String> {
153        self.inner.get_agent_space_id()
154    }
155    /// The execution identifier for the chat session
156    pub fn execution_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
157        self.inner = self.inner.execution_id(input.into());
158        self
159    }
160    /// The execution identifier for the chat session
161    pub fn set_execution_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
162        self.inner = self.inner.set_execution_id(input);
163        self
164    }
165    /// The execution identifier for the chat session
166    pub fn get_execution_id(&self) -> &::std::option::Option<::std::string::String> {
167        self.inner.get_execution_id()
168    }
169    /// The user message content
170    pub fn content(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
171        self.inner = self.inner.content(input.into());
172        self
173    }
174    /// The user message content
175    pub fn set_content(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
176        self.inner = self.inner.set_content(input);
177        self
178    }
179    /// The user message content
180    pub fn get_content(&self) -> &::std::option::Option<::std::string::String> {
181        self.inner.get_content()
182    }
183    /// Optional context for the message
184    pub fn context(mut self, input: crate::types::SendMessageContext) -> Self {
185        self.inner = self.inner.context(input);
186        self
187    }
188    /// Optional context for the message
189    pub fn set_context(mut self, input: ::std::option::Option<crate::types::SendMessageContext>) -> Self {
190        self.inner = self.inner.set_context(input);
191        self
192    }
193    /// Optional context for the message
194    pub fn get_context(&self) -> &::std::option::Option<crate::types::SendMessageContext> {
195        self.inner.get_context()
196    }
197    /// Required user identifier
198    pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
199        self.inner = self.inner.user_id(input.into());
200        self
201    }
202    /// Required user identifier
203    pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
204        self.inner = self.inner.set_user_id(input);
205        self
206    }
207    /// Required user identifier
208    pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
209        self.inner.get_user_id()
210    }
211}