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

io.cloudshiftdev.awscdk.cxapi.AwsCloudFormationStackProperties.kt Maven / Gradle / Ivy

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

package io.cloudshiftdev.awscdk.cxapi

import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Boolean
import kotlin.String
import kotlin.Unit
import kotlin.collections.Map

/**
 * Artifact properties for CloudFormation stacks.
 *
 * Example:
 *
 * ```
 * // The code below shows an example of how to instantiate this type.
 * // The values are placeholders you should change.
 * import io.cloudshiftdev.awscdk.cxapi.*;
 * AwsCloudFormationStackProperties awsCloudFormationStackProperties =
 * AwsCloudFormationStackProperties.builder()
 * .templateFile("templateFile")
 * // the properties below are optional
 * .parameters(Map.of(
 * "parametersKey", "parameters"))
 * .stackName("stackName")
 * .terminationProtection(false)
 * .build();
 * ```
 */
public interface AwsCloudFormationStackProperties {
  /**
   * Values for CloudFormation stack parameters that should be passed when the stack is deployed.
   */
  public fun parameters(): Map = unwrap(this).getParameters() ?: emptyMap()

  /**
   * The name to use for the CloudFormation stack.
   *
   * Default: - name derived from artifact ID
   */
  public fun stackName(): String? = unwrap(this).getStackName()

  /**
   * A file relative to the assembly root which contains the CloudFormation template for this stack.
   */
  public fun templateFile(): String

  /**
   * Whether to enable termination protection for this stack.
   *
   * Default: false
   */
  public fun terminationProtection(): Boolean? = unwrap(this).getTerminationProtection()

  /**
   * A builder for [AwsCloudFormationStackProperties]
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * @param parameters Values for CloudFormation stack parameters that should be passed when the
     * stack is deployed.
     */
    public fun parameters(parameters: Map)

    /**
     * @param stackName The name to use for the CloudFormation stack.
     */
    public fun stackName(stackName: String)

    /**
     * @param templateFile A file relative to the assembly root which contains the CloudFormation
     * template for this stack. 
     */
    public fun templateFile(templateFile: String)

    /**
     * @param terminationProtection Whether to enable termination protection for this stack.
     */
    public fun terminationProtection(terminationProtection: Boolean)
  }

  private class BuilderImpl : Builder {
    private val cdkBuilder: software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties.Builder =
        software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties.builder()

    /**
     * @param parameters Values for CloudFormation stack parameters that should be passed when the
     * stack is deployed.
     */
    override fun parameters(parameters: Map) {
      cdkBuilder.parameters(parameters)
    }

    /**
     * @param stackName The name to use for the CloudFormation stack.
     */
    override fun stackName(stackName: String) {
      cdkBuilder.stackName(stackName)
    }

    /**
     * @param templateFile A file relative to the assembly root which contains the CloudFormation
     * template for this stack. 
     */
    override fun templateFile(templateFile: String) {
      cdkBuilder.templateFile(templateFile)
    }

    /**
     * @param terminationProtection Whether to enable termination protection for this stack.
     */
    override fun terminationProtection(terminationProtection: Boolean) {
      cdkBuilder.terminationProtection(terminationProtection)
    }

    public fun build(): software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties =
        cdkBuilder.build()
  }

  private class Wrapper(
    cdkObject: software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties,
  ) : CdkObject(cdkObject),
      AwsCloudFormationStackProperties {
    /**
     * Values for CloudFormation stack parameters that should be passed when the stack is deployed.
     */
    override fun parameters(): Map = unwrap(this).getParameters() ?: emptyMap()

    /**
     * The name to use for the CloudFormation stack.
     *
     * Default: - name derived from artifact ID
     */
    override fun stackName(): String? = unwrap(this).getStackName()

    /**
     * A file relative to the assembly root which contains the CloudFormation template for this
     * stack.
     */
    override fun templateFile(): String = unwrap(this).getTemplateFile()

    /**
     * Whether to enable termination protection for this stack.
     *
     * Default: false
     */
    override fun terminationProtection(): Boolean? = unwrap(this).getTerminationProtection()
  }

  public companion object {
    public operator fun invoke(block: Builder.() -> Unit = {}): AwsCloudFormationStackProperties {
      val builderImpl = BuilderImpl()
      return Wrapper(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties):
        AwsCloudFormationStackProperties = CdkObjectWrappers.wrap(cdkObject) as?
        AwsCloudFormationStackProperties ?: Wrapper(cdkObject)

    internal fun unwrap(wrapped: AwsCloudFormationStackProperties):
        software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties = (wrapped as
        CdkObject).cdkObject as software.amazon.awscdk.cxapi.AwsCloudFormationStackProperties
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy