cloudshift.awscdk.dsl.services.stepfunctions.tasks.EvaluateExpressionDsl.kt Maven / Gradle / Ivy
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package cloudshift.awscdk.dsl.services.stepfunctions.tasks
import cloudshift.awscdk.common.CdkDslMarker
import cloudshift.awscdk.common.MapBuilder
import cloudshift.awscdk.dsl.services.stepfunctions.CredentialsDsl
import kotlin.Any
import kotlin.Deprecated
import kotlin.String
import kotlin.Unit
import kotlin.collections.Map
import software.amazon.awscdk.Duration
import software.amazon.awscdk.services.lambda.Runtime
import software.amazon.awscdk.services.stepfunctions.Credentials
import software.amazon.awscdk.services.stepfunctions.IntegrationPattern
import software.amazon.awscdk.services.stepfunctions.Timeout
import software.amazon.awscdk.services.stepfunctions.tasks.EvaluateExpression
import software.constructs.Construct
/**
* A Step Functions Task to evaluate an expression.
*
* OUTPUT: the output of this task is the evaluated expression.
*
* Example:
*
* ```
* EvaluateExpression convertToSeconds = EvaluateExpression.Builder.create(this, "Convert to
* seconds")
* .expression("$.waitMilliseconds / 1000")
* .resultPath("$.waitSeconds")
* .build();
* EvaluateExpression createMessage = EvaluateExpression.Builder.create(this, "Create message")
* // Note: this is a string inside a string.
* .expression("`Now waiting ${$.waitSeconds} seconds...`")
* .runtime(Runtime.NODEJS_16_X)
* .resultPath("$.message")
* .build();
* SnsPublish publishMessage = SnsPublish.Builder.create(this, "Publish message")
* .topic(new Topic(this, "cool-topic"))
* .message(TaskInput.fromJsonPathAt("$.message"))
* .resultPath("$.sns")
* .build();
* Wait wait = Wait.Builder.create(this, "Wait")
* .time(WaitTime.secondsPath("$.waitSeconds"))
* .build();
* StateMachine.Builder.create(this, "StateMachine")
* .definition(convertToSeconds.next(createMessage).next(publishMessage).next(wait))
* .build();
* ```
*/
@CdkDslMarker
public class EvaluateExpressionDsl(
scope: Construct,
id: String,
) {
private val cdkBuilder: EvaluateExpression.Builder = EvaluateExpression.Builder.create(scope, id)
/**
* An optional description for this state.
*
* Default: - No comment
*
* @param comment An optional description for this state.
*/
public fun comment(comment: String) {
cdkBuilder.comment(comment)
}
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing the
* task.
*/
public fun credentials(credentials: CredentialsDsl.() -> Unit = {}) {
val builder = CredentialsDsl()
builder.apply(credentials)
cdkBuilder.credentials(builder.build())
}
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing the
* task.
*/
public fun credentials(credentials: Credentials) {
cdkBuilder.credentials(credentials)
}
/**
* The expression to evaluate. The expression may contain state paths.
*
* Example value: `'$.a + $.b'`
*
* @param expression The expression to evaluate. The expression may contain state paths.
*/
public fun expression(expression: String) {
cdkBuilder.expression(expression)
}
/**
* (deprecated) Timeout for the heartbeat.
*
* Default: - None
*
* @deprecated use `heartbeatTimeout`
* @param heartbeat Timeout for the heartbeat.
*/
@Deprecated(message = "deprecated in CDK")
public fun heartbeat(heartbeat: Duration) {
cdkBuilder.heartbeat(heartbeat)
}
/**
* Timeout for the heartbeat.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param heartbeatTimeout Timeout for the heartbeat.
*/
public fun heartbeatTimeout(heartbeatTimeout: Timeout) {
cdkBuilder.heartbeatTimeout(heartbeatTimeout)
}
/**
* JSONPath expression to select part of the state to be the input to this state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* input to be the empty object {}.
*
* Default: - The entire task input (JSON path '$')
*
* @param inputPath JSONPath expression to select part of the state to be the input to this state.
*
*/
public fun inputPath(inputPath: String) {
cdkBuilder.inputPath(inputPath)
}
/**
* AWS Step Functions integrates with services directly in the Amazon States Language.
*
* You can control these AWS services using service integration patterns
*
* Default: - `IntegrationPattern.REQUEST_RESPONSE` for most tasks.
* `IntegrationPattern.RUN_JOB` for the following exceptions:
* `BatchSubmitJob`, `EmrAddStep`, `EmrCreateCluster`, `EmrTerminationCluster`, and
* `EmrContainersStartJobRun`.
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token)
* @param integrationPattern AWS Step Functions integrates with services directly in the Amazon
* States Language.
*/
public fun integrationPattern(integrationPattern: IntegrationPattern) {
cdkBuilder.integrationPattern(integrationPattern)
}
/**
* JSONPath expression to select select a portion of the state output to pass to the next state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* output to be the empty object {}.
*
* Default: - The entire JSON node determined by the state input, the task result,
* and resultPath is passed to the next state (JSON path '$')
*
* @param outputPath JSONPath expression to select select a portion of the state output to pass to
* the next state.
*/
public fun outputPath(outputPath: String) {
cdkBuilder.outputPath(outputPath)
}
/**
* JSONPath expression to indicate where to inject the state's output.
*
* May also be the special value JsonPath.DISCARD, which will cause the state's
* input to become its output.
*
* Default: - Replaces the entire input with the result (JSON path '$')
*
* @param resultPath JSONPath expression to indicate where to inject the state's output.
*/
public fun resultPath(resultPath: String) {
cdkBuilder.resultPath(resultPath)
}
/**
* The JSON that will replace the state's raw result and become the effective result before
* ResultPath is applied.
*
* You can use ResultSelector to create a payload with values that are static
* or selected from the state's raw result.
*
* Default: - None
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector)
* @param resultSelector The JSON that will replace the state's raw result and become the
* effective result before ResultPath is applied.
*/
public fun resultSelector(resultSelector: MapBuilder.() -> Unit = {}) {
val builder = MapBuilder()
builder.apply(resultSelector)
cdkBuilder.resultSelector(builder.map)
}
/**
* The JSON that will replace the state's raw result and become the effective result before
* ResultPath is applied.
*
* You can use ResultSelector to create a payload with values that are static
* or selected from the state's raw result.
*
* Default: - None
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector)
* @param resultSelector The JSON that will replace the state's raw result and become the
* effective result before ResultPath is applied.
*/
public fun resultSelector(resultSelector: Map) {
cdkBuilder.resultSelector(resultSelector)
}
/**
* The runtime language to use to evaluate the expression.
*
* Default: lambda.Runtime.NODEJS_16_X
*
* @param runtime The runtime language to use to evaluate the expression.
*/
public fun runtime(runtime: Runtime) {
cdkBuilder.runtime(runtime)
}
/**
* Timeout for the task.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param taskTimeout Timeout for the task.
*/
public fun taskTimeout(taskTimeout: Timeout) {
cdkBuilder.taskTimeout(taskTimeout)
}
/**
* (deprecated) Timeout for the task.
*
* Default: - None
*
* @deprecated use `taskTimeout`
* @param timeout Timeout for the task.
*/
@Deprecated(message = "deprecated in CDK")
public fun timeout(timeout: Duration) {
cdkBuilder.timeout(timeout)
}
public fun build(): EvaluateExpression = cdkBuilder.build()
}