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

com.pulumi.azure.authorization.kotlin.RoleDefinitionArgs.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.authorization.kotlin

import com.pulumi.azure.authorization.RoleDefinitionArgs.builder
import com.pulumi.azure.authorization.kotlin.inputs.RoleDefinitionPermissionArgs
import com.pulumi.azure.authorization.kotlin.inputs.RoleDefinitionPermissionArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
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

/**
 * Manages a custom Role Definition, used to assign Roles to Users/Principals. See ['Understand role definitions'](https://docs.microsoft.com/azure/role-based-access-control/role-definitions) in the Azure documentation for more details.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const primary = azure.core.getSubscription({});
 * const example = new azure.authorization.RoleDefinition("example", {
 *     name: "my-custom-role",
 *     scope: primary.then(primary => primary.id),
 *     description: "This is a custom role created",
 *     permissions: [{
 *         actions: ["*"],
 *         notActions: [],
 *     }],
 *     assignableScopes: [primary.then(primary => primary.id)],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * primary = azure.core.get_subscription()
 * example = azure.authorization.RoleDefinition("example",
 *     name="my-custom-role",
 *     scope=primary.id,
 *     description="This is a custom role created",
 *     permissions=[{
 *         "actions": ["*"],
 *         "not_actions": [],
 *     }],
 *     assignable_scopes=[primary.id])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var primary = Azure.Core.GetSubscription.Invoke();
 *     var example = new Azure.Authorization.RoleDefinition("example", new()
 *     {
 *         Name = "my-custom-role",
 *         Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
 *         Description = "This is a custom role created",
 *         Permissions = new[]
 *         {
 *             new Azure.Authorization.Inputs.RoleDefinitionPermissionArgs
 *             {
 *                 Actions = new[]
 *                 {
 *                     "*",
 *                 },
 *                 NotActions = new() { },
 *             },
 *         },
 *         AssignableScopes = new[]
 *         {
 *             primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/authorization"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		primary, err := core.LookupSubscription(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = authorization.NewRoleDefinition(ctx, "example", &authorization.RoleDefinitionArgs{
 * 			Name:        pulumi.String("my-custom-role"),
 * 			Scope:       pulumi.String(primary.Id),
 * 			Description: pulumi.String("This is a custom role created"),
 * 			Permissions: authorization.RoleDefinitionPermissionArray{
 * 				&authorization.RoleDefinitionPermissionArgs{
 * 					Actions: pulumi.StringArray{
 * 						pulumi.String("*"),
 * 					},
 * 					NotActions: pulumi.StringArray{},
 * 				},
 * 			},
 * 			AssignableScopes: pulumi.StringArray{
 * 				pulumi.String(primary.Id),
 * 			},
 * 		})
 * 		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.inputs.GetSubscriptionArgs;
 * import com.pulumi.azure.authorization.RoleDefinition;
 * import com.pulumi.azure.authorization.RoleDefinitionArgs;
 * import com.pulumi.azure.authorization.inputs.RoleDefinitionPermissionArgs;
 * 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 primary = CoreFunctions.getSubscription();
 *         var example = new RoleDefinition("example", RoleDefinitionArgs.builder()
 *             .name("my-custom-role")
 *             .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
 *             .description("This is a custom role created")
 *             .permissions(RoleDefinitionPermissionArgs.builder()
 *                 .actions("*")
 *                 .notActions()
 *                 .build())
 *             .assignableScopes(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:authorization:RoleDefinition
 *     properties:
 *       name: my-custom-role
 *       scope: ${primary.id}
 *       description: This is a custom role created
 *       permissions:
 *         - actions:
 *             - '*'
 *           notActions: []
 *       assignableScopes:
 *         - ${primary.id}
 * variables:
 *   primary:
 *     fn::invoke:
 *       Function: azure:core:getSubscription
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Role Definitions can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:authorization/roleDefinition:RoleDefinition example "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000|/subscriptions/00000000-0000-0000-0000-000000000000"
 * ```
 * @property assignableScopes One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
 * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
 * @property description A description of the Role Definition.
 * @property name The name of the Role Definition.
 * @property permissions A `permissions` block as defined below.
 * @property roleDefinitionId A unique UUID/GUID which identifies this role - one will be generated if not specified. Changing this forces a new resource to be created.
 * @property scope The scope at which the Role Definition applies to, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`. It is recommended to use the first entry of the `assignable_scopes`. Changing this forces a new resource to be created.
 */
public data class RoleDefinitionArgs(
    public val assignableScopes: Output>? = null,
    public val description: Output? = null,
    public val name: Output? = null,
    public val permissions: Output>? = null,
    public val roleDefinitionId: Output? = null,
    public val scope: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azure.authorization.RoleDefinitionArgs =
        com.pulumi.azure.authorization.RoleDefinitionArgs.builder()
            .assignableScopes(assignableScopes?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
            .description(description?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .permissions(
                permissions?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .roleDefinitionId(roleDefinitionId?.applyValue({ args0 -> args0 }))
            .scope(scope?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [RoleDefinitionArgs].
 */
@PulumiTagMarker
public class RoleDefinitionArgsBuilder internal constructor() {
    private var assignableScopes: Output>? = null

    private var description: Output? = null

    private var name: Output? = null

    private var permissions: Output>? = null

    private var roleDefinitionId: Output? = null

    private var scope: Output? = null

    /**
     * @param value One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
     * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
     */
    @JvmName("mwqnekoarnnkstqy")
    public suspend fun assignableScopes(`value`: Output>) {
        this.assignableScopes = value
    }

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

    /**
     * @param values One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
     * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
     */
    @JvmName("vtlonklxvgccpaql")
    public suspend fun assignableScopes(values: List>) {
        this.assignableScopes = Output.all(values)
    }

    /**
     * @param value A description of the Role Definition.
     */
    @JvmName("wncycdefkunwwfsi")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

    /**
     * @param value The name of the Role Definition.
     */
    @JvmName("hbnprxnpdpleyopc")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value A `permissions` block as defined below.
     */
    @JvmName("boekxihxochvuvbp")
    public suspend fun permissions(`value`: Output>) {
        this.permissions = value
    }

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

    /**
     * @param values A `permissions` block as defined below.
     */
    @JvmName("cqhakrmpepyfxekl")
    public suspend fun permissions(values: List>) {
        this.permissions = Output.all(values)
    }

    /**
     * @param value A unique UUID/GUID which identifies this role - one will be generated if not specified. Changing this forces a new resource to be created.
     */
    @JvmName("vhsfbrcaqcfmdsqd")
    public suspend fun roleDefinitionId(`value`: Output) {
        this.roleDefinitionId = value
    }

    /**
     * @param value The scope at which the Role Definition applies to, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`. It is recommended to use the first entry of the `assignable_scopes`. Changing this forces a new resource to be created.
     */
    @JvmName("iugexgucaoafgsok")
    public suspend fun scope(`value`: Output) {
        this.scope = value
    }

    /**
     * @param value One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
     * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
     */
    @JvmName("txnkrmvaubynggki")
    public suspend fun assignableScopes(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.assignableScopes = mapped
    }

    /**
     * @param values One or more assignable scopes for this Role Definition, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`.
     * > **NOTE:** The value for `scope` is automatically included in this list if no other values supplied.
     */
    @JvmName("xsairghkdunpljrf")
    public suspend fun assignableScopes(vararg values: String) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.assignableScopes = mapped
    }

    /**
     * @param value A description of the Role Definition.
     */
    @JvmName("bdowbpvkfopdgfyo")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

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

    /**
     * @param value A `permissions` block as defined below.
     */
    @JvmName("aoasitvuqygbthxc")
    public suspend fun permissions(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.permissions = mapped
    }

    /**
     * @param argument A `permissions` block as defined below.
     */
    @JvmName("cyekjggpbxlysvvr")
    public suspend fun permissions(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            RoleDefinitionPermissionArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.permissions = mapped
    }

    /**
     * @param argument A `permissions` block as defined below.
     */
    @JvmName("naghfpagdmufdgsh")
    public suspend fun permissions(vararg argument: suspend RoleDefinitionPermissionArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            RoleDefinitionPermissionArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.permissions = mapped
    }

    /**
     * @param argument A `permissions` block as defined below.
     */
    @JvmName("nuqnfssdhdpfxdgp")
    public suspend fun permissions(argument: suspend RoleDefinitionPermissionArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            RoleDefinitionPermissionArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.permissions = mapped
    }

    /**
     * @param values A `permissions` block as defined below.
     */
    @JvmName("pvympplygkklxqbn")
    public suspend fun permissions(vararg values: RoleDefinitionPermissionArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.permissions = mapped
    }

    /**
     * @param value A unique UUID/GUID which identifies this role - one will be generated if not specified. Changing this forces a new resource to be created.
     */
    @JvmName("pwhraoxglulbjcxk")
    public suspend fun roleDefinitionId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.roleDefinitionId = mapped
    }

    /**
     * @param value The scope at which the Role Definition applies to, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`. It is recommended to use the first entry of the `assignable_scopes`. Changing this forces a new resource to be created.
     */
    @JvmName("yomsybkwoxpqptha")
    public suspend fun scope(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.scope = mapped
    }

    internal fun build(): RoleDefinitionArgs = RoleDefinitionArgs(
        assignableScopes = assignableScopes,
        description = description,
        name = name,
        permissions = permissions,
        roleDefinitionId = roleDefinitionId,
        scope = scope,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy