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

io.cloudshiftdev.awscdk.services.ssm.StringParameter.kt Maven / Gradle / Ivy

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

package io.cloudshiftdev.awscdk.services.ssm

import io.cloudshiftdev.awscdk.Resource
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.services.iam.Grant
import io.cloudshiftdev.awscdk.services.iam.IGrantable
import io.cloudshiftdev.awscdk.services.kms.IKey
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.Number
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmName
import io.cloudshiftdev.constructs.Construct as CloudshiftdevConstructsConstruct
import software.constructs.Construct as SoftwareConstructsConstruct

/**
 * Creates a new String SSM Parameter.
 *
 * Example:
 *
 * ```
 * StringParameter ssmParameter = StringParameter.Builder.create(this, "mySsmParameter")
 * .parameterName("mySsmParameter")
 * .stringValue("mySsmParameterValue")
 * .build();
 * ```
 */
public open class StringParameter(
  cdkObject: software.amazon.awscdk.services.ssm.StringParameter,
) : Resource(cdkObject),
    IStringParameter,
    IParameter {
  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: StringParameterProps,
  ) :
      this(software.amazon.awscdk.services.ssm.StringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id, props.let(StringParameterProps.Companion::unwrap))
  )

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

  /**
   * The encryption key that is used to encrypt this parameter.
   *
   * Default: - default master key
   */
  public open fun encryptionKey(): IKey? = unwrap(this).getEncryptionKey()?.let(IKey::wrap)

  /**
   * Grants read (DescribeParameter, GetParameters, GetParameter, GetParameterHistory) permissions
   * on the SSM Parameter.
   *
   * @param grantee 
   */
  public override fun grantRead(grantee: IGrantable): Grant =
      unwrap(this).grantRead(grantee.let(IGrantable.Companion::unwrap)).let(Grant::wrap)

  /**
   * Grants write (PutParameter) permissions on the SSM Parameter.
   *
   * @param grantee 
   */
  public override fun grantWrite(grantee: IGrantable): Grant =
      unwrap(this).grantWrite(grantee.let(IGrantable.Companion::unwrap)).let(Grant::wrap)

  /**
   * The ARN of the SSM Parameter resource.
   */
  public override fun parameterArn(): String = unwrap(this).getParameterArn()

  /**
   * The name of the SSM Parameter resource.
   */
  public override fun parameterName(): String = unwrap(this).getParameterName()

  /**
   * The type of the SSM Parameter resource.
   */
  public override fun parameterType(): String = unwrap(this).getParameterType()

  /**
   * The parameter value.
   *
   * Value must not nest another parameter. Do not use {{}} in the value.
   */
  public override fun stringValue(): String = unwrap(this).getStringValue()

  /**
   * A fluent builder for [io.cloudshiftdev.awscdk.services.ssm.StringParameter].
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * A regular expression used to validate the parameter value.
     *
     * For example, for String types with values restricted to
     * numbers, you can specify the following: `^\d+$`
     *
     * Default: no validation is performed
     *
     * @param allowedPattern A regular expression used to validate the parameter value. 
     */
    public fun allowedPattern(allowedPattern: String)

    /**
     * The data type of the parameter, such as `text` or `aws:ec2:image`.
     *
     * Default: ParameterDataType.TEXT
     *
     * @param dataType The data type of the parameter, such as `text` or `aws:ec2:image`. 
     */
    public fun dataType(dataType: ParameterDataType)

    /**
     * Information about the parameter that you want to add to the system.
     *
     * Default: none
     *
     * @param description Information about the parameter that you want to add to the system. 
     */
    public fun description(description: String)

    /**
     * The name of the parameter.
     *
     * Default: - a name will be generated by CloudFormation
     *
     * @param parameterName The name of the parameter. 
     */
    public fun parameterName(parameterName: String)

    /**
     * Indicates whether the parameter name is a simple name.
     *
     * A parameter name
     * without any "/" is considered a simple name. If the parameter name includes
     * "/", setting simpleName to true might cause unintended issues such
     * as duplicate "/" in the resulting ARN.
     *
     * This is required only if `parameterName` is a token, which means we
     * are unable to detect if the name is simple or "path-like" for the purpose
     * of rendering SSM parameter ARNs.
     *
     * If `parameterName` is not specified, `simpleName` must be `true` (or
     * undefined) since the name generated by AWS CloudFormation is always a
     * simple name.
     *
     * Default: - auto-detect based on `parameterName`
     *
     * @param simpleName Indicates whether the parameter name is a simple name. 
     */
    public fun simpleName(simpleName: Boolean)

    /**
     * The value of the parameter.
     *
     * It may not reference another parameter and `{{}}` cannot be used in the value.
     *
     * @param stringValue The value of the parameter. 
     */
    public fun stringValue(stringValue: String)

    /**
     * The tier of the string parameter.
     *
     * Default: - undefined
     *
     * @param tier The tier of the string parameter. 
     */
    public fun tier(tier: ParameterTier)

    /**
     * (deprecated) The type of the string parameter.
     *
     * Default: ParameterType.STRING
     *
     * * type will always be 'String'
     * @param type The type of the string parameter. 
     */
    @Deprecated(message = "deprecated in CDK")
    public fun type(type: ParameterType)
  }

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

    /**
     * A regular expression used to validate the parameter value.
     *
     * For example, for String types with values restricted to
     * numbers, you can specify the following: `^\d+$`
     *
     * Default: no validation is performed
     *
     * @param allowedPattern A regular expression used to validate the parameter value. 
     */
    override fun allowedPattern(allowedPattern: String) {
      cdkBuilder.allowedPattern(allowedPattern)
    }

    /**
     * The data type of the parameter, such as `text` or `aws:ec2:image`.
     *
     * Default: ParameterDataType.TEXT
     *
     * @param dataType The data type of the parameter, such as `text` or `aws:ec2:image`. 
     */
    override fun dataType(dataType: ParameterDataType) {
      cdkBuilder.dataType(dataType.let(ParameterDataType.Companion::unwrap))
    }

    /**
     * Information about the parameter that you want to add to the system.
     *
     * Default: none
     *
     * @param description Information about the parameter that you want to add to the system. 
     */
    override fun description(description: String) {
      cdkBuilder.description(description)
    }

    /**
     * The name of the parameter.
     *
     * Default: - a name will be generated by CloudFormation
     *
     * @param parameterName The name of the parameter. 
     */
    override fun parameterName(parameterName: String) {
      cdkBuilder.parameterName(parameterName)
    }

    /**
     * Indicates whether the parameter name is a simple name.
     *
     * A parameter name
     * without any "/" is considered a simple name. If the parameter name includes
     * "/", setting simpleName to true might cause unintended issues such
     * as duplicate "/" in the resulting ARN.
     *
     * This is required only if `parameterName` is a token, which means we
     * are unable to detect if the name is simple or "path-like" for the purpose
     * of rendering SSM parameter ARNs.
     *
     * If `parameterName` is not specified, `simpleName` must be `true` (or
     * undefined) since the name generated by AWS CloudFormation is always a
     * simple name.
     *
     * Default: - auto-detect based on `parameterName`
     *
     * @param simpleName Indicates whether the parameter name is a simple name. 
     */
    override fun simpleName(simpleName: Boolean) {
      cdkBuilder.simpleName(simpleName)
    }

    /**
     * The value of the parameter.
     *
     * It may not reference another parameter and `{{}}` cannot be used in the value.
     *
     * @param stringValue The value of the parameter. 
     */
    override fun stringValue(stringValue: String) {
      cdkBuilder.stringValue(stringValue)
    }

    /**
     * The tier of the string parameter.
     *
     * Default: - undefined
     *
     * @param tier The tier of the string parameter. 
     */
    override fun tier(tier: ParameterTier) {
      cdkBuilder.tier(tier.let(ParameterTier.Companion::unwrap))
    }

    /**
     * (deprecated) The type of the string parameter.
     *
     * Default: ParameterType.STRING
     *
     * * type will always be 'String'
     * @param type The type of the string parameter. 
     */
    @Deprecated(message = "deprecated in CDK")
    override fun type(type: ParameterType) {
      cdkBuilder.type(type.let(ParameterType.Companion::unwrap))
    }

    public fun build(): software.amazon.awscdk.services.ssm.StringParameter = cdkBuilder.build()
  }

  public companion object {
    public fun fromSecureStringParameterAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: SecureStringParameterAttributes,
    ): IStringParameter =
        software.amazon.awscdk.services.ssm.StringParameter.fromSecureStringParameterAttributes(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id,
        attrs.let(SecureStringParameterAttributes.Companion::unwrap)).let(IStringParameter::wrap)

    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("64b1b55fdfa5b42ba90555680348f37a5f7eb9a70ce7485030f807e3bdaace4a")
    public fun fromSecureStringParameterAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: SecureStringParameterAttributes.Builder.() -> Unit,
    ): IStringParameter = fromSecureStringParameterAttributes(scope, id,
        SecureStringParameterAttributes(attrs))

    public fun fromStringParameterArn(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      stringParameterArn: String,
    ): IStringParameter =
        software.amazon.awscdk.services.ssm.StringParameter.fromStringParameterArn(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, stringParameterArn).let(IStringParameter::wrap)

    public fun fromStringParameterAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: StringParameterAttributes,
    ): IStringParameter =
        software.amazon.awscdk.services.ssm.StringParameter.fromStringParameterAttributes(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, attrs.let(StringParameterAttributes.Companion::unwrap)).let(IStringParameter::wrap)

    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("123d9102253eb9c07606d49a45b8ce2ebe4db6917a9f117b688a1772ac6e5f30")
    public fun fromStringParameterAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: StringParameterAttributes.Builder.() -> Unit,
    ): IStringParameter = fromStringParameterAttributes(scope, id, StringParameterAttributes(attrs))

    public fun fromStringParameterName(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      stringParameterName: String,
    ): IStringParameter =
        software.amazon.awscdk.services.ssm.StringParameter.fromStringParameterName(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, stringParameterName).let(IStringParameter::wrap)

    @Deprecated(message = "deprecated in CDK")
    public fun valueForSecureStringParameter(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      version: Number,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForSecureStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, version)

    public fun valueForStringParameter(scope: CloudshiftdevConstructsConstruct,
        parameterName: String): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName)

    public fun valueForStringParameter(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      version: Number,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, version)

    @Deprecated(message = "deprecated in CDK")
    public fun valueForTypedStringParameter(scope: CloudshiftdevConstructsConstruct,
        parameterName: String): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName)

    @Deprecated(message = "deprecated in CDK")
    public fun valueForTypedStringParameter(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      type: ParameterType,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, type.let(ParameterType.Companion::unwrap))

    @Deprecated(message = "deprecated in CDK")
    public fun valueForTypedStringParameter(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      type: ParameterType,
      version: Number,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameter(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, type.let(ParameterType.Companion::unwrap), version)

    public fun valueForTypedStringParameterV2(scope: CloudshiftdevConstructsConstruct,
        parameterName: String): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameterV2(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName)

    public fun valueForTypedStringParameterV2(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      type: ParameterValueType,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameterV2(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, type.let(ParameterValueType.Companion::unwrap))

    public fun valueForTypedStringParameterV2(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      type: ParameterValueType,
      version: Number,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueForTypedStringParameterV2(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, type.let(ParameterValueType.Companion::unwrap), version)

    public fun valueFromLookup(scope: CloudshiftdevConstructsConstruct, parameterName: String):
        String =
        software.amazon.awscdk.services.ssm.StringParameter.valueFromLookup(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName)

    public fun valueFromLookup(
      scope: CloudshiftdevConstructsConstruct,
      parameterName: String,
      defaultValue: String,
    ): String =
        software.amazon.awscdk.services.ssm.StringParameter.valueFromLookup(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        parameterName, defaultValue)

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

    internal fun wrap(cdkObject: software.amazon.awscdk.services.ssm.StringParameter):
        StringParameter = StringParameter(cdkObject)

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy