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

com.pulumi.gcp.iam.kotlin.IamFunctions.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.iam.kotlin

import com.pulumi.gcp.iam.IamFunctions.getRulePlain
import com.pulumi.gcp.iam.IamFunctions.getTestablePermissionsPlain
import com.pulumi.gcp.iam.IamFunctions.getWorkloadIdentityPoolPlain
import com.pulumi.gcp.iam.IamFunctions.getWorkloadIdentityPoolProviderPlain
import com.pulumi.gcp.iam.kotlin.inputs.GetRulePlainArgs
import com.pulumi.gcp.iam.kotlin.inputs.GetRulePlainArgsBuilder
import com.pulumi.gcp.iam.kotlin.inputs.GetTestablePermissionsPlainArgs
import com.pulumi.gcp.iam.kotlin.inputs.GetTestablePermissionsPlainArgsBuilder
import com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolPlainArgs
import com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolPlainArgsBuilder
import com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolProviderPlainArgs
import com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolProviderPlainArgsBuilder
import com.pulumi.gcp.iam.kotlin.outputs.GetRuleResult
import com.pulumi.gcp.iam.kotlin.outputs.GetTestablePermissionsResult
import com.pulumi.gcp.iam.kotlin.outputs.GetWorkloadIdentityPoolProviderResult
import com.pulumi.gcp.iam.kotlin.outputs.GetWorkloadIdentityPoolResult
import kotlinx.coroutines.future.await
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.gcp.iam.kotlin.outputs.GetRuleResult.Companion.toKotlin as getRuleResultToKotlin
import com.pulumi.gcp.iam.kotlin.outputs.GetTestablePermissionsResult.Companion.toKotlin as getTestablePermissionsResultToKotlin
import com.pulumi.gcp.iam.kotlin.outputs.GetWorkloadIdentityPoolProviderResult.Companion.toKotlin as getWorkloadIdentityPoolProviderResultToKotlin
import com.pulumi.gcp.iam.kotlin.outputs.GetWorkloadIdentityPoolResult.Companion.toKotlin as getWorkloadIdentityPoolResultToKotlin

public object IamFunctions {
    /**
     * Use this data source to get information about a Google IAM Role.
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as gcp from "@pulumi/gcp";
     * const roleinfo = gcp.iam.getRule({
     *     name: "roles/compute.viewer",
     * });
     * export const theRolePermissions = roleinfo.then(roleinfo => roleinfo.includedPermissions);
     * ```
     * ```python
     * import pulumi
     * import pulumi_gcp as gcp
     * roleinfo = gcp.iam.get_rule(name="roles/compute.viewer")
     * pulumi.export("theRolePermissions", roleinfo.included_permissions)
     * ```
     * ```csharp
     * using System.Collections.Generic;
     * using System.Linq;
     * using Pulumi;
     * using Gcp = Pulumi.Gcp;
     * return await Deployment.RunAsync(() =>
     * {
     *     var roleinfo = Gcp.Iam.GetRule.Invoke(new()
     *     {
     *         Name = "roles/compute.viewer",
     *     });
     *     return new Dictionary
     *     {
     *         ["theRolePermissions"] = roleinfo.Apply(getRuleResult => getRuleResult.IncludedPermissions),
     *     };
     * });
     * ```
     * ```go
     * package main
     * import (
     * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/iam"
     * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
     * )
     * func main() {
     * 	pulumi.Run(func(ctx *pulumi.Context) error {
     * 		roleinfo, err := iam.GetRule(ctx, &iam.GetRuleArgs{
     * 			Name: "roles/compute.viewer",
     * 		}, nil)
     * 		if err != nil {
     * 			return err
     * 		}
     * 		ctx.Export("theRolePermissions", roleinfo.IncludedPermissions)
     * 		return nil
     * 	})
     * }
     * ```
     * ```java
     * package generated_program;
     * import com.pulumi.Context;
     * import com.pulumi.Pulumi;
     * import com.pulumi.core.Output;
     * import com.pulumi.gcp.iam.IamFunctions;
     * import com.pulumi.gcp.iam.inputs.GetRuleArgs;
     * 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 roleinfo = IamFunctions.getRule(GetRuleArgs.builder()
     *             .name("roles/compute.viewer")
     *             .build());
     *         ctx.export("theRolePermissions", roleinfo.applyValue(getRuleResult -> getRuleResult.includedPermissions()));
     *     }
     * }
     * ```
     * ```yaml
     * variables:
     *   roleinfo:
     *     fn::invoke:
     *       Function: gcp:iam:getRule
     *       Arguments:
     *         name: roles/compute.viewer
     * outputs:
     *   theRolePermissions: ${roleinfo.includedPermissions}
     * ```
     * 
     * @param argument A collection of arguments for invoking getRule.
     * @return A collection of values returned by getRule.
     */
    public suspend fun getRule(argument: GetRulePlainArgs): GetRuleResult =
        getRuleResultToKotlin(getRulePlain(argument.toJava()).await())

    /**
     * @see [getRule].
     * @param name The name of the Role to lookup in the form `roles/{ROLE_NAME}`, `organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}` or `projects/{PROJECT_ID}/roles/{ROLE_NAME}`
     * @return A collection of values returned by getRule.
     */
    public suspend fun getRule(name: String): GetRuleResult {
        val argument = GetRulePlainArgs(
            name = name,
        )
        return getRuleResultToKotlin(getRulePlain(argument.toJava()).await())
    }

    /**
     * @see [getRule].
     * @param argument Builder for [com.pulumi.gcp.iam.kotlin.inputs.GetRulePlainArgs].
     * @return A collection of values returned by getRule.
     */
    public suspend fun getRule(argument: suspend GetRulePlainArgsBuilder.() -> Unit): GetRuleResult {
        val builder = GetRulePlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getRuleResultToKotlin(getRulePlain(builtArgument.toJava()).await())
    }

    /**
     * Retrieve a list of testable permissions for a resource. Testable permissions mean the permissions that user can add or remove in a role at a given resource. The resource can be referenced either via the full resource name or via a URI.
     * ## Example Usage
     * Retrieve all the supported permissions able to be set on `my-project` that are in either GA or BETA. This is useful for dynamically constructing custom roles.
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as gcp from "@pulumi/gcp";
     * const perms = gcp.iam.getTestablePermissions({
     *     fullResourceName: "//cloudresourcemanager.googleapis.com/projects/my-project",
     *     stages: [
     *         "GA",
     *         "BETA",
     *     ],
     * });
     * ```
     * ```python
     * import pulumi
     * import pulumi_gcp as gcp
     * perms = gcp.iam.get_testable_permissions(full_resource_name="//cloudresourcemanager.googleapis.com/projects/my-project",
     *     stages=[
     *         "GA",
     *         "BETA",
     *     ])
     * ```
     * ```csharp
     * using System.Collections.Generic;
     * using System.Linq;
     * using Pulumi;
     * using Gcp = Pulumi.Gcp;
     * return await Deployment.RunAsync(() =>
     * {
     *     var perms = Gcp.Iam.GetTestablePermissions.Invoke(new()
     *     {
     *         FullResourceName = "//cloudresourcemanager.googleapis.com/projects/my-project",
     *         Stages = new[]
     *         {
     *             "GA",
     *             "BETA",
     *         },
     *     });
     * });
     * ```
     * ```go
     * package main
     * import (
     * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/iam"
     * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
     * )
     * func main() {
     * 	pulumi.Run(func(ctx *pulumi.Context) error {
     * 		_, err := iam.GetTestablePermissions(ctx, &iam.GetTestablePermissionsArgs{
     * 			FullResourceName: "//cloudresourcemanager.googleapis.com/projects/my-project",
     * 			Stages: []string{
     * 				"GA",
     * 				"BETA",
     * 			},
     * 		}, nil)
     * 		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.gcp.iam.IamFunctions;
     * import com.pulumi.gcp.iam.inputs.GetTestablePermissionsArgs;
     * 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 perms = IamFunctions.getTestablePermissions(GetTestablePermissionsArgs.builder()
     *             .fullResourceName("//cloudresourcemanager.googleapis.com/projects/my-project")
     *             .stages(
     *                 "GA",
     *                 "BETA")
     *             .build());
     *     }
     * }
     * ```
     * ```yaml
     * variables:
     *   perms:
     *     fn::invoke:
     *       Function: gcp:iam:getTestablePermissions
     *       Arguments:
     *         fullResourceName: //cloudresourcemanager.googleapis.com/projects/my-project
     *         stages:
     *           - GA
     *           - BETA
     * ```
     * 
     * @param argument A collection of arguments for invoking getTestablePermissions.
     * @return A collection of values returned by getTestablePermissions.
     */
    public suspend fun getTestablePermissions(argument: GetTestablePermissionsPlainArgs): GetTestablePermissionsResult =
        getTestablePermissionsResultToKotlin(getTestablePermissionsPlain(argument.toJava()).await())

    /**
     * @see [getTestablePermissions].
     * @param customSupportLevel The level of support for custom roles. Can be one of `"NOT_SUPPORTED"`, `"SUPPORTED"`, `"TESTING"`. Default is `"SUPPORTED"`
     * @param fullResourceName See [full resource name documentation](https://cloud.google.com/apis/design/resource_names#full_resource_name) for more detail.
     * @param stages The acceptable release stages of the permission in the output. Note that `BETA` does not include permissions in `GA`, but you can specify both with `["GA", "BETA"]` for example. Can be a list of `"ALPHA"`, `"BETA"`, `"GA"`, `"DEPRECATED"`. Default is `["GA"]`.
     * @return A collection of values returned by getTestablePermissions.
     */
    public suspend fun getTestablePermissions(
        customSupportLevel: String? = null,
        fullResourceName: String,
        stages: List? = null,
    ): GetTestablePermissionsResult {
        val argument = GetTestablePermissionsPlainArgs(
            customSupportLevel = customSupportLevel,
            fullResourceName = fullResourceName,
            stages = stages,
        )
        return getTestablePermissionsResultToKotlin(getTestablePermissionsPlain(argument.toJava()).await())
    }

    /**
     * @see [getTestablePermissions].
     * @param argument Builder for [com.pulumi.gcp.iam.kotlin.inputs.GetTestablePermissionsPlainArgs].
     * @return A collection of values returned by getTestablePermissions.
     */
    public suspend fun getTestablePermissions(argument: suspend GetTestablePermissionsPlainArgsBuilder.() -> Unit): GetTestablePermissionsResult {
        val builder = GetTestablePermissionsPlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getTestablePermissionsResultToKotlin(getTestablePermissionsPlain(builtArgument.toJava()).await())
    }

    /**
     * Get a IAM workload identity pool from Google Cloud by its id.
     * > **Note:** The following resource requires the Beta IAM role `roles/iam.workloadIdentityPoolAdmin` in order to succeed. `OWNER` and `EDITOR` roles do not include the necessary permissions.
     * ## Example Usage
     * ```tf
     * data "google_iam_workload_identity_pool" "foo" {
     *   workload_identity_pool_id = "foo-pool"
     * }
     * ```
     * @param argument A collection of arguments for invoking getWorkloadIdentityPool.
     * @return A collection of values returned by getWorkloadIdentityPool.
     */
    public suspend fun getWorkloadIdentityPool(argument: GetWorkloadIdentityPoolPlainArgs): GetWorkloadIdentityPoolResult =
        getWorkloadIdentityPoolResultToKotlin(getWorkloadIdentityPoolPlain(argument.toJava()).await())

    /**
     * @see [getWorkloadIdentityPool].
     * @param project The project in which the resource belongs. If it
     * is not provided, the provider project is used.
     * @param workloadIdentityPoolId The id of the pool which is the
     * final component of the resource name.
     * - - -
     * @return A collection of values returned by getWorkloadIdentityPool.
     */
    public suspend fun getWorkloadIdentityPool(
        project: String? = null,
        workloadIdentityPoolId: String,
    ): GetWorkloadIdentityPoolResult {
        val argument = GetWorkloadIdentityPoolPlainArgs(
            project = project,
            workloadIdentityPoolId = workloadIdentityPoolId,
        )
        return getWorkloadIdentityPoolResultToKotlin(getWorkloadIdentityPoolPlain(argument.toJava()).await())
    }

    /**
     * @see [getWorkloadIdentityPool].
     * @param argument Builder for [com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolPlainArgs].
     * @return A collection of values returned by getWorkloadIdentityPool.
     */
    public suspend fun getWorkloadIdentityPool(argument: suspend GetWorkloadIdentityPoolPlainArgsBuilder.() -> Unit): GetWorkloadIdentityPoolResult {
        val builder = GetWorkloadIdentityPoolPlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getWorkloadIdentityPoolResultToKotlin(getWorkloadIdentityPoolPlain(builtArgument.toJava()).await())
    }

    /**
     * Get a IAM workload identity provider from Google Cloud by its id.
     * ## Example Usage
     * ```tf
     * data "google_iam_workload_identity_pool_provider" "foo" {
     *   workload_identity_pool_id          = "foo-pool"
     *   workload_identity_pool_provider_id = "bar-provider"
     * }
     * ```
     * @param argument A collection of arguments for invoking getWorkloadIdentityPoolProvider.
     * @return A collection of values returned by getWorkloadIdentityPoolProvider.
     */
    public suspend fun getWorkloadIdentityPoolProvider(argument: GetWorkloadIdentityPoolProviderPlainArgs): GetWorkloadIdentityPoolProviderResult =
        getWorkloadIdentityPoolProviderResultToKotlin(getWorkloadIdentityPoolProviderPlain(argument.toJava()).await())

    /**
     * @see [getWorkloadIdentityPoolProvider].
     * @param project The project in which the resource belongs. If it
     * is not provided, the provider project is used.
     * @param workloadIdentityPoolId The id of the pool which is the
     * final component of the pool resource name.
     * @param workloadIdentityPoolProviderId The id of the provider which is the
     * final component of the resource name.
     * - - -
     * @return A collection of values returned by getWorkloadIdentityPoolProvider.
     */
    public suspend fun getWorkloadIdentityPoolProvider(
        project: String? = null,
        workloadIdentityPoolId: String,
        workloadIdentityPoolProviderId: String,
    ): GetWorkloadIdentityPoolProviderResult {
        val argument = GetWorkloadIdentityPoolProviderPlainArgs(
            project = project,
            workloadIdentityPoolId = workloadIdentityPoolId,
            workloadIdentityPoolProviderId = workloadIdentityPoolProviderId,
        )
        return getWorkloadIdentityPoolProviderResultToKotlin(getWorkloadIdentityPoolProviderPlain(argument.toJava()).await())
    }

    /**
     * @see [getWorkloadIdentityPoolProvider].
     * @param argument Builder for [com.pulumi.gcp.iam.kotlin.inputs.GetWorkloadIdentityPoolProviderPlainArgs].
     * @return A collection of values returned by getWorkloadIdentityPoolProvider.
     */
    public suspend fun getWorkloadIdentityPoolProvider(argument: suspend GetWorkloadIdentityPoolProviderPlainArgsBuilder.() -> Unit): GetWorkloadIdentityPoolProviderResult {
        val builder = GetWorkloadIdentityPoolProviderPlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getWorkloadIdentityPoolProviderResultToKotlin(getWorkloadIdentityPoolProviderPlain(builtArgument.toJava()).await())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy