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

com.pulumi.vault.github.kotlin.User.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.vault.github.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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

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

    public var args: UserArgs = UserArgs()

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

/**
 * Manages policy mappings for Github Users authenticated via Github. See the [Vault
 * documentation](https://www.vaultproject.io/docs/auth/github/) for more
 * information.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as vault from "@pulumi/vault";
 * const example = new vault.github.AuthBackend("example", {organization: "myorg"});
 * const tfUser = new vault.github.User("tf_user", {
 *     backend: example.id,
 *     user: "john.doe",
 *     policies: [
 *         "developer",
 *         "read-only",
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_vault as vault
 * example = vault.github.AuthBackend("example", organization="myorg")
 * tf_user = vault.github.User("tf_user",
 *     backend=example.id,
 *     user="john.doe",
 *     policies=[
 *         "developer",
 *         "read-only",
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Vault.GitHub.AuthBackend("example", new()
 *     {
 *         Organization = "myorg",
 *     });
 *     var tfUser = new Vault.GitHub.User("tf_user", new()
 *     {
 *         Backend = example.Id,
 *         UserName = "john.doe",
 *         Policies = new[]
 *         {
 *             "developer",
 *             "read-only",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/github"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := github.NewAuthBackend(ctx, "example", &github.AuthBackendArgs{
 * 			Organization: pulumi.String("myorg"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = github.NewUser(ctx, "tf_user", &github.UserArgs{
 * 			Backend: example.ID(),
 * 			User:    pulumi.String("john.doe"),
 * 			Policies: pulumi.StringArray{
 * 				pulumi.String("developer"),
 * 				pulumi.String("read-only"),
 * 			},
 * 		})
 * 		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.github.AuthBackend;
 * import com.pulumi.vault.github.AuthBackendArgs;
 * import com.pulumi.vault.github.User;
 * import com.pulumi.vault.github.UserArgs;
 * 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 AuthBackend("example", AuthBackendArgs.builder()
 *             .organization("myorg")
 *             .build());
 *         var tfUser = new User("tfUser", UserArgs.builder()
 *             .backend(example.id())
 *             .user("john.doe")
 *             .policies(
 *                 "developer",
 *                 "read-only")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: vault:github:AuthBackend
 *     properties:
 *       organization: myorg
 *   tfUser:
 *     type: vault:github:User
 *     name: tf_user
 *     properties:
 *       backend: ${example.id}
 *       user: john.doe
 *       policies:
 *         - developer
 *         - read-only
 * ```
 * 
 * ## Import
 * Github user mappings can be imported using the `path`, e.g.
 * ```sh
 * $ pulumi import vault:github/user:User tf_user auth/github/map/users/john.doe
 * ```
 */
public class User internal constructor(
    override val javaResource: com.pulumi.vault.github.User,
) : KotlinCustomResource(javaResource, UserMapper) {
    /**
     * Path where the github auth backend is mounted. Defaults to `github`
     * if not specified.
     */
    public val backend: Output?
        get() = javaResource.backend().applyValue({ args0 -> args0.map({ args0 -> args0 }).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) })

    /**
     * An array of strings specifying the policies to be set on tokens issued
     * using this role.
     */
    public val policies: Output>?
        get() = javaResource.policies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * GitHub user name.
     */
    public val user: Output
        get() = javaResource.user().applyValue({ args0 -> args0 })
}

public object UserMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.vault.github.User::class == javaResource::class

    override fun map(javaResource: Resource): User = User(
        javaResource as
            com.pulumi.vault.github.User,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy