This module defines the choice rules for a Choice state.
Use the :py~stepfunctions.steps.Choice.add_choice
method to add a branch to a Choice step.
my_choice_state.add_choice(
rule=ChoiceRule.BooleanEquals(variable=previous_state.output()["Success"], value=True),
next_step=happy_path
)
my_choice_state.add_choice(
ChoiceRule.BooleanEquals(variable=previous_state.output()["Success"], value=False),
next_step=sad_state
)
In this example, choice rules are added to the Choice state my_choice_state
using :py~stepfunctions.steps.Choice.add_choice
. Logic in a Choice state is implemented with the help of Choice Rules. A Choice Rule encapsulates a comparison, which contains the following:
- An input variable to compare
- The type of comparison
- The value to compare the variable to
The type of comparison is abstracted by the classes provided in this module. Multiple choice rules can be compounded together using the :py~stepfunctions.steps.choice_rule.ChoiceRule.And
or :py~stepfunctions.steps.choice_rule.ChoiceRule.Or
classes. A choice rule can be negated using the :py~stepfunctions.steps.choice_rule.ChoiceRule.Not
class.
stepfunctions.steps.choice_rule.BaseRule
stepfunctions.steps.choice_rule.Rule
stepfunctions.steps.choice_rule.CompoundRule
stepfunctions.steps.choice_rule.NotRule
stepfunctions.steps.choice_rule.ChoiceRule