aws_sdk_bedrockagentruntime/operation/invoke_flow/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::invoke_flow::_invoke_flow_output::InvokeFlowOutputBuilder;
3
4pub use crate::operation::invoke_flow::_invoke_flow_input::InvokeFlowInputBuilder;
5
6impl crate::operation::invoke_flow::builders::InvokeFlowInputBuilder {
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_flow::InvokeFlowOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::invoke_flow::InvokeFlowError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.invoke_flow();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `InvokeFlow`.
24///
25/// <p>Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there's an error, the error is returned. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-test.html">Test a flow in Amazon Bedrock</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p><note>
26/// <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeFlow</code>.</p>
27/// </note>
28#[derive(::std::clone::Clone, ::std::fmt::Debug)]
29pub struct InvokeFlowFluentBuilder {
30    handle: ::std::sync::Arc<crate::client::Handle>,
31    inner: crate::operation::invoke_flow::builders::InvokeFlowInputBuilder,
32    config_override: ::std::option::Option<crate::config::Builder>,
33}
34impl
35    crate::client::customize::internal::CustomizableSend<
36        crate::operation::invoke_flow::InvokeFlowOutput,
37        crate::operation::invoke_flow::InvokeFlowError,
38    > for InvokeFlowFluentBuilder
39{
40    fn send(
41        self,
42        config_override: crate::config::Builder,
43    ) -> crate::client::customize::internal::BoxFuture<
44        crate::client::customize::internal::SendResult<
45            crate::operation::invoke_flow::InvokeFlowOutput,
46            crate::operation::invoke_flow::InvokeFlowError,
47        >,
48    > {
49        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
50    }
51}
52impl InvokeFlowFluentBuilder {
53    /// Creates a new `InvokeFlowFluentBuilder`.
54    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
55        Self {
56            handle,
57            inner: ::std::default::Default::default(),
58            config_override: ::std::option::Option::None,
59        }
60    }
61    /// Access the InvokeFlow as a reference.
62    pub fn as_input(&self) -> &crate::operation::invoke_flow::builders::InvokeFlowInputBuilder {
63        &self.inner
64    }
65    /// Sends the request and returns the response.
66    ///
67    /// If an error occurs, an `SdkError` will be returned with additional details that
68    /// can be matched against.
69    ///
70    /// By default, any retryable failures will be retried twice. Retry behavior
71    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
72    /// set when configuring the client.
73    pub async fn send(
74        self,
75    ) -> ::std::result::Result<
76        crate::operation::invoke_flow::InvokeFlowOutput,
77        ::aws_smithy_runtime_api::client::result::SdkError<
78            crate::operation::invoke_flow::InvokeFlowError,
79            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
80        >,
81    > {
82        let input = self
83            .inner
84            .build()
85            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
86        let runtime_plugins = crate::operation::invoke_flow::InvokeFlow::operation_runtime_plugins(
87            self.handle.runtime_plugins.clone(),
88            &self.handle.conf,
89            self.config_override,
90        );
91        let mut output = crate::operation::invoke_flow::InvokeFlow::orchestrate(&runtime_plugins, input).await?;
92
93        // Converts any error encountered beyond this point into an `SdkError` response error
94        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
95        // function, the original `HttpResponse` is no longer available and cannot be restored.
96        // This means that header information from the original response has been lost.
97        //
98        // Note that the response body would have been consumed by the deserializer
99        // regardless, even if the initial message was hypothetically processed during
100        // the orchestrator's deserialization phase but later resulted in an error.
101        fn response_error(
102            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
103        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
104            crate::operation::invoke_flow::InvokeFlowError,
105            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
106        > {
107            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
108                err,
109                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
110                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
111                    ::aws_smithy_types::body::SdkBody::empty(),
112                ),
113            )
114        }
115
116        let message = output.response_stream.try_recv_initial_response().await.map_err(response_error)?;
117
118        match message {
119            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
120            ::std::option::Option::None => ::std::result::Result::Ok(output),
121        }
122    }
123
124    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
125    pub fn customize(
126        self,
127    ) -> crate::client::customize::CustomizableOperation<
128        crate::operation::invoke_flow::InvokeFlowOutput,
129        crate::operation::invoke_flow::InvokeFlowError,
130        Self,
131    > {
132        crate::client::customize::CustomizableOperation::new(self)
133    }
134    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
135        self.set_config_override(::std::option::Option::Some(config_override.into()));
136        self
137    }
138
139    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
140        self.config_override = config_override;
141        self
142    }
143    /// <p>The unique identifier of the flow.</p>
144    pub fn flow_identifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
145        self.inner = self.inner.flow_identifier(input.into());
146        self
147    }
148    /// <p>The unique identifier of the flow.</p>
149    pub fn set_flow_identifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
150        self.inner = self.inner.set_flow_identifier(input);
151        self
152    }
153    /// <p>The unique identifier of the flow.</p>
154    pub fn get_flow_identifier(&self) -> &::std::option::Option<::std::string::String> {
155        self.inner.get_flow_identifier()
156    }
157    /// <p>The unique identifier of the flow alias.</p>
158    pub fn flow_alias_identifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
159        self.inner = self.inner.flow_alias_identifier(input.into());
160        self
161    }
162    /// <p>The unique identifier of the flow alias.</p>
163    pub fn set_flow_alias_identifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
164        self.inner = self.inner.set_flow_alias_identifier(input);
165        self
166    }
167    /// <p>The unique identifier of the flow alias.</p>
168    pub fn get_flow_alias_identifier(&self) -> &::std::option::Option<::std::string::String> {
169        self.inner.get_flow_alias_identifier()
170    }
171    ///
172    /// Appends an item to `inputs`.
173    ///
174    /// To override the contents of this collection use [`set_inputs`](Self::set_inputs).
175    ///
176    /// <p>A list of objects, each containing information about an input into the flow.</p>
177    pub fn inputs(mut self, input: crate::types::FlowInput) -> Self {
178        self.inner = self.inner.inputs(input);
179        self
180    }
181    /// <p>A list of objects, each containing information about an input into the flow.</p>
182    pub fn set_inputs(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::FlowInput>>) -> Self {
183        self.inner = self.inner.set_inputs(input);
184        self
185    }
186    /// <p>A list of objects, each containing information about an input into the flow.</p>
187    pub fn get_inputs(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::FlowInput>> {
188        self.inner.get_inputs()
189    }
190    /// <p>Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html">Track each step in your prompt flow by viewing its trace in Amazon Bedrock</a>.</p>
191    pub fn enable_trace(mut self, input: bool) -> Self {
192        self.inner = self.inner.enable_trace(input);
193        self
194    }
195    /// <p>Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html">Track each step in your prompt flow by viewing its trace in Amazon Bedrock</a>.</p>
196    pub fn set_enable_trace(mut self, input: ::std::option::Option<bool>) -> Self {
197        self.inner = self.inner.set_enable_trace(input);
198        self
199    }
200    /// <p>Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html">Track each step in your prompt flow by viewing its trace in Amazon Bedrock</a>.</p>
201    pub fn get_enable_trace(&self) -> &::std::option::Option<bool> {
202        self.inner.get_enable_trace()
203    }
204    /// <p>Model performance settings for the request.</p>
205    pub fn model_performance_configuration(mut self, input: crate::types::ModelPerformanceConfiguration) -> Self {
206        self.inner = self.inner.model_performance_configuration(input);
207        self
208    }
209    /// <p>Model performance settings for the request.</p>
210    pub fn set_model_performance_configuration(mut self, input: ::std::option::Option<crate::types::ModelPerformanceConfiguration>) -> Self {
211        self.inner = self.inner.set_model_performance_configuration(input);
212        self
213    }
214    /// <p>Model performance settings for the request.</p>
215    pub fn get_model_performance_configuration(&self) -> &::std::option::Option<crate::types::ModelPerformanceConfiguration> {
216        self.inner.get_model_performance_configuration()
217    }
218    /// <p>The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.</p>
219    pub fn execution_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
220        self.inner = self.inner.execution_id(input.into());
221        self
222    }
223    /// <p>The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.</p>
224    pub fn set_execution_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
225        self.inner = self.inner.set_execution_id(input);
226        self
227    }
228    /// <p>The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.</p>
229    pub fn get_execution_id(&self) -> &::std::option::Option<::std::string::String> {
230        self.inner.get_execution_id()
231    }
232}