> **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.
# Expression

Expression for events in Detector Model state.

Obtainable from: Expression.add, Expression.and, Expression.bitwiseAnd, Expression.bitwiseOr, Expression.bitwiseXor, Expression.concat, Expression.currentInput, Expression.divide, Expression.eq, Expression.fromString, Expression.gt, Expression.gte, Expression.inputAttribute, Expression.lt, Expression.lte, Expression.multiply, Expression.neq, Expression.or, Expression.subtract, Expression.timeout
Used as argument in: Expression.add, Expression.and, Expression.bitwiseAnd, Expression.bitwiseOr, Expression.bitwiseXor, Expression.concat, Expression.divide, Expression.eq, Expression.gt, Expression.gte, Expression.lt, Expression.lte, Expression.multiply, Expression.neq, Expression.or, Expression.subtract, SetVariableAction (initializer), TimerDuration.fromExpression

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

## Example

TypeScript:

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

declare const input: iotevents.IInput;

const state = new iotevents.State({
  stateName: 'MyState',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.SetTimerAction('MyTimer', {
        duration: cdk.Duration.seconds(60),
      }),
    ],
  }],
});
```

Python:

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

# input: iotevents.IInput

state = iotevents.State(
    state_name="MyState",
    on_enter=[iotevents.Event(
        event_name="test-event",
        condition=iotevents.Expression.current_input(input),
        actions=[
            actions.SetTimerAction("MyTimer", {
                "duration": cdk.Duration.seconds(60)
            })
        ]
    )]
)
```

Java:

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

IInput input;

State state = State.Builder.create()
        .stateName("MyState")
        .onEnter(List.of(Event.builder()
                .eventName("test-event")
                .condition(Expression.currentInput(input))
                .actions(List.of(
                    new SetTimerAction("MyTimer", Map.of(
                            "duration", cdk.Duration.seconds(60)))))
                .build()))
        .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;

IInput input;

var state = new State(new StateProps {
    StateName = "MyState",
    OnEnter = new [] { new Event {
        EventName = "test-event",
        Condition = Expression.CurrentInput(input),
        Actions = new [] {
            new SetTimerAction("MyTimer", new Dictionary<string, object> {
                { "duration", cdk.Duration.Seconds(60) }
            }) }
    } }
});
```

Golang:

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

var input IInput

state := iotevents.NewState(&StateProps{
	StateName: jsii.String("MyState"),
	OnEnter: []Event{
		&Event{
			EventName: jsii.String("test-event"),
			Condition: iotevents.Expression_CurrentInput(input),
			Actions: []IAction{
				actions.NewSetTimerAction(jsii.String("MyTimer"), map[string]interface{}{
					"duration": cdk.Duration_seconds(jsii.Number(60)),
				}),
			},
		},
	},
})
```

## Initializer

TypeScript:

```ts
new Expression()
```

Python:

```python
Expression()
```

Java:

```java
new Expression()
```

C# / .NET:

```csharp
new Expression()
```

Golang:

```go
NewExpression()
```

## Methods

- `add(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Addition operator.

- `and(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the AND operator.

- `bitwiseAnd(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Bitwise AND operator.

- `bitwiseOr(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Bitwise OR operator.

- `bitwiseXor(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Bitwise XOR operator.

- `concat(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the String Concatenation operator.

- `currentInput(input: IInput): Expression // chainable` (static) — Create a expression for function `currentInput()`.

  It is evaluated to true if the specified input message was received.

- `divide(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Division operator.

- `eq(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Equal operator.

- `evaluate(parentPriority?: number): string` — This is called to evaluate the expression.

  **Parameters**

  - `parentPriority` — priority of the parent of this expression, used for determining whether or not to add parenthesis around the expression.

- `fromString(value: string): Expression // chainable` (static) — Create a expression from the given string.

- `gt(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Greater Than operator.

- `gte(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Greater Than Or Equal operator.

- `inputAttribute(input: IInput, path: string): Expression // chainable` (static) — Create a expression for get an input attribute as `$input.TemperatureInput.temperatures[2]`.

- `lt(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Less Than operator.

- `lte(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Less Than Or Equal operator.

- `multiply(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Multiplication operator.

- `neq(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Not Equal operator.

- `or(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the OR operator.

- `subtract(left: Expression, right: Expression): Expression // chainable` (static) — Create a expression for the Subtraction operator.

- `timeout(timerName: string): Expression // chainable` (static) — Create a expression for function `timeout("timer-name")`.

  It is evaluated to true if the specified timer has elapsed.
  You can define a timer only using the `setTimer` action.
