Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Loading...

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", // 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
});

Initializer

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
};

Properties

NameTypeDescription
InitialStateStateThe state that is entered at the creation of each detector.
DescriptionstringA brief description of the detector model.
DetectorKeystringThe value used to identify a detector instance.
DetectorModelNamestringThe name of the detector model.
EvaluationMethodEventEvaluationInformation about the order in which events are evaluated and how actions are executed.
RoleIRoleThe role that grants permission to AWS IoT Events to perform its operations.
InitialStateRequired
public State InitialState { get; set; }

The state that is entered at the creation of each detector.

DescriptionOptional
public string Description { get; set; }
  • Type: string
  • Default: none

A brief description of the detector model.

DetectorKeyOptional
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.

DetectorModelNameOptional
public string DetectorModelName { get; set; }
  • Type: string
  • Default: CloudFormation will generate a unique name of the detector model

The name of the detector model.

EvaluationMethodOptional
public EventEvaluation EvaluationMethod { get; set; }

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.

RoleOptional
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.