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

com.pulumi.gitlab.kotlin.ProjectAccessTokenArgs.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.

The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gitlab.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gitlab.ProjectAccessTokenArgs.builder
import com.pulumi.gitlab.kotlin.inputs.ProjectAccessTokenRotationConfigurationArgs
import com.pulumi.gitlab.kotlin.inputs.ProjectAccessTokenRotationConfigurationArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName

/**
 * The `gitlab.ProjectAccessToken` resource allows to manage the lifecycle of a project access token.
 * > Observability scopes are in beta and may not work on all instances. See more details in [the documentation](https://docs.gitlab.com/ee/operations/tracing.html)
 * > Use `rotation_configuration` to automatically rotate tokens instead of using `timestamp()` as timestamp will cause changes with every plan. `pulumi up` must still be run to rotate the token.
 * > Due to [Automatic reuse detection](https://docs.gitlab.com/ee/api/project_access_tokens.html#automatic-reuse-detection) it's possible that a new Project Access Token will immediately be revoked. Check if an old process using the old token is running if this happens.
 * **Upstream API**: [GitLab API docs](https://docs.gitlab.com/ee/api/project_access_tokens.html)
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gitlab from "@pulumi/gitlab";
 * const example = new gitlab.ProjectAccessToken("example", {
 *     project: "25",
 *     name: "Example project access token",
 *     expiresAt: "2020-03-14",
 *     accessLevel: "reporter",
 *     scopes: ["api"],
 * });
 * const exampleProjectVariable = new gitlab.ProjectVariable("example", {
 *     project: exampleGitlabProject.id,
 *     key: "pat",
 *     value: example.token,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gitlab as gitlab
 * example = gitlab.ProjectAccessToken("example",
 *     project="25",
 *     name="Example project access token",
 *     expires_at="2020-03-14",
 *     access_level="reporter",
 *     scopes=["api"])
 * example_project_variable = gitlab.ProjectVariable("example",
 *     project=example_gitlab_project["id"],
 *     key="pat",
 *     value=example.token)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using GitLab = Pulumi.GitLab;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new GitLab.ProjectAccessToken("example", new()
 *     {
 *         Project = "25",
 *         Name = "Example project access token",
 *         ExpiresAt = "2020-03-14",
 *         AccessLevel = "reporter",
 *         Scopes = new[]
 *         {
 *             "api",
 *         },
 *     });
 *     var exampleProjectVariable = new GitLab.ProjectVariable("example", new()
 *     {
 *         Project = exampleGitlabProject.Id,
 *         Key = "pat",
 *         Value = example.Token,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gitlab/sdk/v8/go/gitlab"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := gitlab.NewProjectAccessToken(ctx, "example", &gitlab.ProjectAccessTokenArgs{
 * 			Project:     pulumi.String("25"),
 * 			Name:        pulumi.String("Example project access token"),
 * 			ExpiresAt:   pulumi.String("2020-03-14"),
 * 			AccessLevel: pulumi.String("reporter"),
 * 			Scopes: pulumi.StringArray{
 * 				pulumi.String("api"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = gitlab.NewProjectVariable(ctx, "example", &gitlab.ProjectVariableArgs{
 * 			Project: pulumi.Any(exampleGitlabProject.Id),
 * 			Key:     pulumi.String("pat"),
 * 			Value:   example.Token,
 * 		})
 * 		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.gitlab.ProjectAccessToken;
 * import com.pulumi.gitlab.ProjectAccessTokenArgs;
 * import com.pulumi.gitlab.ProjectVariable;
 * import com.pulumi.gitlab.ProjectVariableArgs;
 * 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 ProjectAccessToken("example", ProjectAccessTokenArgs.builder()
 *             .project("25")
 *             .name("Example project access token")
 *             .expiresAt("2020-03-14")
 *             .accessLevel("reporter")
 *             .scopes("api")
 *             .build());
 *         var exampleProjectVariable = new ProjectVariable("exampleProjectVariable", ProjectVariableArgs.builder()
 *             .project(exampleGitlabProject.id())
 *             .key("pat")
 *             .value(example.token())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gitlab:ProjectAccessToken
 *     properties:
 *       project: '25'
 *       name: Example project access token
 *       expiresAt: 2020-03-14
 *       accessLevel: reporter
 *       scopes:
 *         - api
 *   exampleProjectVariable:
 *     type: gitlab:ProjectVariable
 *     name: example
 *     properties:
 *       project: ${exampleGitlabProject.id}
 *       key: pat
 *       value: ${example.token}
 * ```
 * 
 * ## Import
 * Starting in Terraform v1.5.0 you can use an import block to import `gitlab_project_access_token`. For example:
 * terraform
 * import {
 *   to = gitlab_project_access_token.example
 *   id = "see CLI command below for ID"
 * }
 * Import using the CLI is supported using the following syntax:
 * A GitLab Project Access Token can be imported using a key composed of `:`, e.g.
 * ```sh
 * $ pulumi import gitlab:index/projectAccessToken:ProjectAccessToken example "12345:1"
 * ```
 * NOTE: the `token` resource attribute is not available for imported resources as this information cannot be read from the GitLab API.
 * @property accessLevel The access level for the project access token. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`. Default is `maintainer`.
 * @property expiresAt When the token will expire, YYYY-MM-DD format. Is automatically set when `rotation_configuration` is used.
 * @property name The name of the project access token.
 * @property project The ID or full path of the project.
 * @property rotationConfiguration The configuration for when to rotate a token automatically. Will not rotate a token until `pulumi up` is run.
 * @property scopes The scopes of the project access token. valid values are: `api`, `read_api`, `read_registry`, `write_registry`, `read_repository`, `write_repository`, `create_runner`, `manage_runner`, `ai_features`, `k8s_proxy`, `read_observability`, `write_observability`
 */
public data class ProjectAccessTokenArgs(
    public val accessLevel: Output? = null,
    public val expiresAt: Output? = null,
    public val name: Output? = null,
    public val project: Output? = null,
    public val rotationConfiguration: Output? = null,
    public val scopes: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.gitlab.ProjectAccessTokenArgs =
        com.pulumi.gitlab.ProjectAccessTokenArgs.builder()
            .accessLevel(accessLevel?.applyValue({ args0 -> args0 }))
            .expiresAt(expiresAt?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .project(project?.applyValue({ args0 -> args0 }))
            .rotationConfiguration(
                rotationConfiguration?.applyValue({ args0 ->
                    args0.let({ args0 ->
                        args0.toJava()
                    })
                }),
            )
            .scopes(scopes?.applyValue({ args0 -> args0.map({ args0 -> args0 }) })).build()
}

/**
 * Builder for [ProjectAccessTokenArgs].
 */
@PulumiTagMarker
public class ProjectAccessTokenArgsBuilder internal constructor() {
    private var accessLevel: Output? = null

    private var expiresAt: Output? = null

    private var name: Output? = null

    private var project: Output? = null

    private var rotationConfiguration: Output? = null

    private var scopes: Output>? = null

    /**
     * @param value The access level for the project access token. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`. Default is `maintainer`.
     */
    @JvmName("cyporvbfdllcxnuv")
    public suspend fun accessLevel(`value`: Output) {
        this.accessLevel = value
    }

    /**
     * @param value When the token will expire, YYYY-MM-DD format. Is automatically set when `rotation_configuration` is used.
     */
    @JvmName("jhxrupifyhvjcjbm")
    public suspend fun expiresAt(`value`: Output) {
        this.expiresAt = value
    }

    /**
     * @param value The name of the project access token.
     */
    @JvmName("agdgcwjtgrqfyqgd")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value The ID or full path of the project.
     */
    @JvmName("xqavkwqtfhcqgxdi")
    public suspend fun project(`value`: Output) {
        this.project = value
    }

    /**
     * @param value The configuration for when to rotate a token automatically. Will not rotate a token until `pulumi up` is run.
     */
    @JvmName("rokihvmouloewcvm")
    public suspend fun rotationConfiguration(`value`: Output) {
        this.rotationConfiguration = value
    }

    /**
     * @param value The scopes of the project access token. valid values are: `api`, `read_api`, `read_registry`, `write_registry`, `read_repository`, `write_repository`, `create_runner`, `manage_runner`, `ai_features`, `k8s_proxy`, `read_observability`, `write_observability`
     */
    @JvmName("doscmqpuarnuvwgl")
    public suspend fun scopes(`value`: Output>) {
        this.scopes = value
    }

    @JvmName("qvvmwaeyaetqeuig")
    public suspend fun scopes(vararg values: Output) {
        this.scopes = Output.all(values.asList())
    }

    /**
     * @param values The scopes of the project access token. valid values are: `api`, `read_api`, `read_registry`, `write_registry`, `read_repository`, `write_repository`, `create_runner`, `manage_runner`, `ai_features`, `k8s_proxy`, `read_observability`, `write_observability`
     */
    @JvmName("jxwgdynvwpsfkexh")
    public suspend fun scopes(values: List>) {
        this.scopes = Output.all(values)
    }

    /**
     * @param value The access level for the project access token. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`. Default is `maintainer`.
     */
    @JvmName("xcjphlcssijbyllq")
    public suspend fun accessLevel(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.accessLevel = mapped
    }

    /**
     * @param value When the token will expire, YYYY-MM-DD format. Is automatically set when `rotation_configuration` is used.
     */
    @JvmName("fjnsyffbmeeydayj")
    public suspend fun expiresAt(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.expiresAt = mapped
    }

    /**
     * @param value The name of the project access token.
     */
    @JvmName("mcbfrgcasbhspfbd")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value The ID or full path of the project.
     */
    @JvmName("qyinanayghfokshf")
    public suspend fun project(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.project = mapped
    }

    /**
     * @param value The configuration for when to rotate a token automatically. Will not rotate a token until `pulumi up` is run.
     */
    @JvmName("momgynnjegfrelyj")
    public suspend fun rotationConfiguration(`value`: ProjectAccessTokenRotationConfigurationArgs?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rotationConfiguration = mapped
    }

    /**
     * @param argument The configuration for when to rotate a token automatically. Will not rotate a token until `pulumi up` is run.
     */
    @JvmName("xcfnptwwldrdasqb")
    public suspend fun rotationConfiguration(argument: suspend ProjectAccessTokenRotationConfigurationArgsBuilder.() -> Unit) {
        val toBeMapped = ProjectAccessTokenRotationConfigurationArgsBuilder().applySuspend {
            argument()
        }.build()
        val mapped = of(toBeMapped)
        this.rotationConfiguration = mapped
    }

    /**
     * @param value The scopes of the project access token. valid values are: `api`, `read_api`, `read_registry`, `write_registry`, `read_repository`, `write_repository`, `create_runner`, `manage_runner`, `ai_features`, `k8s_proxy`, `read_observability`, `write_observability`
     */
    @JvmName("nsyldwmdgolwnrws")
    public suspend fun scopes(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.scopes = mapped
    }

    /**
     * @param values The scopes of the project access token. valid values are: `api`, `read_api`, `read_registry`, `write_registry`, `read_repository`, `write_repository`, `create_runner`, `manage_runner`, `ai_features`, `k8s_proxy`, `read_observability`, `write_observability`
     */
    @JvmName("welenfscgvsqvyxy")
    public suspend fun scopes(vararg values: String) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.scopes = mapped
    }

    internal fun build(): ProjectAccessTokenArgs = ProjectAccessTokenArgs(
        accessLevel = accessLevel,
        expiresAt = expiresAt,
        name = name,
        project = project,
        rotationConfiguration = rotationConfiguration,
        scopes = scopes,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy