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

io.cloudshiftdev.awscdk.services.stepfunctions.Fail.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")

package io.cloudshiftdev.awscdk.services.stepfunctions

import com.fasterxml.jackson.databind.node.ObjectNode
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import io.cloudshiftdev.constructs.Construct as CloudshiftdevConstructsConstruct
import software.constructs.Construct as SoftwareConstructsConstruct

/**
 * Define a Fail state in the state machine.
 *
 * Reaching a Fail state terminates the state execution in failure.
 *
 * Example:
 *
 * ```
 * Fail fail = Fail.Builder.create(this, "Fail")
 * .errorPath(JsonPath.format("error: {}.", JsonPath.stringAt("$.someError")))
 * .causePath("States.Format('cause: {}.', $.someCause)")
 * .build();
 * ```
 */
public open class Fail(
  cdkObject: software.amazon.awscdk.services.stepfunctions.Fail,
) : State(cdkObject) {
  public constructor(scope: CloudshiftdevConstructsConstruct, id: String) :
      this(software.amazon.awscdk.services.stepfunctions.Fail(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id)
  )

  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: FailProps,
  ) :
      this(software.amazon.awscdk.services.stepfunctions.Fail(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id, props.let(FailProps.Companion::unwrap))
  )

  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: FailProps.Builder.() -> Unit,
  ) : this(scope, id, FailProps(props)
  )

  /**
   * Continuable states of this Chainable.
   */
  public override fun endStates(): List =
      unwrap(this).getEndStates().map(INextable::wrap)

  /**
   * Return the Amazon States Language object for this state.
   */
  public override fun toStateJson(): ObjectNode = unwrap(this).toStateJson()

  /**
   * A fluent builder for [io.cloudshiftdev.awscdk.services.stepfunctions.Fail].
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * A description for the cause of the failure.
     *
     * Default: - No description
     *
     * @param cause A description for the cause of the failure. 
     */
    public fun cause(cause: String)

    /**
     * JsonPath expression to select part of the state to be the cause to this state.
     *
     * You can also use an intrinsic function that returns a string to specify this property.
     * The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem,
     * States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.
     *
     * Default: - No cause path
     *
     * @param causePath JsonPath expression to select part of the state to be the cause to this
     * state. 
     */
    public fun causePath(causePath: String)

    /**
     * An optional description for this state.
     *
     * Default: - No comment
     *
     * @param comment An optional description for this state. 
     */
    public fun comment(comment: String)

    /**
     * Error code used to represent this failure.
     *
     * Default: - No error code
     *
     * @param error Error code used to represent this failure. 
     */
    public fun error(error: String)

    /**
     * JsonPath expression to select part of the state to be the error to this state.
     *
     * You can also use an intrinsic function that returns a string to specify this property.
     * The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem,
     * States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.
     *
     * Default: - No error path
     *
     * @param errorPath JsonPath expression to select part of the state to be the error to this
     * state. 
     */
    public fun errorPath(errorPath: String)

    /**
     * Optional name for this state.
     *
     * Default: - The construct ID will be used as state name
     *
     * @param stateName Optional name for this state. 
     */
    public fun stateName(stateName: String)
  }

  private class BuilderImpl(
    scope: SoftwareConstructsConstruct,
    id: String,
  ) : Builder {
    private val cdkBuilder: software.amazon.awscdk.services.stepfunctions.Fail.Builder =
        software.amazon.awscdk.services.stepfunctions.Fail.Builder.create(scope, id)

    /**
     * A description for the cause of the failure.
     *
     * Default: - No description
     *
     * @param cause A description for the cause of the failure. 
     */
    override fun cause(cause: String) {
      cdkBuilder.cause(cause)
    }

    /**
     * JsonPath expression to select part of the state to be the cause to this state.
     *
     * You can also use an intrinsic function that returns a string to specify this property.
     * The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem,
     * States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.
     *
     * Default: - No cause path
     *
     * @param causePath JsonPath expression to select part of the state to be the cause to this
     * state. 
     */
    override fun causePath(causePath: String) {
      cdkBuilder.causePath(causePath)
    }

    /**
     * An optional description for this state.
     *
     * Default: - No comment
     *
     * @param comment An optional description for this state. 
     */
    override fun comment(comment: String) {
      cdkBuilder.comment(comment)
    }

    /**
     * Error code used to represent this failure.
     *
     * Default: - No error code
     *
     * @param error Error code used to represent this failure. 
     */
    override fun error(error: String) {
      cdkBuilder.error(error)
    }

    /**
     * JsonPath expression to select part of the state to be the error to this state.
     *
     * You can also use an intrinsic function that returns a string to specify this property.
     * The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem,
     * States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.
     *
     * Default: - No error path
     *
     * @param errorPath JsonPath expression to select part of the state to be the error to this
     * state. 
     */
    override fun errorPath(errorPath: String) {
      cdkBuilder.errorPath(errorPath)
    }

    /**
     * Optional name for this state.
     *
     * Default: - The construct ID will be used as state name
     *
     * @param stateName Optional name for this state. 
     */
    override fun stateName(stateName: String) {
      cdkBuilder.stateName(stateName)
    }

    public fun build(): software.amazon.awscdk.services.stepfunctions.Fail = cdkBuilder.build()
  }

  public companion object {
    public operator fun invoke(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      block: Builder.() -> Unit = {},
    ): Fail {
      val builderImpl = BuilderImpl(CloudshiftdevConstructsConstruct.unwrap(scope), id)
      return Fail(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.services.stepfunctions.Fail): Fail =
        Fail(cdkObject)

    internal fun unwrap(wrapped: Fail): software.amazon.awscdk.services.stepfunctions.Fail =
        wrapped.cdkObject as software.amazon.awscdk.services.stepfunctions.Fail
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy