DetectorModelProps
Properties for defining an AWS IoT Events detector model.
Example
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", // optionalAttributeJsonPaths = 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 { // optionalEventName = "test-input-event",Actions = new [] { new LambdaInvokeAction(func) } } },OnExit = new [] { new Event { // optionalEventName = "test-exit-event",Actions = new [] { new LambdaInvokeAction(func) } } }});var coldState = new State(new StateProps {StateName = "cold"});// transit to coldState when temperature is less than 15warmState.TransitionTo(coldState, new TransitionOptions {EventName = "to_coldState", // optional property, default by combining the names of the StatesWhen = 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 15coldState.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", // optionalDescription = "test-detector-model-description", // optional property, default is noneEvaluationMethod = EventEvaluation.SERIAL, // optional property, default is iotevents.EventEvaluation.BATCHDetectorKey = "payload.deviceId", // optional property, default is none and single detector instance will be created and all inputs will be routed to itInitialState = warmState});
using Amazon.CDK.AWS.IoTEvents.Alpha;new DetectorModelProps {State InitialState,string Description = null,string DetectorKey = null,string DetectorModelName = null,EventEvaluation EvaluationMethod = null,IRole Role = null};
Name | Type | Description |
---|---|---|
InitialState | State | The state that is entered at the creation of each detector. |
Description | string | A brief description of the detector model. |
DetectorKey | string | The value used to identify a detector instance. |
DetectorModelName | string | The name of the detector model. |
EvaluationMethod | EventEvaluation | Information about the order in which events are evaluated and how actions are executed. |
Role | IRole | The role that grants permission to AWS IoT Events to perform its operations. |
public State InitialState { get; set; }
- Type: State
The state that is entered at the creation of each detector.
public string Description { get; set; }
- Type: string
- Default: none
A brief description of the detector model.
public string DetectorKey { get; set; }
- Type: string
- Default: none (single detector instance will be created and all inputs will be routed to it)
The value used to identify a detector instance.
When a device or system sends input, a new detector instance with a unique key value is created. AWS IoT Events can continue to route input to its corresponding detector instance based on this identifying information.
This parameter uses a JSON-path expression to select the attribute-value pair in the message payload that is used for identification. To route the message to the correct detector instance, the device must send a message payload that contains the same attribute-value.
public string DetectorModelName { get; set; }
- Type: string
- Default: CloudFormation will generate a unique name of the detector model
The name of the detector model.
public EventEvaluation EvaluationMethod { get; set; }
- Type: EventEvaluation
- Default: EventEvaluation.BATCH
Information about the order in which events are evaluated and how actions are executed.
When setting to SERIAL, variables are updated and event conditions are evaluated in the order that the events are defined. When setting to BATCH, variables within a state are updated and events within a state are performed only after all event conditions are evaluated.
public IRole Role { get; set; }
- Type: IRole
- Default: a role will be created with default permissions
The role that grants permission to AWS IoT Events to perform its operations.
Use the snippets below in your Git repositories or elsewhere to add a button that links to this package. The button will automatically update to light mode or dark mode based on whether the user's client has requested a light or dark theme.
[](https://constructs.dev/packages/@aws-cdk/aws-iotevents-alpha)
<a href="https://constructs.dev/packages/@aws-cdk/aws-iotevents-alpha"><img src="https://constructs.dev/badge?package=%40aws-cdk%2Faws-iotevents-alpha" alt="View on Construct Hub"/></a>