Interface IChoiceTransitionOptions
Options for Choice Transition.
Inherited Members
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IChoiceTransitionOptions : IAssignableStateOptions
Syntax (vb)
Public Interface IChoiceTransitionOptions Inherits IAssignableStateOptions
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Events;
Connection connection;
var getIssue = HttpInvoke.Jsonata(this, "Get Issue", new HttpInvokeJsonataProps {
Connection = connection,
ApiRoot = "{% 'https://' & $states.input.hostname %}",
ApiEndpoint = TaskInput.FromText("{% 'issues/' & $states.input.issue.id %}"),
Method = TaskInput.FromText("GET"),
// Parse the API call result to object and set to the variables
Assign = new Dictionary<string, object> {
{ "hostname", "{% $states.input.hostname %}" },
{ "issue", "{% $parse($states.result.ResponseBody) %}" }
}
});
var updateLabels = HttpInvoke.Jsonata(this, "Update Issue Labels", new HttpInvokeJsonataProps {
Connection = connection,
ApiRoot = "{% 'https://' & $states.input.hostname %}",
ApiEndpoint = TaskInput.FromText("{% 'issues/' & $states.input.issue.id & 'labels' %}"),
Method = TaskInput.FromText("POST"),
Body = TaskInput.FromObject(new Dictionary<string, object> {
{ "labels", "{% [$type, $component] %}" }
})
});
var notMatchTitleTemplate = Pass.Jsonata(this, "Not Match Title Template");
var definition = getIssue.Next(Choice.Jsonata(this, "Match Title Template?").When(Condition.Jsonata("{% $contains($issue.title, /(feat)|(fix)|(chore)(w*):.*/) %}"), updateLabels, new ChoiceTransitionOptions {
Assign = new Dictionary<string, object> {
{ "type", "{% $match($states.input.title, /(w*)((.*))/).groups[0] %}" },
{ "component", "{% $match($states.input.title, /(w*)((.*))/).groups[1] %}" }
}
}).Otherwise(notMatchTitleTemplate));
new StateMachine(this, "StateMachine", new StateMachineProps {
DefinitionBody = DefinitionBody.FromChainable(definition),
Timeout = Duration.Minutes(5),
Comment = "automate issue labeling state machine"
});
Synopsis
Properties
Comment | An optional description for the choice transition. |
Outputs | This option for JSONata only. |
Properties
Comment
An optional description for the choice transition.
string? Comment { get; }
Property Value
Remarks
Default: No comment
Outputs
This option for JSONata only.
object? Outputs { get; }
Property Value
Remarks
When you use JSONPath, then the state ignores this property. Used to specify and transform output from the state. When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly.
Default: - $states.result or $states.errorOutput
See: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-input-output-filtering.html