> **Experimental**
>
> `@aws-cdk/aws-iotevents-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# TransitionOptions

Properties for options of state transition.

Used as argument in: [State.transitionTo](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-iotevents-alpha.State.html#transitionto)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/state.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-iotevents-alpha/lib/state.ts#L10)

## Example

TypeScript:

```ts
import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as actions from '@aws-cdk/aws-iotevents-actions-alpha';
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const func: lambda.IFunction;

const input = new iotevents.Input(this, 'MyInput', {
  inputName: 'my_input', // optional
  attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
});

const warmState = new iotevents.State({
  stateName: 'warm',
  onEnter: [{
    eventName: 'test-enter-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [new actions.LambdaInvokeAction(func)], // optional
  }],
  onInput: [{ // optional
    eventName: 'test-input-event',
    actions: [new actions.LambdaInvokeAction(func)],
  }],
  onExit: [{ // optional
    eventName: 'test-exit-event',
    actions: [new actions.LambdaInvokeAction(func)],
  }],
});
const coldState = new iotevents.State({
  stateName: 'cold',
});

// transit to coldState when temperature is less than 15
warmState.transitionTo(coldState, {
  eventName: 'to_coldState', // optional property, default by combining the names of the States
  when: iotevents.Expression.lt(
    iotevents.Expression.inputAttribute(input, 'payload.temperature'),
    iotevents.Expression.fromString('15'),
  ),
  executing: [new actions.LambdaInvokeAction(func)], // optional
});
// transit to warmState when temperature is greater than or equal to 15
coldState.transitionTo(warmState, {
  when: iotevents.Expression.gte(
    iotevents.Expression.inputAttribute(input, 'payload.temperature'),
    iotevents.Expression.fromString('15'),
  ),
});

new iotevents.DetectorModel(this, 'MyDetectorModel', {
  detectorModelName: 'test-detector-model', // optional
  description: 'test-detector-model-description', // optional property, default is none
  evaluationMethod: iotevents.EventEvaluation.SERIAL, // optional property, default is iotevents.EventEvaluation.BATCH
  detectorKey: 'payload.deviceId', // optional property, default is none and single detector instance will be created and all inputs will be routed to it
  initialState: warmState,
});
```

Python:

```python
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions
import aws_cdk.aws_lambda as lambda_

# func: lambda.IFunction

input = iotevents.Input(self, "MyInput",
    input_name="my_input",  # optional
    attribute_json_paths=["payload.deviceId", "payload.temperature"]
)

warm_state = iotevents.State(
    state_name="warm",
    on_enter=[iotevents.Event(
        event_name="test-enter-event",
        condition=iotevents.Expression.current_input(input),
        actions=[actions.LambdaInvokeAction(func)]
    )],
    on_input=[iotevents.Event( # optional
        event_name="test-input-event",
        actions=[actions.LambdaInvokeAction(func)])],
    on_exit=[iotevents.Event( # optional
        event_name="test-exit-event",
        actions=[actions.LambdaInvokeAction(func)])]
)
cold_state = iotevents.State(
    state_name="cold"
)

# transit to coldState when temperature is less than 15
warm_state.transition_to(cold_state,
    event_name="to_coldState",  # optional property, default by combining the names of the States
    when=iotevents.Expression.lt(
        iotevents.Expression.input_attribute(input, "payload.temperature"),
        iotevents.Expression.from_string("15")),
    executing=[actions.LambdaInvokeAction(func)]
)
# transit to warmState when temperature is greater than or equal to 15
cold_state.transition_to(warm_state,
    when=iotevents.Expression.gte(
        iotevents.Expression.input_attribute(input, "payload.temperature"),
        iotevents.Expression.from_string("15"))
)

iotevents.DetectorModel(self, "MyDetectorModel",
    detector_model_name="test-detector-model",  # optional
    description="test-detector-model-description",  # optional property, default is none
    evaluation_method=iotevents.EventEvaluation.SERIAL,  # optional property, default is iotevents.EventEvaluation.BATCH
    detector_key="payload.deviceId",  # optional property, default is none and single detector instance will be created and all inputs will be routed to it
    initial_state=warm_state
)
```

Java:

```java
import software.amazon.awscdk.services.iotevents.alpha.*;
import software.amazon.awscdk.services.iotevents.actions.alpha.*;
import software.amazon.awscdk.services.lambda.*;

IFunction func;

Input input = Input.Builder.create(this, "MyInput")
        .inputName("my_input") // optional
        .attributeJsonPaths(List.of("payload.deviceId", "payload.temperature"))
        .build();

State warmState = State.Builder.create()
        .stateName("warm")
        .onEnter(List.of(Event.builder()
                .eventName("test-enter-event")
                .condition(Expression.currentInput(input))
                .actions(List.of(new LambdaInvokeAction(func)))
                .build()))
        .onInput(List.of(Event.builder() // optional
                .eventName("test-input-event")
                .actions(List.of(new LambdaInvokeAction(func))).build()))
        .onExit(List.of(Event.builder() // optional
                .eventName("test-exit-event")
                .actions(List.of(new LambdaInvokeAction(func))).build()))
        .build();
State coldState = State.Builder.create()
        .stateName("cold")
        .build();

// transit to coldState when temperature is less than 15
warmState.transitionTo(coldState, TransitionOptions.builder()
        .eventName("to_coldState") // optional property, default by combining the names of the States
        .when(Expression.lt(Expression.inputAttribute(input, "payload.temperature"), Expression.fromString("15")))
        .executing(List.of(new LambdaInvokeAction(func)))
        .build());
// transit to warmState when temperature is greater than or equal to 15
coldState.transitionTo(warmState, TransitionOptions.builder()
        .when(Expression.gte(Expression.inputAttribute(input, "payload.temperature"), Expression.fromString("15")))
        .build());

DetectorModel.Builder.create(this, "MyDetectorModel")
        .detectorModelName("test-detector-model") // optional
        .description("test-detector-model-description") // optional property, default is none
        .evaluationMethod(EventEvaluation.SERIAL) // optional property, default is iotevents.EventEvaluation.BATCH
        .detectorKey("payload.deviceId") // optional property, default is none and single detector instance will be created and all inputs will be routed to it
        .initialState(warmState)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.IoTEvents.Alpha
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;
using Amazon.CDK.AWS.Lambda;

IFunction func;

var input = new Input(this, "MyInput", new InputProps {
    InputName = "my_input",  // optional
    AttributeJsonPaths = new [] { "payload.deviceId", "payload.temperature" }
});

var warmState = new State(new StateProps {
    StateName = "warm",
    OnEnter = new [] { new Event {
        EventName = "test-enter-event",
        Condition = Expression.CurrentInput(input),
        Actions = new [] { new LambdaInvokeAction(func) }
    } },
    OnInput = new [] { new Event {  // optional
        EventName = "test-input-event",
        Actions = new [] { new LambdaInvokeAction(func) } } },
    OnExit = new [] { new Event {  // optional
        EventName = "test-exit-event",
        Actions = new [] { new LambdaInvokeAction(func) } } }
});
var coldState = new State(new StateProps {
    StateName = "cold"
});

// transit to coldState when temperature is less than 15
warmState.TransitionTo(coldState, new TransitionOptions {
    EventName = "to_coldState",  // optional property, default by combining the names of the States
    When = Expression.Lt(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15")),
    Executing = new [] { new LambdaInvokeAction(func) }
});
// transit to warmState when temperature is greater than or equal to 15
coldState.TransitionTo(warmState, new TransitionOptions {
    When = Expression.Gte(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15"))
});

new DetectorModel(this, "MyDetectorModel", new DetectorModelProps {
    DetectorModelName = "test-detector-model",  // optional
    Description = "test-detector-model-description",  // optional property, default is none
    EvaluationMethod = EventEvaluation.SERIAL,  // optional property, default is iotevents.EventEvaluation.BATCH
    DetectorKey = "payload.deviceId",  // optional property, default is none and single detector instance will be created and all inputs will be routed to it
    InitialState = warmState
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkioteventsalpha/v2
import "github.com/aws/aws-cdk-go/awscdkioteventsalpha"
import "github.com/aws/aws-cdk-go/awscdkioteventsactionsalpha"
import lambda "github.com/aws/aws-cdk-go/awscdk"

var func IFunction

input := iotevents.NewInput(this, jsii.String("MyInput"), &InputProps{
	InputName: jsii.String("my_input"),
	 // optional
	AttributeJsonPaths: []*string{
		jsii.String("payload.deviceId"),
		jsii.String("payload.temperature"),
	},
})

warmState := iotevents.NewState(&StateProps{
	StateName: jsii.String("warm"),
	OnEnter: []Event{
		&Event{
			EventName: jsii.String("test-enter-event"),
			Condition: iotevents.Expression_CurrentInput(input),
			Actions: []IAction{
				actions.NewLambdaInvokeAction(func),
			},
		},
	},
	OnInput: []Event{
		&Event{
			 // optional
			EventName: jsii.String("test-input-event"),
			Actions: []IAction{
				actions.NewLambdaInvokeAction(func),
			},
		},
	},
	OnExit: []Event{
		&Event{
			 // optional
			EventName: jsii.String("test-exit-event"),
			Actions: []IAction{
				actions.NewLambdaInvokeAction(func),
			},
		},
	},
})
coldState := iotevents.NewState(&StateProps{
	StateName: jsii.String("cold"),
})

// transit to coldState when temperature is less than 15
warmState.TransitionTo(coldState, &TransitionOptions{
	EventName: jsii.String("to_coldState"),
	 // optional property, default by combining the names of the States
	When: iotevents.Expression_Lt(iotevents.Expression_InputAttribute(input, jsii.String("payload.temperature")), iotevents.Expression_FromString(jsii.String("15"))),
	Executing: []IAction{
		actions.NewLambdaInvokeAction(func),
	},
})
// transit to warmState when temperature is greater than or equal to 15
coldState.TransitionTo(warmState, &TransitionOptions{
	When: iotevents.Expression_Gte(iotevents.Expression_*InputAttribute(input, jsii.String("payload.temperature")), iotevents.Expression_*FromString(jsii.String("15"))),
})

iotevents.NewDetectorModel(this, jsii.String("MyDetectorModel"), &DetectorModelProps{
	DetectorModelName: jsii.String("test-detector-model"),
	 // optional
	Description: jsii.String("test-detector-model-description"),
	 // optional property, default is none
	EvaluationMethod: iotevents.EventEvaluation_SERIAL,
	 // optional property, default is iotevents.EventEvaluation.BATCH
	DetectorKey: jsii.String("payload.deviceId"),
	 // optional property, default is none and single detector instance will be created and all inputs will be routed to it
	InitialState: warmState,
})
```

## Properties

- `eventName`: string — The name of the event.

  **Default:** string combining the names of the States as `${originStateName}_to_${targetStateName}`

- `executing`: [IAction](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-iotevents-alpha.IAction.html)[] — The actions to be performed with the transition.

  **Default:** no actions will be performed

- `when`: [Expression](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-iotevents-alpha.Expression.html) (required) — The condition that is used to determine to cause the state transition and the actions.

  When this was evaluated to `true`, the state transition and the actions are triggered.
