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

com.pulumi.azure.kusto.kotlin.DatabasePrincipalAssignment.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.15.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.kusto.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

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

    public var args: DatabasePrincipalAssignmentArgs = DatabasePrincipalAssignmentArgs()

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

/**
 * Manages a Kusto (also known as Azure Data Explorer) Database Principal Assignment.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const current = azure.core.getClientConfig({});
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "KustoRG",
 *     location: "West Europe",
 * });
 * const exampleCluster = new azure.kusto.Cluster("example", {
 *     name: "kustocluster",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: {
 *         name: "Standard_D13_v2",
 *         capacity: 2,
 *     },
 * });
 * const exampleDatabase = new azure.kusto.Database("example", {
 *     name: "KustoDatabase",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     clusterName: exampleCluster.name,
 *     hotCachePeriod: "P7D",
 *     softDeletePeriod: "P31D",
 * });
 * const exampleDatabasePrincipalAssignment = new azure.kusto.DatabasePrincipalAssignment("example", {
 *     name: "KustoPrincipalAssignment",
 *     resourceGroupName: example.name,
 *     clusterName: exampleCluster.name,
 *     databaseName: exampleDatabase.name,
 *     tenantId: current.then(current => current.tenantId),
 *     principalId: current.then(current => current.clientId),
 *     principalType: "App",
 *     role: "Viewer",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * current = azure.core.get_client_config()
 * example = azure.core.ResourceGroup("example",
 *     name="KustoRG",
 *     location="West Europe")
 * example_cluster = azure.kusto.Cluster("example",
 *     name="kustocluster",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku=azure.kusto.ClusterSkuArgs(
 *         name="Standard_D13_v2",
 *         capacity=2,
 *     ))
 * example_database = azure.kusto.Database("example",
 *     name="KustoDatabase",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     cluster_name=example_cluster.name,
 *     hot_cache_period="P7D",
 *     soft_delete_period="P31D")
 * example_database_principal_assignment = azure.kusto.DatabasePrincipalAssignment("example",
 *     name="KustoPrincipalAssignment",
 *     resource_group_name=example.name,
 *     cluster_name=example_cluster.name,
 *     database_name=example_database.name,
 *     tenant_id=current.tenant_id,
 *     principal_id=current.client_id,
 *     principal_type="App",
 *     role="Viewer")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var current = Azure.Core.GetClientConfig.Invoke();
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "KustoRG",
 *         Location = "West Europe",
 *     });
 *     var exampleCluster = new Azure.Kusto.Cluster("example", new()
 *     {
 *         Name = "kustocluster",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = new Azure.Kusto.Inputs.ClusterSkuArgs
 *         {
 *             Name = "Standard_D13_v2",
 *             Capacity = 2,
 *         },
 *     });
 *     var exampleDatabase = new Azure.Kusto.Database("example", new()
 *     {
 *         Name = "KustoDatabase",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         ClusterName = exampleCluster.Name,
 *         HotCachePeriod = "P7D",
 *         SoftDeletePeriod = "P31D",
 *     });
 *     var exampleDatabasePrincipalAssignment = new Azure.Kusto.DatabasePrincipalAssignment("example", new()
 *     {
 *         Name = "KustoPrincipalAssignment",
 *         ResourceGroupName = example.Name,
 *         ClusterName = exampleCluster.Name,
 *         DatabaseName = exampleDatabase.Name,
 *         TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
 *         PrincipalId = current.Apply(getClientConfigResult => getClientConfigResult.ClientId),
 *         PrincipalType = "App",
 *         Role = "Viewer",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/kusto"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		current, err := core.GetClientConfig(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("KustoRG"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleCluster, err := kusto.NewCluster(ctx, "example", &kusto.ClusterArgs{
 * 			Name:              pulumi.String("kustocluster"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku: &kusto.ClusterSkuArgs{
 * 				Name:     pulumi.String("Standard_D13_v2"),
 * 				Capacity: pulumi.Int(2),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleDatabase, err := kusto.NewDatabase(ctx, "example", &kusto.DatabaseArgs{
 * 			Name:              pulumi.String("KustoDatabase"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			ClusterName:       exampleCluster.Name,
 * 			HotCachePeriod:    pulumi.String("P7D"),
 * 			SoftDeletePeriod:  pulumi.String("P31D"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kusto.NewDatabasePrincipalAssignment(ctx, "example", &kusto.DatabasePrincipalAssignmentArgs{
 * 			Name:              pulumi.String("KustoPrincipalAssignment"),
 * 			ResourceGroupName: example.Name,
 * 			ClusterName:       exampleCluster.Name,
 * 			DatabaseName:      exampleDatabase.Name,
 * 			TenantId:          pulumi.String(current.TenantId),
 * 			PrincipalId:       pulumi.String(current.ClientId),
 * 			PrincipalType:     pulumi.String("App"),
 * 			Role:              pulumi.String("Viewer"),
 * 		})
 * 		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.azure.core.CoreFunctions;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.kusto.Cluster;
 * import com.pulumi.azure.kusto.ClusterArgs;
 * import com.pulumi.azure.kusto.inputs.ClusterSkuArgs;
 * import com.pulumi.azure.kusto.Database;
 * import com.pulumi.azure.kusto.DatabaseArgs;
 * import com.pulumi.azure.kusto.DatabasePrincipalAssignment;
 * import com.pulumi.azure.kusto.DatabasePrincipalAssignmentArgs;
 * 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) {
 *         final var current = CoreFunctions.getClientConfig();
 *         var example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("KustoRG")
 *             .location("West Europe")
 *             .build());
 *         var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
 *             .name("kustocluster")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku(ClusterSkuArgs.builder()
 *                 .name("Standard_D13_v2")
 *                 .capacity(2)
 *                 .build())
 *             .build());
 *         var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
 *             .name("KustoDatabase")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .clusterName(exampleCluster.name())
 *             .hotCachePeriod("P7D")
 *             .softDeletePeriod("P31D")
 *             .build());
 *         var exampleDatabasePrincipalAssignment = new DatabasePrincipalAssignment("exampleDatabasePrincipalAssignment", DatabasePrincipalAssignmentArgs.builder()
 *             .name("KustoPrincipalAssignment")
 *             .resourceGroupName(example.name())
 *             .clusterName(exampleCluster.name())
 *             .databaseName(exampleDatabase.name())
 *             .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
 *             .principalId(current.applyValue(getClientConfigResult -> getClientConfigResult.clientId()))
 *             .principalType("App")
 *             .role("Viewer")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: KustoRG
 *       location: West Europe
 *   exampleCluster:
 *     type: azure:kusto:Cluster
 *     name: example
 *     properties:
 *       name: kustocluster
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku:
 *         name: Standard_D13_v2
 *         capacity: 2
 *   exampleDatabase:
 *     type: azure:kusto:Database
 *     name: example
 *     properties:
 *       name: KustoDatabase
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       clusterName: ${exampleCluster.name}
 *       hotCachePeriod: P7D
 *       softDeletePeriod: P31D
 *   exampleDatabasePrincipalAssignment:
 *     type: azure:kusto:DatabasePrincipalAssignment
 *     name: example
 *     properties:
 *       name: KustoPrincipalAssignment
 *       resourceGroupName: ${example.name}
 *       clusterName: ${exampleCluster.name}
 *       databaseName: ${exampleDatabase.name}
 *       tenantId: ${current.tenantId}
 *       principalId: ${current.clientId}
 *       principalType: App
 *       role: Viewer
 * variables:
 *   current:
 *     fn::invoke:
 *       Function: azure:core:getClientConfig
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Kusto Database Principal Assignment can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:kusto/databasePrincipalAssignment:DatabasePrincipalAssignment example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/clusters/cluster1/databases/database1/principalAssignments/assignment1
 * ```
 */
public class DatabasePrincipalAssignment internal constructor(
    override val javaResource: com.pulumi.azure.kusto.DatabasePrincipalAssignment,
) : KotlinCustomResource(javaResource, DatabasePrincipalAssignmentMapper) {
    /**
     * The name of the cluster in which to create the resource. Changing this forces a new resource to be created.
     */
    public val clusterName: Output
        get() = javaResource.clusterName().applyValue({ args0 -> args0 })

    /**
     * The name of the database in which to create the resource. Changing this forces a new resource to be created.
     */
    public val databaseName: Output
        get() = javaResource.databaseName().applyValue({ args0 -> args0 })

    /**
     * The name of the kusto principal assignment. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The object id of the principal. Changing this forces a new resource to be created.
     */
    public val principalId: Output
        get() = javaResource.principalId().applyValue({ args0 -> args0 })

    /**
     * The name of the principal.
     */
    public val principalName: Output
        get() = javaResource.principalName().applyValue({ args0 -> args0 })

    /**
     * The type of the principal. Valid values include `App`, `Group`, `User`. Changing this forces a new resource to be created.
     */
    public val principalType: Output
        get() = javaResource.principalType().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group in which to create the resource. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The database role assigned to the principal. Valid values include `Admin`, `Ingestor`, `Monitor`, `UnrestrictedViewer`, `User` and `Viewer`. Changing this forces a new resource to be created.
     */
    public val role: Output
        get() = javaResource.role().applyValue({ args0 -> args0 })

    /**
     * The tenant id in which the principal resides. Changing this forces a new resource to be created.
     */
    public val tenantId: Output
        get() = javaResource.tenantId().applyValue({ args0 -> args0 })

    /**
     * The name of the tenant.
     */
    public val tenantName: Output
        get() = javaResource.tenantName().applyValue({ args0 -> args0 })
}

public object DatabasePrincipalAssignmentMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.kusto.DatabasePrincipalAssignment::class == javaResource::class

    override fun map(javaResource: Resource): DatabasePrincipalAssignment =
        DatabasePrincipalAssignment(
            javaResource as
                com.pulumi.azure.kusto.DatabasePrincipalAssignment,
        )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy