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

com.pulumi.vault.kotlin.Token.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: 6.4.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.vault.kotlin

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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

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

    public var args: TokenArgs = TokenArgs()

    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 TokenArgsBuilder.() -> Unit) {
        val builder = TokenArgsBuilder()
        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(): Token {
        val builtJavaResource = com.pulumi.vault.Token(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Token(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as vault from "@pulumi/vault";
 * const example = new vault.Token("example", {
 *     roleName: "app",
 *     policies: [
 *         "policy1",
 *         "policy2",
 *     ],
 *     renewable: true,
 *     ttl: "24h",
 *     renewMinLease: 43200,
 *     renewIncrement: 86400,
 *     metadata: {
 *         purpose: "service-account",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_vault as vault
 * example = vault.Token("example",
 *     role_name="app",
 *     policies=[
 *         "policy1",
 *         "policy2",
 *     ],
 *     renewable=True,
 *     ttl="24h",
 *     renew_min_lease=43200,
 *     renew_increment=86400,
 *     metadata={
 *         "purpose": "service-account",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Vault.Token("example", new()
 *     {
 *         RoleName = "app",
 *         Policies = new[]
 *         {
 *             "policy1",
 *             "policy2",
 *         },
 *         Renewable = true,
 *         Ttl = "24h",
 *         RenewMinLease = 43200,
 *         RenewIncrement = 86400,
 *         Metadata =
 *         {
 *             { "purpose", "service-account" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := vault.NewToken(ctx, "example", &vault.TokenArgs{
 * 			RoleName: pulumi.String("app"),
 * 			Policies: pulumi.StringArray{
 * 				pulumi.String("policy1"),
 * 				pulumi.String("policy2"),
 * 			},
 * 			Renewable:      pulumi.Bool(true),
 * 			Ttl:            pulumi.String("24h"),
 * 			RenewMinLease:  pulumi.Int(43200),
 * 			RenewIncrement: pulumi.Int(86400),
 * 			Metadata: pulumi.StringMap{
 * 				"purpose": pulumi.String("service-account"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.vault.Token;
 * import com.pulumi.vault.TokenArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new Token("example", TokenArgs.builder()
 *             .roleName("app")
 *             .policies(
 *                 "policy1",
 *                 "policy2")
 *             .renewable(true)
 *             .ttl("24h")
 *             .renewMinLease(43200)
 *             .renewIncrement(86400)
 *             .metadata(Map.of("purpose", "service-account"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: vault:Token
 *     properties:
 *       roleName: app
 *       policies:
 *         - policy1
 *         - policy2
 *       renewable: true
 *       ttl: 24h
 *       renewMinLease: 43200
 *       renewIncrement: 86400
 *       metadata:
 *         purpose: service-account
 * ```
 * 
 * ## Import
 * Tokens can be imported using its `id` as accessor id, e.g.
 * ```sh
 * $ pulumi import vault:index/token:Token example 
 * ```
 */
public class Token internal constructor(
    override val javaResource: com.pulumi.vault.Token,
) : KotlinCustomResource(javaResource, TokenMapper) {
    /**
     * String containing the client token if stored in present file
     */
    public val clientToken: Output
        get() = javaResource.clientToken().applyValue({ args0 -> args0 })

    /**
     * String containing the token display name
     */
    public val displayName: Output?
        get() = javaResource.displayName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The explicit max TTL of this token. This is specified as a numeric string with suffix like "30s" ro "5m"
     */
    public val explicitMaxTtl: Output?
        get() = javaResource.explicitMaxTtl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * String containing the token lease duration if present in state file
     */
    public val leaseDuration: Output
        get() = javaResource.leaseDuration().applyValue({ args0 -> args0 })

    /**
     * String containing the token lease started time if present in state file
     */
    public val leaseStarted: Output
        get() = javaResource.leaseStarted().applyValue({ args0 -> args0 })

    /**
     * Metadata to be set on this token
     */
    public val metadata: Output>?
        get() = javaResource.metadata().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The namespace to provision the resource in.
     * The value should not contain leading or trailing forward slashes.
     * The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
     * *Available only for Vault Enterprise*.
     */
    public val namespace: Output?
        get() = javaResource.namespace().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Flag to not attach the default policy to this token
     */
    public val noDefaultPolicy: Output?
        get() = javaResource.noDefaultPolicy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Flag to create a token without parent
     */
    public val noParent: Output
        get() = javaResource.noParent().applyValue({ args0 -> args0 })

    /**
     * The number of allowed uses of this token
     */
    public val numUses: Output
        get() = javaResource.numUses().applyValue({ args0 -> args0 })

    /**
     * The period of this token. This is specified as a numeric string with suffix like "30s" ro "5m"
     */
    public val period: Output?
        get() = javaResource.period().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * List of policies to attach to this token
     */
    public val policies: Output>?
        get() = javaResource.policies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * The renew increment. This is specified in seconds
     */
    public val renewIncrement: Output?
        get() = javaResource.renewIncrement().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The minimal lease to renew this token
     */
    public val renewMinLease: Output?
        get() = javaResource.renewMinLease().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Flag to allow to renew this token
     */
    public val renewable: Output
        get() = javaResource.renewable().applyValue({ args0 -> args0 })

    /**
     * The token role name
     */
    public val roleName: Output?
        get() = javaResource.roleName().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The TTL period of this token. This is specified as a numeric string with suffix like "30s" ro "5m"
     */
    public val ttl: Output?
        get() = javaResource.ttl().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The client wrapped token.
     */
    public val wrappedToken: Output
        get() = javaResource.wrappedToken().applyValue({ args0 -> args0 })

    /**
     * The client wrapping accessor.
     */
    public val wrappingAccessor: Output
        get() = javaResource.wrappingAccessor().applyValue({ args0 -> args0 })

    /**
     * The TTL period of the wrapped token.
     */
    public val wrappingTtl: Output?
        get() = javaResource.wrappingTtl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object TokenMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.vault.Token::class == javaResource::class

    override fun map(javaResource: Resource): Token = Token(javaResource as com.pulumi.vault.Token)
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy