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

com.pulumi.cloudflare.kotlin.ApiToken.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 5.49.1.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.kotlin

import com.pulumi.cloudflare.kotlin.outputs.ApiTokenCondition
import com.pulumi.cloudflare.kotlin.outputs.ApiTokenPolicy
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.cloudflare.kotlin.outputs.ApiTokenCondition.Companion.toKotlin as apiTokenConditionToKotlin
import com.pulumi.cloudflare.kotlin.outputs.ApiTokenPolicy.Companion.toKotlin as apiTokenPolicyToKotlin

/**
 * Builder for [ApiToken].
 */
@PulumiTagMarker
public class ApiTokenResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ApiTokenArgs = ApiTokenArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend ApiTokenArgsBuilder.() -> Unit) {
        val builder = ApiTokenArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): ApiToken {
        val builtJavaResource = com.pulumi.cloudflare.ApiToken(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return ApiToken(builtJavaResource)
    }
}

/**
 * Provides a resource which manages Cloudflare API tokens.
 * Read more about permission groups and their applicable scopes in the
 * [developer documentation](https://developers.cloudflare.com/api/tokens/create/permissions).
 */
public class ApiToken internal constructor(
    override val javaResource: com.pulumi.cloudflare.ApiToken,
) : KotlinCustomResource(javaResource, ApiTokenMapper) {
    /**
     * Conditions under which the token should be considered valid.
     */
    public val condition: Output?
        get() = javaResource.condition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    apiTokenConditionToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The expiration time on or after which the token MUST NOT be accepted for processing.
     */
    public val expiresOn: Output?
        get() = javaResource.expiresOn().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Timestamp of when the token was issued.
     */
    public val issuedOn: Output
        get() = javaResource.issuedOn().applyValue({ args0 -> args0 })

    /**
     * Timestamp of when the token was last modified.
     */
    public val modifiedOn: Output
        get() = javaResource.modifiedOn().applyValue({ args0 -> args0 })

    /**
     * Name of the API Token.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The time before which the token MUST NOT be accepted for processing.
     */
    public val notBefore: Output?
        get() = javaResource.notBefore().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Permissions policy. Multiple policy blocks can be defined.
     */
    public val policies: Output>
        get() = javaResource.policies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    apiTokenPolicyToKotlin(args0)
                })
            })
        })

    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    /**
     * The value of the API Token.
     */
    public val `value`: Output
        get() = javaResource.`value`().applyValue({ args0 -> args0 })
}

public object ApiTokenMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.cloudflare.ApiToken::class == javaResource::class

    override fun map(javaResource: Resource): ApiToken = ApiToken(
        javaResource as
            com.pulumi.cloudflare.ApiToken,
    )
}

/**
 * @see [ApiToken].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [ApiToken].
 */
public suspend fun apiToken(name: String, block: suspend ApiTokenResourceBuilder.() -> Unit): ApiToken {
    val builder = ApiTokenResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [ApiToken].
 * @param name The _unique_ name of the resulting resource.
 */
public fun apiToken(name: String): ApiToken {
    val builder = ApiTokenResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy