aws-sdk-databrew 1.92.0

AWS SDK for AWS Glue DataBrew
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Represents a single data quality requirement that should be validated in the scope of this dataset.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Rule {
    /// <p>The name of the rule.</p>
    pub name: ::std::string::String,
    /// <p>A value that specifies whether the rule is disabled. Once a rule is disabled, a profile job will not validate it during a job run. Default value is false.</p>
    pub disabled: bool,
    /// <p>The expression which includes column references, condition names followed by variable references, possibly grouped and combined with other conditions. For example, <code>(:col1 starts_with :prefix1 or :col1 starts_with :prefix2) and (:col1 ends_with :suffix1 or :col1 ends_with :suffix2)</code>. Column and value references are substitution variables that should start with the ':' symbol. Depending on the context, substitution variables' values can be either an actual value or a column name. These values are defined in the SubstitutionMap. If a CheckExpression starts with a column reference, then ColumnSelectors in the rule should be null. If ColumnSelectors has been defined, then there should be no column reference in the left side of a condition, for example, <code>is_between :val1 and :val2</code>.</p>
    /// <p>For more information, see <a href="https://docs.aws.amazon.com/databrew/latest/dg/profile.data-quality-available-checks.html">Available checks</a></p>
    pub check_expression: ::std::string::String,
    /// <p>The map of substitution variable names to their values used in a check expression. Variable names should start with a ':' (colon). Variable values can either be actual values or column names. To differentiate between the two, column names should be enclosed in backticks, for example, <code>":col1": "`Column A`".</code></p>
    pub substitution_map: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    /// <p>The threshold used with a non-aggregate check expression. Non-aggregate check expressions will be applied to each row in a specific column, and the threshold will be used to determine whether the validation succeeds.</p>
    pub threshold: ::std::option::Option<crate::types::Threshold>,
    /// <p>List of column selectors. Selectors can be used to select columns using a name or regular expression from the dataset. Rule will be applied to selected columns.</p>
    pub column_selectors: ::std::option::Option<::std::vec::Vec<crate::types::ColumnSelector>>,
}
impl Rule {
    /// <p>The name of the rule.</p>
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// <p>A value that specifies whether the rule is disabled. Once a rule is disabled, a profile job will not validate it during a job run. Default value is false.</p>
    pub fn disabled(&self) -> bool {
        self.disabled
    }
    /// <p>The expression which includes column references, condition names followed by variable references, possibly grouped and combined with other conditions. For example, <code>(:col1 starts_with :prefix1 or :col1 starts_with :prefix2) and (:col1 ends_with :suffix1 or :col1 ends_with :suffix2)</code>. Column and value references are substitution variables that should start with the ':' symbol. Depending on the context, substitution variables' values can be either an actual value or a column name. These values are defined in the SubstitutionMap. If a CheckExpression starts with a column reference, then ColumnSelectors in the rule should be null. If ColumnSelectors has been defined, then there should be no column reference in the left side of a condition, for example, <code>is_between :val1 and :val2</code>.</p>
    /// <p>For more information, see <a href="https://docs.aws.amazon.com/databrew/latest/dg/profile.data-quality-available-checks.html">Available checks</a></p>
    pub fn check_expression(&self) -> &str {
        use std::ops::Deref;
        self.check_expression.deref()
    }
    /// <p>The map of substitution variable names to their values used in a check expression. Variable names should start with a ':' (colon). Variable values can either be actual values or column names. To differentiate between the two, column names should be enclosed in backticks, for example, <code>":col1": "`Column A`".</code></p>
    pub fn substitution_map(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        self.substitution_map.as_ref()
    }
    /// <p>The threshold used with a non-aggregate check expression. Non-aggregate check expressions will be applied to each row in a specific column, and the threshold will be used to determine whether the validation succeeds.</p>
    pub fn threshold(&self) -> ::std::option::Option<&crate::types::Threshold> {
        self.threshold.as_ref()
    }
    /// <p>List of column selectors. Selectors can be used to select columns using a name or regular expression from the dataset. Rule will be applied to selected columns.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.column_selectors.is_none()`.
    pub fn column_selectors(&self) -> &[crate::types::ColumnSelector] {
        self.column_selectors.as_deref().unwrap_or_default()
    }
}
impl Rule {
    /// Creates a new builder-style object to manufacture [`Rule`](crate::types::Rule).
    pub fn builder() -> crate::types::builders::RuleBuilder {
        crate::types::builders::RuleBuilder::default()
    }
}

/// A builder for [`Rule`](crate::types::Rule).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct RuleBuilder {
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) disabled: ::std::option::Option<bool>,
    pub(crate) check_expression: ::std::option::Option<::std::string::String>,
    pub(crate) substitution_map: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    pub(crate) threshold: ::std::option::Option<crate::types::Threshold>,
    pub(crate) column_selectors: ::std::option::Option<::std::vec::Vec<crate::types::ColumnSelector>>,
}
impl RuleBuilder {
    /// <p>The name of the rule.</p>
    /// This field is required.
    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The name of the rule.</p>
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// <p>The name of the rule.</p>
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// <p>A value that specifies whether the rule is disabled. Once a rule is disabled, a profile job will not validate it during a job run. Default value is false.</p>
    pub fn disabled(mut self, input: bool) -> Self {
        self.disabled = ::std::option::Option::Some(input);
        self
    }
    /// <p>A value that specifies whether the rule is disabled. Once a rule is disabled, a profile job will not validate it during a job run. Default value is false.</p>
    pub fn set_disabled(mut self, input: ::std::option::Option<bool>) -> Self {
        self.disabled = input;
        self
    }
    /// <p>A value that specifies whether the rule is disabled. Once a rule is disabled, a profile job will not validate it during a job run. Default value is false.</p>
    pub fn get_disabled(&self) -> &::std::option::Option<bool> {
        &self.disabled
    }
    /// <p>The expression which includes column references, condition names followed by variable references, possibly grouped and combined with other conditions. For example, <code>(:col1 starts_with :prefix1 or :col1 starts_with :prefix2) and (:col1 ends_with :suffix1 or :col1 ends_with :suffix2)</code>. Column and value references are substitution variables that should start with the ':' symbol. Depending on the context, substitution variables' values can be either an actual value or a column name. These values are defined in the SubstitutionMap. If a CheckExpression starts with a column reference, then ColumnSelectors in the rule should be null. If ColumnSelectors has been defined, then there should be no column reference in the left side of a condition, for example, <code>is_between :val1 and :val2</code>.</p>
    /// <p>For more information, see <a href="https://docs.aws.amazon.com/databrew/latest/dg/profile.data-quality-available-checks.html">Available checks</a></p>
    /// This field is required.
    pub fn check_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.check_expression = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The expression which includes column references, condition names followed by variable references, possibly grouped and combined with other conditions. For example, <code>(:col1 starts_with :prefix1 or :col1 starts_with :prefix2) and (:col1 ends_with :suffix1 or :col1 ends_with :suffix2)</code>. Column and value references are substitution variables that should start with the ':' symbol. Depending on the context, substitution variables' values can be either an actual value or a column name. These values are defined in the SubstitutionMap. If a CheckExpression starts with a column reference, then ColumnSelectors in the rule should be null. If ColumnSelectors has been defined, then there should be no column reference in the left side of a condition, for example, <code>is_between :val1 and :val2</code>.</p>
    /// <p>For more information, see <a href="https://docs.aws.amazon.com/databrew/latest/dg/profile.data-quality-available-checks.html">Available checks</a></p>
    pub fn set_check_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.check_expression = input;
        self
    }
    /// <p>The expression which includes column references, condition names followed by variable references, possibly grouped and combined with other conditions. For example, <code>(:col1 starts_with :prefix1 or :col1 starts_with :prefix2) and (:col1 ends_with :suffix1 or :col1 ends_with :suffix2)</code>. Column and value references are substitution variables that should start with the ':' symbol. Depending on the context, substitution variables' values can be either an actual value or a column name. These values are defined in the SubstitutionMap. If a CheckExpression starts with a column reference, then ColumnSelectors in the rule should be null. If ColumnSelectors has been defined, then there should be no column reference in the left side of a condition, for example, <code>is_between :val1 and :val2</code>.</p>
    /// <p>For more information, see <a href="https://docs.aws.amazon.com/databrew/latest/dg/profile.data-quality-available-checks.html">Available checks</a></p>
    pub fn get_check_expression(&self) -> &::std::option::Option<::std::string::String> {
        &self.check_expression
    }
    /// Adds a key-value pair to `substitution_map`.
    ///
    /// To override the contents of this collection use [`set_substitution_map`](Self::set_substitution_map).
    ///
    /// <p>The map of substitution variable names to their values used in a check expression. Variable names should start with a ':' (colon). Variable values can either be actual values or column names. To differentiate between the two, column names should be enclosed in backticks, for example, <code>":col1": "`Column A`".</code></p>
    pub fn substitution_map(
        mut self,
        k: impl ::std::convert::Into<::std::string::String>,
        v: impl ::std::convert::Into<::std::string::String>,
    ) -> Self {
        let mut hash_map = self.substitution_map.unwrap_or_default();
        hash_map.insert(k.into(), v.into());
        self.substitution_map = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>The map of substitution variable names to their values used in a check expression. Variable names should start with a ':' (colon). Variable values can either be actual values or column names. To differentiate between the two, column names should be enclosed in backticks, for example, <code>":col1": "`Column A`".</code></p>
    pub fn set_substitution_map(
        mut self,
        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    ) -> Self {
        self.substitution_map = input;
        self
    }
    /// <p>The map of substitution variable names to their values used in a check expression. Variable names should start with a ':' (colon). Variable values can either be actual values or column names. To differentiate between the two, column names should be enclosed in backticks, for example, <code>":col1": "`Column A`".</code></p>
    pub fn get_substitution_map(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        &self.substitution_map
    }
    /// <p>The threshold used with a non-aggregate check expression. Non-aggregate check expressions will be applied to each row in a specific column, and the threshold will be used to determine whether the validation succeeds.</p>
    pub fn threshold(mut self, input: crate::types::Threshold) -> Self {
        self.threshold = ::std::option::Option::Some(input);
        self
    }
    /// <p>The threshold used with a non-aggregate check expression. Non-aggregate check expressions will be applied to each row in a specific column, and the threshold will be used to determine whether the validation succeeds.</p>
    pub fn set_threshold(mut self, input: ::std::option::Option<crate::types::Threshold>) -> Self {
        self.threshold = input;
        self
    }
    /// <p>The threshold used with a non-aggregate check expression. Non-aggregate check expressions will be applied to each row in a specific column, and the threshold will be used to determine whether the validation succeeds.</p>
    pub fn get_threshold(&self) -> &::std::option::Option<crate::types::Threshold> {
        &self.threshold
    }
    /// Appends an item to `column_selectors`.
    ///
    /// To override the contents of this collection use [`set_column_selectors`](Self::set_column_selectors).
    ///
    /// <p>List of column selectors. Selectors can be used to select columns using a name or regular expression from the dataset. Rule will be applied to selected columns.</p>
    pub fn column_selectors(mut self, input: crate::types::ColumnSelector) -> Self {
        let mut v = self.column_selectors.unwrap_or_default();
        v.push(input);
        self.column_selectors = ::std::option::Option::Some(v);
        self
    }
    /// <p>List of column selectors. Selectors can be used to select columns using a name or regular expression from the dataset. Rule will be applied to selected columns.</p>
    pub fn set_column_selectors(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ColumnSelector>>) -> Self {
        self.column_selectors = input;
        self
    }
    /// <p>List of column selectors. Selectors can be used to select columns using a name or regular expression from the dataset. Rule will be applied to selected columns.</p>
    pub fn get_column_selectors(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ColumnSelector>> {
        &self.column_selectors
    }
    /// Consumes the builder and constructs a [`Rule`](crate::types::Rule).
    /// This method will fail if any of the following fields are not set:
    /// - [`name`](crate::types::builders::RuleBuilder::name)
    /// - [`check_expression`](crate::types::builders::RuleBuilder::check_expression)
    pub fn build(self) -> ::std::result::Result<crate::types::Rule, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Rule {
            name: self.name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "name",
                    "name was not specified but it is required when building Rule",
                )
            })?,
            disabled: self.disabled.unwrap_or_default(),
            check_expression: self.check_expression.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "check_expression",
                    "check_expression was not specified but it is required when building Rule",
                )
            })?,
            substitution_map: self.substitution_map,
            threshold: self.threshold,
            column_selectors: self.column_selectors,
        })
    }
}