aws_sdk_bedrock/operation/update_guardrail/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::update_guardrail::_update_guardrail_output::UpdateGuardrailOutputBuilder;
3
4pub use crate::operation::update_guardrail::_update_guardrail_input::UpdateGuardrailInputBuilder;
5
6impl crate::operation::update_guardrail::builders::UpdateGuardrailInputBuilder {
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::update_guardrail::UpdateGuardrailOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::update_guardrail::UpdateGuardrailError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.update_guardrail();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `UpdateGuardrail`.
24///
25/// <p>Updates a guardrail with the values you specify.</p>
26/// <ul>
27/// <li>
28/// <p>Specify a <code>name</code> and optional <code>description</code>.</p></li>
29/// <li>
30/// <p>Specify messages for when the guardrail successfully blocks a prompt or a model response in the <code>blockedInputMessaging</code> and <code>blockedOutputsMessaging</code> fields.</p></li>
31/// <li>
32/// <p>Specify topics for the guardrail to deny in the <code>topicPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailTopicConfig.html">GuardrailTopicConfig</a> object in the <code>topicsConfig</code> list pertains to one topic.</p>
33/// <ul>
34/// <li>
35/// <p>Give a <code>name</code> and <code>description</code> so that the guardrail can properly identify the topic.</p></li>
36/// <li>
37/// <p>Specify <code>DENY</code> in the <code>type</code> field.</p></li>
38/// <li>
39/// <p>(Optional) Provide up to five prompts that you would categorize as belonging to the topic in the <code>examples</code> list.</p></li>
40/// </ul></li>
41/// <li>
42/// <p>Specify filter strengths for the harmful categories defined in Amazon Bedrock in the <code>contentPolicyConfig</code> object. Each <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a> object in the <code>filtersConfig</code> list pertains to a harmful category. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-content-filters">Content filters</a>. For more information about the fields in a content filter, see <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p>
43/// <ul>
44/// <li>
45/// <p>Specify the category in the <code>type</code> field.</p></li>
46/// <li>
47/// <p>Specify the strength of the filter for prompts in the <code>inputStrength</code> field and for model responses in the <code>strength</code> field of the <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailContentFilterConfig.html">GuardrailContentFilterConfig</a>.</p></li>
48/// </ul></li>
49/// <li>
50/// <p>(Optional) For security, include the ARN of a KMS key in the <code>kmsKeyId</code> field.</p></li>
51/// </ul>
52#[derive(::std::clone::Clone, ::std::fmt::Debug)]
53pub struct UpdateGuardrailFluentBuilder {
54    handle: ::std::sync::Arc<crate::client::Handle>,
55    inner: crate::operation::update_guardrail::builders::UpdateGuardrailInputBuilder,
56    config_override: ::std::option::Option<crate::config::Builder>,
57}
58impl
59    crate::client::customize::internal::CustomizableSend<
60        crate::operation::update_guardrail::UpdateGuardrailOutput,
61        crate::operation::update_guardrail::UpdateGuardrailError,
62    > for UpdateGuardrailFluentBuilder
63{
64    fn send(
65        self,
66        config_override: crate::config::Builder,
67    ) -> crate::client::customize::internal::BoxFuture<
68        crate::client::customize::internal::SendResult<
69            crate::operation::update_guardrail::UpdateGuardrailOutput,
70            crate::operation::update_guardrail::UpdateGuardrailError,
71        >,
72    > {
73        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
74    }
75}
76impl UpdateGuardrailFluentBuilder {
77    /// Creates a new `UpdateGuardrailFluentBuilder`.
78    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
79        Self {
80            handle,
81            inner: ::std::default::Default::default(),
82            config_override: ::std::option::Option::None,
83        }
84    }
85    /// Access the UpdateGuardrail as a reference.
86    pub fn as_input(&self) -> &crate::operation::update_guardrail::builders::UpdateGuardrailInputBuilder {
87        &self.inner
88    }
89    /// Sends the request and returns the response.
90    ///
91    /// If an error occurs, an `SdkError` will be returned with additional details that
92    /// can be matched against.
93    ///
94    /// By default, any retryable failures will be retried twice. Retry behavior
95    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
96    /// set when configuring the client.
97    pub async fn send(
98        self,
99    ) -> ::std::result::Result<
100        crate::operation::update_guardrail::UpdateGuardrailOutput,
101        ::aws_smithy_runtime_api::client::result::SdkError<
102            crate::operation::update_guardrail::UpdateGuardrailError,
103            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
104        >,
105    > {
106        let input = self
107            .inner
108            .build()
109            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
110        let runtime_plugins = crate::operation::update_guardrail::UpdateGuardrail::operation_runtime_plugins(
111            self.handle.runtime_plugins.clone(),
112            &self.handle.conf,
113            self.config_override,
114        );
115        crate::operation::update_guardrail::UpdateGuardrail::orchestrate(&runtime_plugins, input).await
116    }
117
118    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
119    pub fn customize(
120        self,
121    ) -> crate::client::customize::CustomizableOperation<
122        crate::operation::update_guardrail::UpdateGuardrailOutput,
123        crate::operation::update_guardrail::UpdateGuardrailError,
124        Self,
125    > {
126        crate::client::customize::CustomizableOperation::new(self)
127    }
128    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
129        self.set_config_override(::std::option::Option::Some(config_override.into()));
130        self
131    }
132
133    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
134        self.config_override = config_override;
135        self
136    }
137    /// <p>The unique identifier of the guardrail. This can be an ID or the ARN.</p>
138    pub fn guardrail_identifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
139        self.inner = self.inner.guardrail_identifier(input.into());
140        self
141    }
142    /// <p>The unique identifier of the guardrail. This can be an ID or the ARN.</p>
143    pub fn set_guardrail_identifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
144        self.inner = self.inner.set_guardrail_identifier(input);
145        self
146    }
147    /// <p>The unique identifier of the guardrail. This can be an ID or the ARN.</p>
148    pub fn get_guardrail_identifier(&self) -> &::std::option::Option<::std::string::String> {
149        self.inner.get_guardrail_identifier()
150    }
151    /// <p>A name for the guardrail.</p>
152    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
153        self.inner = self.inner.name(input.into());
154        self
155    }
156    /// <p>A name for the guardrail.</p>
157    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
158        self.inner = self.inner.set_name(input);
159        self
160    }
161    /// <p>A name for the guardrail.</p>
162    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
163        self.inner.get_name()
164    }
165    /// <p>A description of the guardrail.</p>
166    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
167        self.inner = self.inner.description(input.into());
168        self
169    }
170    /// <p>A description of the guardrail.</p>
171    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
172        self.inner = self.inner.set_description(input);
173        self
174    }
175    /// <p>A description of the guardrail.</p>
176    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
177        self.inner.get_description()
178    }
179    /// <p>The topic policy to configure for the guardrail.</p>
180    pub fn topic_policy_config(mut self, input: crate::types::GuardrailTopicPolicyConfig) -> Self {
181        self.inner = self.inner.topic_policy_config(input);
182        self
183    }
184    /// <p>The topic policy to configure for the guardrail.</p>
185    pub fn set_topic_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailTopicPolicyConfig>) -> Self {
186        self.inner = self.inner.set_topic_policy_config(input);
187        self
188    }
189    /// <p>The topic policy to configure for the guardrail.</p>
190    pub fn get_topic_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailTopicPolicyConfig> {
191        self.inner.get_topic_policy_config()
192    }
193    /// <p>The content policy to configure for the guardrail.</p>
194    pub fn content_policy_config(mut self, input: crate::types::GuardrailContentPolicyConfig) -> Self {
195        self.inner = self.inner.content_policy_config(input);
196        self
197    }
198    /// <p>The content policy to configure for the guardrail.</p>
199    pub fn set_content_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailContentPolicyConfig>) -> Self {
200        self.inner = self.inner.set_content_policy_config(input);
201        self
202    }
203    /// <p>The content policy to configure for the guardrail.</p>
204    pub fn get_content_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailContentPolicyConfig> {
205        self.inner.get_content_policy_config()
206    }
207    /// <p>The word policy to configure for the guardrail.</p>
208    pub fn word_policy_config(mut self, input: crate::types::GuardrailWordPolicyConfig) -> Self {
209        self.inner = self.inner.word_policy_config(input);
210        self
211    }
212    /// <p>The word policy to configure for the guardrail.</p>
213    pub fn set_word_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailWordPolicyConfig>) -> Self {
214        self.inner = self.inner.set_word_policy_config(input);
215        self
216    }
217    /// <p>The word policy to configure for the guardrail.</p>
218    pub fn get_word_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailWordPolicyConfig> {
219        self.inner.get_word_policy_config()
220    }
221    /// <p>The sensitive information policy to configure for the guardrail.</p>
222    pub fn sensitive_information_policy_config(mut self, input: crate::types::GuardrailSensitiveInformationPolicyConfig) -> Self {
223        self.inner = self.inner.sensitive_information_policy_config(input);
224        self
225    }
226    /// <p>The sensitive information policy to configure for the guardrail.</p>
227    pub fn set_sensitive_information_policy_config(
228        mut self,
229        input: ::std::option::Option<crate::types::GuardrailSensitiveInformationPolicyConfig>,
230    ) -> Self {
231        self.inner = self.inner.set_sensitive_information_policy_config(input);
232        self
233    }
234    /// <p>The sensitive information policy to configure for the guardrail.</p>
235    pub fn get_sensitive_information_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailSensitiveInformationPolicyConfig> {
236        self.inner.get_sensitive_information_policy_config()
237    }
238    /// <p>The contextual grounding policy configuration used to update a guardrail.</p>
239    pub fn contextual_grounding_policy_config(mut self, input: crate::types::GuardrailContextualGroundingPolicyConfig) -> Self {
240        self.inner = self.inner.contextual_grounding_policy_config(input);
241        self
242    }
243    /// <p>The contextual grounding policy configuration used to update a guardrail.</p>
244    pub fn set_contextual_grounding_policy_config(
245        mut self,
246        input: ::std::option::Option<crate::types::GuardrailContextualGroundingPolicyConfig>,
247    ) -> Self {
248        self.inner = self.inner.set_contextual_grounding_policy_config(input);
249        self
250    }
251    /// <p>The contextual grounding policy configuration used to update a guardrail.</p>
252    pub fn get_contextual_grounding_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailContextualGroundingPolicyConfig> {
253        self.inner.get_contextual_grounding_policy_config()
254    }
255    /// <p>Updated configuration for Automated Reasoning policies associated with the guardrail.</p>
256    pub fn automated_reasoning_policy_config(mut self, input: crate::types::GuardrailAutomatedReasoningPolicyConfig) -> Self {
257        self.inner = self.inner.automated_reasoning_policy_config(input);
258        self
259    }
260    /// <p>Updated configuration for Automated Reasoning policies associated with the guardrail.</p>
261    pub fn set_automated_reasoning_policy_config(
262        mut self,
263        input: ::std::option::Option<crate::types::GuardrailAutomatedReasoningPolicyConfig>,
264    ) -> Self {
265        self.inner = self.inner.set_automated_reasoning_policy_config(input);
266        self
267    }
268    /// <p>Updated configuration for Automated Reasoning policies associated with the guardrail.</p>
269    pub fn get_automated_reasoning_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailAutomatedReasoningPolicyConfig> {
270        self.inner.get_automated_reasoning_policy_config()
271    }
272    /// <p>The system-defined guardrail profile that you're using with your guardrail. Guardrail profiles define the destination Amazon Web Services Regions where guardrail inference requests can be automatically routed.</p>
273    /// <p>For more information, see the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html">Amazon Bedrock User Guide</a>.</p>
274    pub fn cross_region_config(mut self, input: crate::types::GuardrailCrossRegionConfig) -> Self {
275        self.inner = self.inner.cross_region_config(input);
276        self
277    }
278    /// <p>The system-defined guardrail profile that you're using with your guardrail. Guardrail profiles define the destination Amazon Web Services Regions where guardrail inference requests can be automatically routed.</p>
279    /// <p>For more information, see the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html">Amazon Bedrock User Guide</a>.</p>
280    pub fn set_cross_region_config(mut self, input: ::std::option::Option<crate::types::GuardrailCrossRegionConfig>) -> Self {
281        self.inner = self.inner.set_cross_region_config(input);
282        self
283    }
284    /// <p>The system-defined guardrail profile that you're using with your guardrail. Guardrail profiles define the destination Amazon Web Services Regions where guardrail inference requests can be automatically routed.</p>
285    /// <p>For more information, see the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html">Amazon Bedrock User Guide</a>.</p>
286    pub fn get_cross_region_config(&self) -> &::std::option::Option<crate::types::GuardrailCrossRegionConfig> {
287        self.inner.get_cross_region_config()
288    }
289    /// <p>The message to return when the guardrail blocks a prompt.</p>
290    pub fn blocked_input_messaging(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
291        self.inner = self.inner.blocked_input_messaging(input.into());
292        self
293    }
294    /// <p>The message to return when the guardrail blocks a prompt.</p>
295    pub fn set_blocked_input_messaging(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
296        self.inner = self.inner.set_blocked_input_messaging(input);
297        self
298    }
299    /// <p>The message to return when the guardrail blocks a prompt.</p>
300    pub fn get_blocked_input_messaging(&self) -> &::std::option::Option<::std::string::String> {
301        self.inner.get_blocked_input_messaging()
302    }
303    /// <p>The message to return when the guardrail blocks a model response.</p>
304    pub fn blocked_outputs_messaging(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
305        self.inner = self.inner.blocked_outputs_messaging(input.into());
306        self
307    }
308    /// <p>The message to return when the guardrail blocks a model response.</p>
309    pub fn set_blocked_outputs_messaging(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
310        self.inner = self.inner.set_blocked_outputs_messaging(input);
311        self
312    }
313    /// <p>The message to return when the guardrail blocks a model response.</p>
314    pub fn get_blocked_outputs_messaging(&self) -> &::std::option::Option<::std::string::String> {
315        self.inner.get_blocked_outputs_messaging()
316    }
317    /// <p>The ARN of the KMS key with which to encrypt the guardrail.</p>
318    pub fn kms_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
319        self.inner = self.inner.kms_key_id(input.into());
320        self
321    }
322    /// <p>The ARN of the KMS key with which to encrypt the guardrail.</p>
323    pub fn set_kms_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
324        self.inner = self.inner.set_kms_key_id(input);
325        self
326    }
327    /// <p>The ARN of the KMS key with which to encrypt the guardrail.</p>
328    pub fn get_kms_key_id(&self) -> &::std::option::Option<::std::string::String> {
329        self.inner.get_kms_key_id()
330    }
331}