aws-sdk-bedrock 1.129.0

AWS SDK for Amazon Bedrock
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::create_guardrail::_create_guardrail_output::CreateGuardrailOutputBuilder;

pub use crate::operation::create_guardrail::_create_guardrail_input::CreateGuardrailInputBuilder;

impl crate::operation::create_guardrail::builders::CreateGuardrailInputBuilder {
    /// Sends a request with this input using the given client.
    pub async fn send_with(
        self,
        client: &crate::Client,
    ) -> ::std::result::Result<
        crate::operation::create_guardrail::CreateGuardrailOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::create_guardrail::CreateGuardrailError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.create_guardrail();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `CreateGuardrail`.
///
/// <p>Creates a guardrail to block topics and to implement safeguards for your generative AI applications.</p>
/// <p>You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter out denied topics and words, and remove sensitive information for privacy protection.</p>
/// <ul>
/// <li>
/// <p><b>Content filters</b> - Adjust filter strengths to block input prompts or model responses containing harmful content.</p></li>
/// <li>
/// <p><b>Denied topics</b> - Define a set of topics that are undesirable in the context of your application. These topics will be blocked if detected in user queries or model responses.</p></li>
/// <li>
/// <p><b>Word filters</b> - Configure filters to block undesirable words, phrases, and profanity. Such words can include offensive terms, competitor names etc.</p></li>
/// <li>
/// <p><b>Sensitive information filters</b> - Block or mask sensitive information such as personally identifiable information (PII) or custom regex in user inputs and model responses.</p></li>
/// </ul>
/// <p>In addition to the above policies, you can also configure the messages to be returned to the user if a user input or model response is in violation of the policies defined in the guardrail.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html">Amazon Bedrock Guardrails</a> in the <i>Amazon Bedrock User Guide</i>.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct CreateGuardrailFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::create_guardrail::builders::CreateGuardrailInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::create_guardrail::CreateGuardrailOutput,
        crate::operation::create_guardrail::CreateGuardrailError,
    > for CreateGuardrailFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::create_guardrail::CreateGuardrailOutput,
            crate::operation::create_guardrail::CreateGuardrailError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl CreateGuardrailFluentBuilder {
    /// Creates a new `CreateGuardrailFluentBuilder`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
            config_override: ::std::option::Option::None,
        }
    }
    /// Access the CreateGuardrail as a reference.
    pub fn as_input(&self) -> &crate::operation::create_guardrail::builders::CreateGuardrailInputBuilder {
        &self.inner
    }
    /// Sends the request and returns the response.
    ///
    /// If an error occurs, an `SdkError` will be returned with additional details that
    /// can be matched against.
    ///
    /// By default, any retryable failures will be retried twice. Retry behavior
    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
    /// set when configuring the client.
    pub async fn send(
        self,
    ) -> ::std::result::Result<
        crate::operation::create_guardrail::CreateGuardrailOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::create_guardrail::CreateGuardrailError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let input = self
            .inner
            .build()
            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
        let runtime_plugins = crate::operation::create_guardrail::CreateGuardrail::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        crate::operation::create_guardrail::CreateGuardrail::orchestrate(&runtime_plugins, input).await
    }

    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
    pub fn customize(
        self,
    ) -> crate::client::customize::CustomizableOperation<
        crate::operation::create_guardrail::CreateGuardrailOutput,
        crate::operation::create_guardrail::CreateGuardrailError,
        Self,
    > {
        crate::client::customize::CustomizableOperation::new(self)
    }
    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
        self.set_config_override(::std::option::Option::Some(config_override.into()));
        self
    }

    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
        self.config_override = config_override;
        self
    }
    /// <p>The name to give the guardrail.</p>
    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.name(input.into());
        self
    }
    /// <p>The name to give the guardrail.</p>
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_name(input);
        self
    }
    /// <p>The name to give the guardrail.</p>
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_name()
    }
    /// <p>A description of the guardrail.</p>
    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.description(input.into());
        self
    }
    /// <p>A description of the guardrail.</p>
    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_description(input);
        self
    }
    /// <p>A description of the guardrail.</p>
    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_description()
    }
    /// <p>The topic policies to configure for the guardrail.</p>
    pub fn topic_policy_config(mut self, input: crate::types::GuardrailTopicPolicyConfig) -> Self {
        self.inner = self.inner.topic_policy_config(input);
        self
    }
    /// <p>The topic policies to configure for the guardrail.</p>
    pub fn set_topic_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailTopicPolicyConfig>) -> Self {
        self.inner = self.inner.set_topic_policy_config(input);
        self
    }
    /// <p>The topic policies to configure for the guardrail.</p>
    pub fn get_topic_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailTopicPolicyConfig> {
        self.inner.get_topic_policy_config()
    }
    /// <p>The content filter policies to configure for the guardrail.</p>
    pub fn content_policy_config(mut self, input: crate::types::GuardrailContentPolicyConfig) -> Self {
        self.inner = self.inner.content_policy_config(input);
        self
    }
    /// <p>The content filter policies to configure for the guardrail.</p>
    pub fn set_content_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailContentPolicyConfig>) -> Self {
        self.inner = self.inner.set_content_policy_config(input);
        self
    }
    /// <p>The content filter policies to configure for the guardrail.</p>
    pub fn get_content_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailContentPolicyConfig> {
        self.inner.get_content_policy_config()
    }
    /// <p>The word policy you configure for the guardrail.</p>
    pub fn word_policy_config(mut self, input: crate::types::GuardrailWordPolicyConfig) -> Self {
        self.inner = self.inner.word_policy_config(input);
        self
    }
    /// <p>The word policy you configure for the guardrail.</p>
    pub fn set_word_policy_config(mut self, input: ::std::option::Option<crate::types::GuardrailWordPolicyConfig>) -> Self {
        self.inner = self.inner.set_word_policy_config(input);
        self
    }
    /// <p>The word policy you configure for the guardrail.</p>
    pub fn get_word_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailWordPolicyConfig> {
        self.inner.get_word_policy_config()
    }
    /// <p>The sensitive information policy to configure for the guardrail.</p>
    pub fn sensitive_information_policy_config(mut self, input: crate::types::GuardrailSensitiveInformationPolicyConfig) -> Self {
        self.inner = self.inner.sensitive_information_policy_config(input);
        self
    }
    /// <p>The sensitive information policy to configure for the guardrail.</p>
    pub fn set_sensitive_information_policy_config(
        mut self,
        input: ::std::option::Option<crate::types::GuardrailSensitiveInformationPolicyConfig>,
    ) -> Self {
        self.inner = self.inner.set_sensitive_information_policy_config(input);
        self
    }
    /// <p>The sensitive information policy to configure for the guardrail.</p>
    pub fn get_sensitive_information_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailSensitiveInformationPolicyConfig> {
        self.inner.get_sensitive_information_policy_config()
    }
    /// <p>The contextual grounding policy configuration used to create a guardrail.</p>
    pub fn contextual_grounding_policy_config(mut self, input: crate::types::GuardrailContextualGroundingPolicyConfig) -> Self {
        self.inner = self.inner.contextual_grounding_policy_config(input);
        self
    }
    /// <p>The contextual grounding policy configuration used to create a guardrail.</p>
    pub fn set_contextual_grounding_policy_config(
        mut self,
        input: ::std::option::Option<crate::types::GuardrailContextualGroundingPolicyConfig>,
    ) -> Self {
        self.inner = self.inner.set_contextual_grounding_policy_config(input);
        self
    }
    /// <p>The contextual grounding policy configuration used to create a guardrail.</p>
    pub fn get_contextual_grounding_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailContextualGroundingPolicyConfig> {
        self.inner.get_contextual_grounding_policy_config()
    }
    /// <p>Optional configuration for integrating Automated Reasoning policies with the new guardrail.</p>
    pub fn automated_reasoning_policy_config(mut self, input: crate::types::GuardrailAutomatedReasoningPolicyConfig) -> Self {
        self.inner = self.inner.automated_reasoning_policy_config(input);
        self
    }
    /// <p>Optional configuration for integrating Automated Reasoning policies with the new guardrail.</p>
    pub fn set_automated_reasoning_policy_config(
        mut self,
        input: ::std::option::Option<crate::types::GuardrailAutomatedReasoningPolicyConfig>,
    ) -> Self {
        self.inner = self.inner.set_automated_reasoning_policy_config(input);
        self
    }
    /// <p>Optional configuration for integrating Automated Reasoning policies with the new guardrail.</p>
    pub fn get_automated_reasoning_policy_config(&self) -> &::std::option::Option<crate::types::GuardrailAutomatedReasoningPolicyConfig> {
        self.inner.get_automated_reasoning_policy_config()
    }
    /// <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>
    /// <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>
    pub fn cross_region_config(mut self, input: crate::types::GuardrailCrossRegionConfig) -> Self {
        self.inner = self.inner.cross_region_config(input);
        self
    }
    /// <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>
    /// <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>
    pub fn set_cross_region_config(mut self, input: ::std::option::Option<crate::types::GuardrailCrossRegionConfig>) -> Self {
        self.inner = self.inner.set_cross_region_config(input);
        self
    }
    /// <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>
    /// <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>
    pub fn get_cross_region_config(&self) -> &::std::option::Option<crate::types::GuardrailCrossRegionConfig> {
        self.inner.get_cross_region_config()
    }
    /// <p>The message to return when the guardrail blocks a prompt.</p>
    pub fn blocked_input_messaging(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.blocked_input_messaging(input.into());
        self
    }
    /// <p>The message to return when the guardrail blocks a prompt.</p>
    pub fn set_blocked_input_messaging(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_blocked_input_messaging(input);
        self
    }
    /// <p>The message to return when the guardrail blocks a prompt.</p>
    pub fn get_blocked_input_messaging(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_blocked_input_messaging()
    }
    /// <p>The message to return when the guardrail blocks a model response.</p>
    pub fn blocked_outputs_messaging(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.blocked_outputs_messaging(input.into());
        self
    }
    /// <p>The message to return when the guardrail blocks a model response.</p>
    pub fn set_blocked_outputs_messaging(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_blocked_outputs_messaging(input);
        self
    }
    /// <p>The message to return when the guardrail blocks a model response.</p>
    pub fn get_blocked_outputs_messaging(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_blocked_outputs_messaging()
    }
    /// <p>The ARN of the KMS key that you use to encrypt the guardrail.</p>
    pub fn kms_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.kms_key_id(input.into());
        self
    }
    /// <p>The ARN of the KMS key that you use to encrypt the guardrail.</p>
    pub fn set_kms_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_kms_key_id(input);
        self
    }
    /// <p>The ARN of the KMS key that you use to encrypt the guardrail.</p>
    pub fn get_kms_key_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_kms_key_id()
    }
    ///
    /// Appends an item to `tags`.
    ///
    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
    ///
    /// <p>The tags that you want to attach to the guardrail.</p>
    pub fn tags(mut self, input: crate::types::Tag) -> Self {
        self.inner = self.inner.tags(input);
        self
    }
    /// <p>The tags that you want to attach to the guardrail.</p>
    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
        self.inner = self.inner.set_tags(input);
        self
    }
    /// <p>The tags that you want to attach to the guardrail.</p>
    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
        self.inner.get_tags()
    }
    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than once. 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> in the <i>Amazon S3 User Guide</i>.</p>
    pub fn client_request_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.client_request_token(input.into());
        self
    }
    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than once. 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> in the <i>Amazon S3 User Guide</i>.</p>
    pub fn set_client_request_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_client_request_token(input);
        self
    }
    /// <p>A unique, case-sensitive identifier to ensure that the API request completes no more than once. 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> in the <i>Amazon S3 User Guide</i>.</p>
    pub fn get_client_request_token(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_client_request_token()
    }
}