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

com.pulumi.azure.role.kotlin.RoleFunctions.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.role.kotlin

import com.pulumi.azure.role.RoleFunctions.getRoleDefinitionPlain
import com.pulumi.azure.role.kotlin.inputs.GetRoleDefinitionPlainArgs
import com.pulumi.azure.role.kotlin.inputs.GetRoleDefinitionPlainArgsBuilder
import com.pulumi.azure.role.kotlin.outputs.GetRoleDefinitionResult
import com.pulumi.azure.role.kotlin.outputs.GetRoleDefinitionResult.Companion.toKotlin
import kotlinx.coroutines.future.await
import kotlin.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

public object RoleFunctions {
    /**
     * Use this data source to access information about an existing Role Definition.
     * ## Example Usage
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as azure from "@pulumi/azure";
     * const primary = azure.core.getSubscription({});
     * const customRoleDefinition = new azure.authorization.RoleDefinition("custom", {
     *     roleDefinitionId: "00000000-0000-0000-0000-000000000000",
     *     name: "CustomRoleDef",
     *     scope: primary.then(primary => primary.id),
     * });
     * const custom = pulumi.all([customRoleDefinition.roleDefinitionId, primary]).apply(([roleDefinitionId, primary]) => azure.authorization.getRoleDefinitionOutput({
     *     roleDefinitionId: roleDefinitionId,
     *     scope: primary.id,
     * }));
     * const custom-byname = pulumi.all([customRoleDefinition.name, primary]).apply(([name, primary]) => azure.authorization.getRoleDefinitionOutput({
     *     name: name,
     *     scope: primary.id,
     * }));
     * const builtin = azure.authorization.getRoleDefinition({
     *     name: "Contributor",
     * });
     * export const customRoleDefinitionId = custom.apply(custom => custom.id);
     * export const contributorRoleDefinitionId = builtin.then(builtin => builtin.id);
     * ```
     * ```python
     * import pulumi
     * import pulumi_azure as azure
     * primary = azure.core.get_subscription()
     * custom_role_definition = azure.authorization.RoleDefinition("custom",
     *     role_definition_id="00000000-0000-0000-0000-000000000000",
     *     name="CustomRoleDef",
     *     scope=primary.id)
     * custom = custom_role_definition.role_definition_id.apply(lambda role_definition_id: azure.authorization.get_role_definition_output(role_definition_id=role_definition_id,
     *     scope=primary.id))
     * custom_byname = custom_role_definition.name.apply(lambda name: azure.authorization.get_role_definition_output(name=name,
     *     scope=primary.id))
     * builtin = azure.authorization.get_role_definition(name="Contributor")
     * pulumi.export("customRoleDefinitionId", custom.id)
     * pulumi.export("contributorRoleDefinitionId", builtin.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 customRoleDefinition = new Azure.Authorization.RoleDefinition("custom", new()
     *     {
     *         RoleDefinitionId = "00000000-0000-0000-0000-000000000000",
     *         Name = "CustomRoleDef",
     *         Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
     *     });
     *     var custom = Azure.Authorization.GetRoleDefinition.Invoke(new()
     *     {
     *         RoleDefinitionId = customRoleDefinition.RoleDefinitionId,
     *         Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
     *     });
     *     var custom_byname = Azure.Authorization.GetRoleDefinition.Invoke(new()
     *     {
     *         Name = customRoleDefinition.Name,
     *         Scope = primary.Apply(getSubscriptionResult => getSubscriptionResult.Id),
     *     });
     *     var builtin = Azure.Authorization.GetRoleDefinition.Invoke(new()
     *     {
     *         Name = "Contributor",
     *     });
     *     return new Dictionary
     *     {
     *         ["customRoleDefinitionId"] = custom.Apply(getRoleDefinitionResult => getRoleDefinitionResult.Id),
     *         ["contributorRoleDefinitionId"] = builtin.Apply(getRoleDefinitionResult => getRoleDefinitionResult.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
     * 		}
     * 		customRoleDefinition, err := authorization.NewRoleDefinition(ctx, "custom", &authorization.RoleDefinitionArgs{
     * 			RoleDefinitionId: pulumi.String("00000000-0000-0000-0000-000000000000"),
     * 			Name:             pulumi.String("CustomRoleDef"),
     * 			Scope:            pulumi.String(primary.Id),
     * 		})
     * 		if err != nil {
     * 			return err
     * 		}
     * 		custom := customRoleDefinition.RoleDefinitionId.ApplyT(func(roleDefinitionId string) (authorization.GetRoleDefinitionResult, error) {
     * 			return authorization.GetRoleDefinitionResult(interface{}(authorization.LookupRoleDefinitionOutput(ctx, authorization.GetRoleDefinitionOutputArgs{
     * 				RoleDefinitionId: roleDefinitionId,
     * 				Scope:            primary.Id,
     * 			}, nil))), nil
     * 		}).(authorization.GetRoleDefinitionResultOutput)
     * 		_ = customRoleDefinition.Name.ApplyT(func(name string) (authorization.GetRoleDefinitionResult, error) {
     * 			return authorization.GetRoleDefinitionResult(interface{}(authorization.LookupRoleDefinitionOutput(ctx, authorization.GetRoleDefinitionOutputArgs{
     * 				Name:  name,
     * 				Scope: primary.Id,
     * 			}, nil))), nil
     * 		}).(authorization.GetRoleDefinitionResultOutput)
     * 		builtin, err := authorization.LookupRoleDefinition(ctx, &authorization.LookupRoleDefinitionArgs{
     * 			Name: pulumi.StringRef("Contributor"),
     * 		}, nil)
     * 		if err != nil {
     * 			return err
     * 		}
     * 		ctx.Export("customRoleDefinitionId", custom.ApplyT(func(custom authorization.GetRoleDefinitionResult) (*string, error) {
     * 			return &custom.Id, nil
     * 		}).(pulumi.StringPtrOutput))
     * 		ctx.Export("contributorRoleDefinitionId", builtin.Id)
     * 		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.AuthorizationFunctions;
     * import com.pulumi.azure.authorization.inputs.GetRoleDefinitionArgs;
     * 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 customRoleDefinition = new RoleDefinition("customRoleDefinition", RoleDefinitionArgs.builder()
     *             .roleDefinitionId("00000000-0000-0000-0000-000000000000")
     *             .name("CustomRoleDef")
     *             .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
     *             .build());
     *         final var custom = AuthorizationFunctions.getRoleDefinition(GetRoleDefinitionArgs.builder()
     *             .roleDefinitionId(customRoleDefinition.roleDefinitionId())
     *             .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
     *             .build());
     *         final var custom-byname = AuthorizationFunctions.getRoleDefinition(GetRoleDefinitionArgs.builder()
     *             .name(customRoleDefinition.name())
     *             .scope(primary.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
     *             .build());
     *         final var builtin = AuthorizationFunctions.getRoleDefinition(GetRoleDefinitionArgs.builder()
     *             .name("Contributor")
     *             .build());
     *         ctx.export("customRoleDefinitionId", custom.applyValue(getRoleDefinitionResult -> getRoleDefinitionResult).applyValue(custom -> custom.applyValue(getRoleDefinitionResult -> getRoleDefinitionResult.id())));
     *         ctx.export("contributorRoleDefinitionId", builtin.applyValue(getRoleDefinitionResult -> getRoleDefinitionResult.id()));
     *     }
     * }
     * ```
     * ```yaml
     * resources:
     *   customRoleDefinition:
     *     type: azure:authorization:RoleDefinition
     *     name: custom
     *     properties:
     *       roleDefinitionId: 00000000-0000-0000-0000-000000000000
     *       name: CustomRoleDef
     *       scope: ${primary.id}
     * variables:
     *   primary:
     *     fn::invoke:
     *       Function: azure:core:getSubscription
     *       Arguments: {}
     *   custom:
     *     fn::invoke:
     *       Function: azure:authorization:getRoleDefinition
     *       Arguments:
     *         roleDefinitionId: ${customRoleDefinition.roleDefinitionId}
     *         scope: ${primary.id}
     *   custom-byname:
     *     fn::invoke:
     *       Function: azure:authorization:getRoleDefinition
     *       Arguments:
     *         name: ${customRoleDefinition.name}
     *         scope: ${primary.id}
     *   builtin:
     *     fn::invoke:
     *       Function: azure:authorization:getRoleDefinition
     *       Arguments:
     *         name: Contributor
     * outputs:
     *   customRoleDefinitionId: ${custom.id}
     *   contributorRoleDefinitionId: ${builtin.id}
     * ```
     * 
     * @param argument A collection of arguments for invoking getRoleDefinition.
     * @return A collection of values returned by getRoleDefinition.
     */
    @Deprecated(
        message = """
  azure.role.getRoleDefinition has been deprecated in favor of azure.authorization.getRoleDefinition
  """,
    )
    public suspend fun getRoleDefinition(argument: GetRoleDefinitionPlainArgs): GetRoleDefinitionResult = toKotlin(getRoleDefinitionPlain(argument.toJava()).await())

    /**
     * @see [getRoleDefinition].
     * @param name Specifies the Name of either a built-in or custom Role Definition.
     * > You can also use this for built-in roles such as `Contributor`, `Owner`, `Reader` and `Virtual Machine Contributor`
     * @param roleDefinitionId Specifies the ID of the Role Definition as a UUID/GUID.
     * @param scope Specifies the Scope at which the Custom Role Definition exists.
     * > **Note:** One of `name` or `role_definition_id` must be specified.
     * @return A collection of values returned by getRoleDefinition.
     */
    @Deprecated(
        message = """
  azure.role.getRoleDefinition has been deprecated in favor of azure.authorization.getRoleDefinition
  """,
    )
    public suspend fun getRoleDefinition(
        name: String? = null,
        roleDefinitionId: String? = null,
        scope: String? = null,
    ): GetRoleDefinitionResult {
        val argument = GetRoleDefinitionPlainArgs(
            name = name,
            roleDefinitionId = roleDefinitionId,
            scope = scope,
        )
        return toKotlin(getRoleDefinitionPlain(argument.toJava()).await())
    }

    /**
     * @see [getRoleDefinition].
     * @param argument Builder for [com.pulumi.azure.role.kotlin.inputs.GetRoleDefinitionPlainArgs].
     * @return A collection of values returned by getRoleDefinition.
     */
    @Deprecated(
        message = """
  azure.role.getRoleDefinition has been deprecated in favor of azure.authorization.getRoleDefinition
  """,
    )
    public suspend fun getRoleDefinition(argument: suspend GetRoleDefinitionPlainArgsBuilder.() -> Unit): GetRoleDefinitionResult {
        val builder = GetRoleDefinitionPlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return toKotlin(getRoleDefinitionPlain(builtArgument.toJava()).await())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy