Class Choice
Define a Choice in the state machine.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Choice : State, IChainable
Syntax (vb)
Public Class Choice Inherits State Implements IChainable
Remarks
A choice state can be used to make decisions based on the execution state.
ExampleMetadata: infused
Examples
var map = new Map(this, "Map State", new MapProps {
MaxConcurrency = 1,
ItemsPath = JsonPath.StringAt("$.inputForMap"),
ItemSelector = new Dictionary<string, object> {
{ "item", JsonPath.StringAt("$.Map.Item.Value") }
},
ResultPath = "$.mapOutput"
});
// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
var choice = new Choice(this, "Choice");
var condition1 = Condition.StringEquals("$.item.status", "SUCCESS");
var step1 = new Pass(this, "Step1");
var step2 = new Pass(this, "Step2");
var finish = new Pass(this, "Finish");
var definition = choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish);
map.ItemProcessor(definition);
Synopsis
Constructors
Choice(Construct, string, IChoiceProps?) | Define a Choice in the state machine. |
Properties
EndStates | Continuable states of this Chainable. |
Methods
Afterwards(IAfterwardsOptions?) | Return a Chain that contains all reachable end states from this Choice. |
JsonPath(Construct, string, IChoiceJsonPathProps?) | Define a Choice using JSONPath in the state machine. |
Jsonata(Construct, string, IChoiceJsonataProps?) | Define a Choice using JSONata in the state machine. |
Otherwise(IChainable) | If none of the given conditions match, continue execution with the given state. |
ToStateJson(QueryLanguage?) | Return the Amazon States Language object for this state. |
When(Condition, IChainable, IChoiceTransitionOptions?) | If the given condition matches, continue execution with the given state. |
Constructors
Choice(Construct, string, IChoiceProps?)
Define a Choice in the state machine.
public Choice(Construct scope, string id, IChoiceProps? props = null)
Parameters
- scope Construct
- id string
Descriptive identifier for this chainable.
- props IChoiceProps
Remarks
A choice state can be used to make decisions based on the execution state.
ExampleMetadata: infused
Properties
EndStates
Continuable states of this Chainable.
public override INextable[] EndStates { get; }
Property Value
Overrides
Remarks
A choice state can be used to make decisions based on the execution state.
ExampleMetadata: infused
Methods
Afterwards(IAfterwardsOptions?)
Return a Chain that contains all reachable end states from this Choice.
public virtual Chain Afterwards(IAfterwardsOptions? options = null)
Parameters
- options IAfterwardsOptions
Returns
Remarks
Use this to combine all possible choice paths back.
JsonPath(Construct, string, IChoiceJsonPathProps?)
Define a Choice using JSONPath in the state machine.
public static Choice JsonPath(Construct scope, string id, IChoiceJsonPathProps? props = null)
Parameters
- scope Construct
- id string
- props IChoiceJsonPathProps
Returns
Remarks
A choice state can be used to make decisions based on the execution state.
Jsonata(Construct, string, IChoiceJsonataProps?)
Define a Choice using JSONata in the state machine.
public static Choice Jsonata(Construct scope, string id, IChoiceJsonataProps? props = null)
Parameters
- scope Construct
- id string
- props IChoiceJsonataProps
Returns
Remarks
A choice state can be used to make decisions based on the execution state.
Otherwise(IChainable)
If none of the given conditions match, continue execution with the given state.
public virtual Choice Otherwise(IChainable def)
Parameters
- def IChainable
Returns
Remarks
If no conditions match and no otherwise() has been given, an execution error will be raised.
ToStateJson(QueryLanguage?)
Return the Amazon States Language object for this state.
public override JObject ToStateJson(QueryLanguage? topLevelQueryLanguage = null)
Parameters
- topLevelQueryLanguage QueryLanguage?
Returns
JObject
Overrides
Remarks
A choice state can be used to make decisions based on the execution state.
ExampleMetadata: infused
When(Condition, IChainable, IChoiceTransitionOptions?)
If the given condition matches, continue execution with the given state.
public virtual Choice When(Condition condition, IChainable next, IChoiceTransitionOptions? options = null)
Parameters
- condition Condition
- next IChainable
- options IChoiceTransitionOptions
Returns
Remarks
A choice state can be used to make decisions based on the execution state.
ExampleMetadata: infused