aws-sdk-codepipeline 1.112.0

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

/// <p>The condition for the stage. A condition is made up of the rules and the result for the condition. For more information about conditions, see <a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-conditions.html">Stage conditions</a> and <a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts-how-it-works-conditions.html">How do stage conditions work?</a>.. For more information about rules, see the <a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/rule-reference.html">CodePipeline rule reference</a>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Condition {
    /// <p>The action to be done when the condition is met. For example, rolling back an execution for a failure condition.</p>
    pub result: ::std::option::Option<crate::types::Result>,
    /// <p>The rules that make up the condition.</p>
    pub rules: ::std::option::Option<::std::vec::Vec<crate::types::RuleDeclaration>>,
}
impl Condition {
    /// <p>The action to be done when the condition is met. For example, rolling back an execution for a failure condition.</p>
    pub fn result(&self) -> ::std::option::Option<&crate::types::Result> {
        self.result.as_ref()
    }
    /// <p>The rules that make up the condition.</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 `.rules.is_none()`.
    pub fn rules(&self) -> &[crate::types::RuleDeclaration] {
        self.rules.as_deref().unwrap_or_default()
    }
}
impl Condition {
    /// Creates a new builder-style object to manufacture [`Condition`](crate::types::Condition).
    pub fn builder() -> crate::types::builders::ConditionBuilder {
        crate::types::builders::ConditionBuilder::default()
    }
}

/// A builder for [`Condition`](crate::types::Condition).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct ConditionBuilder {
    pub(crate) result: ::std::option::Option<crate::types::Result>,
    pub(crate) rules: ::std::option::Option<::std::vec::Vec<crate::types::RuleDeclaration>>,
}
impl ConditionBuilder {
    /// <p>The action to be done when the condition is met. For example, rolling back an execution for a failure condition.</p>
    pub fn result(mut self, input: crate::types::Result) -> Self {
        self.result = ::std::option::Option::Some(input);
        self
    }
    /// <p>The action to be done when the condition is met. For example, rolling back an execution for a failure condition.</p>
    pub fn set_result(mut self, input: ::std::option::Option<crate::types::Result>) -> Self {
        self.result = input;
        self
    }
    /// <p>The action to be done when the condition is met. For example, rolling back an execution for a failure condition.</p>
    pub fn get_result(&self) -> &::std::option::Option<crate::types::Result> {
        &self.result
    }
    /// Appends an item to `rules`.
    ///
    /// To override the contents of this collection use [`set_rules`](Self::set_rules).
    ///
    /// <p>The rules that make up the condition.</p>
    pub fn rules(mut self, input: crate::types::RuleDeclaration) -> Self {
        let mut v = self.rules.unwrap_or_default();
        v.push(input);
        self.rules = ::std::option::Option::Some(v);
        self
    }
    /// <p>The rules that make up the condition.</p>
    pub fn set_rules(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RuleDeclaration>>) -> Self {
        self.rules = input;
        self
    }
    /// <p>The rules that make up the condition.</p>
    pub fn get_rules(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RuleDeclaration>> {
        &self.rules
    }
    /// Consumes the builder and constructs a [`Condition`](crate::types::Condition).
    pub fn build(self) -> crate::types::Condition {
        crate::types::Condition {
            result: self.result,
            rules: self.rules,
        }
    }
}