All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awscdk.services.iotevents.actions.alpha.package-info Maven / Gradle / Ivy

/**
 * 

Actions for AWS::IoTEvents Detector Model

*

* --- *

* cdk-constructs: Experimental *

*

*

* The APIs of higher level constructs in this module are experimental and under active development. * They are subject to non-backward compatible changes or removal in any future version. These are * not subject to the Semantic Versioning model and breaking changes will be * announced in the release notes. This means that while you may use them, you may need to update * your source code when upgrading to a newer version of this package. *

*

*

*


*

* *

* This library contains integration classes to specify actions of state events of Detector Model in @aws-cdk/aws-iotevents. * Instances of these classes should be passed to State defined in @aws-cdk/aws-iotevents * You can define built-in actions to use a timer or set a variable, or send data to other AWS resources. *

* This library contains integration classes to use a timer or set a variable, or send data to other AWS resources. * AWS IoT Events can trigger actions when it detects a specified event or transition event. *

* Currently supported are: *

*

    *
  • Use timer
  • *
  • Set variable to detector instanse
  • *
  • Invoke a Lambda function
  • *
*

*

Use timer

*

* The code snippet below creates an Action that creates the timer with duration in seconds. *

*

 * // Example automatically generated from non-compiling source. May contain errors.
 * 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();
 * 
*

* Setting duration by IoT Events Expression: *

*

 * // Example automatically generated from non-compiling source. May contain errors.
 * SetTimerAction.Builder.create("MyTimer")
 *         .durationExpression(iotevents.Expression.inputAttribute(input, "payload.durationSeconds"))
 *         .build();
 * 
*

* And the timer can be reset and cleared. Below is an example of general * Device HeartBeat * Detector Model: *

*

 * // Example automatically generated from non-compiling source. May contain errors.
 * Object online = State.Builder.create()
 *         .stateName("Online")
 *         .onEnter(List.of(Map.of(
 *                 "eventName", "enter-event",
 *                 "condition", iotevents.Expression.currentInput(input),
 *                 "actions", List.of(
 *                     SetTimerAction.Builder.create("MyTimer")
 *                             .duration(cdk.Duration.seconds(60))
 *                             .build()))))
 *         .onInput(List.of(Map.of(
 *                 "eventName", "input-event",
 *                 "condition", iotevents.Expression.currentInput(input),
 *                 "actions", List.of(
 *                     new ResetTimerAction("MyTimer")))))
 *         .onExit(List.of(Map.of(
 *                 "eventName", "exit-event",
 *                 "actions", List.of(
 *                     new ClearTimerAction("MyTimer")))))
 *         .build();
 * Object offline = State.Builder.create().stateName("Offline").build();
 * 
 * online.transitionTo(offline, Map.of("when", iotevents.Expression.timeout("MyTimer")));
 * offline.transitionTo(online, Map.of("when", iotevents.Expression.currentInput(input)));
 * 
*

*

Set variable to detector instanse

*

* The code snippet below creates an Action that set variable to detector instanse * when it is triggered. *

*

 * 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 SetVariableAction("MyVariable", Expression.inputAttribute(input, "payload.temperature"))))
 *                 .build()))
 *         .build();
 * 
*

*

Invoke a Lambda function

*

* The code snippet below creates an Action that invoke a Lambda function * when it is triggered. *

*

 * import software.amazon.awscdk.services.iotevents.alpha.*;
 * import software.amazon.awscdk.services.iotevents.actions.alpha.*;
 * import software.amazon.awscdk.services.lambda.*;
 * 
 * IInput input;
 * IFunction func;
 * 
 * State state = State.Builder.create()
 *         .stateName("MyState")
 *         .onEnter(List.of(Event.builder()
 *                 .eventName("test-event")
 *                 .condition(Expression.currentInput(input))
 *                 .actions(List.of(new LambdaInvokeAction(func)))
 *                 .build()))
 *         .build();
 * 
*/ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) package software.amazon.awscdk.services.iotevents.actions.alpha;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy