aws_sdk_bedrockagent/operation/create_knowledge_base/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_knowledge_base::_create_knowledge_base_output::CreateKnowledgeBaseOutputBuilder;
3
4pub use crate::operation::create_knowledge_base::_create_knowledge_base_input::CreateKnowledgeBaseInputBuilder;
5
6impl crate::operation::create_knowledge_base::builders::CreateKnowledgeBaseInputBuilder {
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::create_knowledge_base::CreateKnowledgeBaseOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_knowledge_base::CreateKnowledgeBaseError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_knowledge_base();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateKnowledgeBase`.
24///
25/// <p>Creates a knowledge base. A knowledge base contains your data sources so that Large Language Models (LLMs) can use your data. To create a knowledge base, you must first set up your data sources and configure a supported vector store. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowlege-base-prereq.html">Set up a knowledge base</a>.</p><note>
26/// <p>If you prefer to let Amazon Bedrock create and manage a vector store for you in Amazon OpenSearch Service, use the console. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-create">Create a knowledge base</a>.</p>
27/// </note>
28/// <ul>
29/// <li>
30/// <p>Provide the <code>name</code> and an optional <code>description</code>.</p></li>
31/// <li>
32/// <p>Provide the Amazon Resource Name (ARN) with permissions to create a knowledge base in the <code>roleArn</code> field.</p></li>
33/// <li>
34/// <p>Provide the embedding model to use in the <code>embeddingModelArn</code> field in the <code>knowledgeBaseConfiguration</code> object.</p></li>
35/// <li>
36/// <p>Provide the configuration for your vector store in the <code>storageConfiguration</code> object.</p>
37/// <ul>
38/// <li>
39/// <p>For an Amazon OpenSearch Service database, use the <code>opensearchServerlessConfiguration</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-oss.html">Create a vector store in Amazon OpenSearch Service</a>.</p></li>
40/// <li>
41/// <p>For an Amazon Aurora database, use the <code>RdsConfiguration</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-rds.html">Create a vector store in Amazon Aurora</a>.</p></li>
42/// <li>
43/// <p>For a Pinecone database, use the <code>pineconeConfiguration</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-pinecone.html">Create a vector store in Pinecone</a>.</p></li>
44/// <li>
45/// <p>For a Redis Enterprise Cloud database, use the <code>redisEnterpriseCloudConfiguration</code> object. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-redis.html">Create a vector store in Redis Enterprise Cloud</a>.</p></li>
46/// </ul></li>
47/// </ul>
48#[derive(::std::clone::Clone, ::std::fmt::Debug)]
49pub struct CreateKnowledgeBaseFluentBuilder {
50    handle: ::std::sync::Arc<crate::client::Handle>,
51    inner: crate::operation::create_knowledge_base::builders::CreateKnowledgeBaseInputBuilder,
52    config_override: ::std::option::Option<crate::config::Builder>,
53}
54impl
55    crate::client::customize::internal::CustomizableSend<
56        crate::operation::create_knowledge_base::CreateKnowledgeBaseOutput,
57        crate::operation::create_knowledge_base::CreateKnowledgeBaseError,
58    > for CreateKnowledgeBaseFluentBuilder
59{
60    fn send(
61        self,
62        config_override: crate::config::Builder,
63    ) -> crate::client::customize::internal::BoxFuture<
64        crate::client::customize::internal::SendResult<
65            crate::operation::create_knowledge_base::CreateKnowledgeBaseOutput,
66            crate::operation::create_knowledge_base::CreateKnowledgeBaseError,
67        >,
68    > {
69        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
70    }
71}
72impl CreateKnowledgeBaseFluentBuilder {
73    /// Creates a new `CreateKnowledgeBaseFluentBuilder`.
74    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
75        Self {
76            handle,
77            inner: ::std::default::Default::default(),
78            config_override: ::std::option::Option::None,
79        }
80    }
81    /// Access the CreateKnowledgeBase as a reference.
82    pub fn as_input(&self) -> &crate::operation::create_knowledge_base::builders::CreateKnowledgeBaseInputBuilder {
83        &self.inner
84    }
85    /// Sends the request and returns the response.
86    ///
87    /// If an error occurs, an `SdkError` will be returned with additional details that
88    /// can be matched against.
89    ///
90    /// By default, any retryable failures will be retried twice. Retry behavior
91    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
92    /// set when configuring the client.
93    pub async fn send(
94        self,
95    ) -> ::std::result::Result<
96        crate::operation::create_knowledge_base::CreateKnowledgeBaseOutput,
97        ::aws_smithy_runtime_api::client::result::SdkError<
98            crate::operation::create_knowledge_base::CreateKnowledgeBaseError,
99            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
100        >,
101    > {
102        let input = self
103            .inner
104            .build()
105            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
106        let runtime_plugins = crate::operation::create_knowledge_base::CreateKnowledgeBase::operation_runtime_plugins(
107            self.handle.runtime_plugins.clone(),
108            &self.handle.conf,
109            self.config_override,
110        );
111        crate::operation::create_knowledge_base::CreateKnowledgeBase::orchestrate(&runtime_plugins, input).await
112    }
113
114    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
115    pub fn customize(
116        self,
117    ) -> crate::client::customize::CustomizableOperation<
118        crate::operation::create_knowledge_base::CreateKnowledgeBaseOutput,
119        crate::operation::create_knowledge_base::CreateKnowledgeBaseError,
120        Self,
121    > {
122        crate::client::customize::CustomizableOperation::new(self)
123    }
124    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
125        self.set_config_override(::std::option::Option::Some(config_override.into()));
126        self
127    }
128
129    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
130        self.config_override = config_override;
131        self
132    }
133    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
134    pub fn client_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
135        self.inner = self.inner.client_token(input.into());
136        self
137    }
138    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
139    pub fn set_client_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
140        self.inner = self.inner.set_client_token(input);
141        self
142    }
143    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
144    pub fn get_client_token(&self) -> &::std::option::Option<::std::string::String> {
145        self.inner.get_client_token()
146    }
147    /// <p>A name for the knowledge base.</p>
148    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
149        self.inner = self.inner.name(input.into());
150        self
151    }
152    /// <p>A name for the knowledge base.</p>
153    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
154        self.inner = self.inner.set_name(input);
155        self
156    }
157    /// <p>A name for the knowledge base.</p>
158    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
159        self.inner.get_name()
160    }
161    /// <p>A description of the knowledge base.</p>
162    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
163        self.inner = self.inner.description(input.into());
164        self
165    }
166    /// <p>A description of the knowledge base.</p>
167    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
168        self.inner = self.inner.set_description(input);
169        self
170    }
171    /// <p>A description of the knowledge base.</p>
172    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
173        self.inner.get_description()
174    }
175    /// <p>The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.</p>
176    pub fn role_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
177        self.inner = self.inner.role_arn(input.into());
178        self
179    }
180    /// <p>The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.</p>
181    pub fn set_role_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
182        self.inner = self.inner.set_role_arn(input);
183        self
184    }
185    /// <p>The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.</p>
186    pub fn get_role_arn(&self) -> &::std::option::Option<::std::string::String> {
187        self.inner.get_role_arn()
188    }
189    /// <p>Contains details about the embeddings model used for the knowledge base.</p>
190    pub fn knowledge_base_configuration(mut self, input: crate::types::KnowledgeBaseConfiguration) -> Self {
191        self.inner = self.inner.knowledge_base_configuration(input);
192        self
193    }
194    /// <p>Contains details about the embeddings model used for the knowledge base.</p>
195    pub fn set_knowledge_base_configuration(mut self, input: ::std::option::Option<crate::types::KnowledgeBaseConfiguration>) -> Self {
196        self.inner = self.inner.set_knowledge_base_configuration(input);
197        self
198    }
199    /// <p>Contains details about the embeddings model used for the knowledge base.</p>
200    pub fn get_knowledge_base_configuration(&self) -> &::std::option::Option<crate::types::KnowledgeBaseConfiguration> {
201        self.inner.get_knowledge_base_configuration()
202    }
203    /// <p>Contains details about the configuration of the vector database used for the knowledge base.</p>
204    pub fn storage_configuration(mut self, input: crate::types::StorageConfiguration) -> Self {
205        self.inner = self.inner.storage_configuration(input);
206        self
207    }
208    /// <p>Contains details about the configuration of the vector database used for the knowledge base.</p>
209    pub fn set_storage_configuration(mut self, input: ::std::option::Option<crate::types::StorageConfiguration>) -> Self {
210        self.inner = self.inner.set_storage_configuration(input);
211        self
212    }
213    /// <p>Contains details about the configuration of the vector database used for the knowledge base.</p>
214    pub fn get_storage_configuration(&self) -> &::std::option::Option<crate::types::StorageConfiguration> {
215        self.inner.get_storage_configuration()
216    }
217    ///
218    /// Adds a key-value pair to `tags`.
219    ///
220    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
221    ///
222    /// <p>Specify the key-value pairs for the tags that you want to attach to your knowledge base in this object.</p>
223    pub fn tags(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
224        self.inner = self.inner.tags(k.into(), v.into());
225        self
226    }
227    /// <p>Specify the key-value pairs for the tags that you want to attach to your knowledge base in this object.</p>
228    pub fn set_tags(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
229        self.inner = self.inner.set_tags(input);
230        self
231    }
232    /// <p>Specify the key-value pairs for the tags that you want to attach to your knowledge base in this object.</p>
233    pub fn get_tags(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
234        self.inner.get_tags()
235    }
236}