software.amazon.awscdk.services.iotevents.actions.LambdaInvokeAction Maven / Gradle / Ivy
Show all versions of iotevents-actions Show documentation
package software.amazon.awscdk.services.iotevents.actions;
/**
* (experimental) The action to write the data to an AWS Lambda function.
*
* Example:
*
*
* import software.amazon.awscdk.services.iotevents.*;
* import software.amazon.awscdk.services.iotevents.actions.*;
* 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();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.71.0 (build f1f58ae)", date = "2022-11-29T04:32:21.936Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.iotevents.actions.$Module.class, fqn = "@aws-cdk/aws-iotevents-actions.LambdaInvokeAction")
public class LambdaInvokeAction extends software.amazon.jsii.JsiiObject implements software.amazon.awscdk.services.iotevents.IAction {
protected LambdaInvokeAction(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected LambdaInvokeAction(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param func the AWS Lambda function to be invoked by this action. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public LambdaInvokeAction(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.lambda.IFunction func) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(func, "func is required") });
}
/**
* (experimental) Returns the AWS IoT Events action specification.
*
* @param _scope This parameter is required.
* @param options This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iotevents.ActionConfig bind(final @org.jetbrains.annotations.NotNull software.constructs.Construct _scope, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iotevents.ActionBindOptions options) {
return software.amazon.jsii.Kernel.call(this, "bind", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.iotevents.ActionConfig.class), new Object[] { java.util.Objects.requireNonNull(_scope, "_scope is required"), java.util.Objects.requireNonNull(options, "options is required") });
}
}