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

com.pulumi.gcp.accesscontextmanager.kotlin.AccessLevels.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: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.accesscontextmanager.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.accesscontextmanager.kotlin.outputs.AccessLevelsAccessLevel
import com.pulumi.gcp.accesscontextmanager.kotlin.outputs.AccessLevelsAccessLevel.Companion.toKotlin
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 [AccessLevels].
 */
@PulumiTagMarker
public class AccessLevelsResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: AccessLevelsArgs = AccessLevelsArgs()

    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 AccessLevelsArgsBuilder.() -> Unit) {
        val builder = AccessLevelsArgsBuilder()
        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(): AccessLevels {
        val builtJavaResource =
            com.pulumi.gcp.accesscontextmanager.AccessLevels(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return AccessLevels(builtJavaResource)
    }
}

/**
 * Replace all existing Access Levels in an Access Policy with the Access Levels provided. This is done atomically.
 * This is a bulk edit of all Access Levels and may override existing Access Levels created by `gcp.accesscontextmanager.AccessLevel`,
 * thus causing a permadiff if used alongside `gcp.accesscontextmanager.AccessLevel` on the same parent.
 * To get more information about AccessLevels, see:
 * * [API documentation](https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.accessLevels)
 * * How-to Guides
 *     * [Access Policy Quickstart](https://cloud.google.com/access-context-manager/docs/quickstart)
 * ## Example Usage
 * ### Access Context Manager Access Levels Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const access_policy = new gcp.accesscontextmanager.AccessPolicy("access-policy", {
 *     parent: "organizations/123456789",
 *     title: "my policy",
 * });
 * const access_levels = new gcp.accesscontextmanager.AccessLevels("access-levels", {
 *     parent: pulumi.interpolate`accessPolicies/${access_policy.name}`,
 *     accessLevels: [
 *         {
 *             name: pulumi.interpolate`accessPolicies/${access_policy.name}/accessLevels/chromeos_no_lock`,
 *             title: "chromeos_no_lock",
 *             basic: {
 *                 conditions: [{
 *                     devicePolicy: {
 *                         requireScreenLock: true,
 *                         osConstraints: [{
 *                             osType: "DESKTOP_CHROME_OS",
 *                         }],
 *                     },
 *                     regions: [
 *                         "CH",
 *                         "IT",
 *                         "US",
 *                     ],
 *                 }],
 *             },
 *         },
 *         {
 *             name: pulumi.interpolate`accessPolicies/${access_policy.name}/accessLevels/mac_no_lock`,
 *             title: "mac_no_lock",
 *             basic: {
 *                 conditions: [{
 *                     devicePolicy: {
 *                         requireScreenLock: true,
 *                         osConstraints: [{
 *                             osType: "DESKTOP_MAC",
 *                         }],
 *                     },
 *                     regions: [
 *                         "CH",
 *                         "IT",
 *                         "US",
 *                     ],
 *                 }],
 *             },
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * access_policy = gcp.accesscontextmanager.AccessPolicy("access-policy",
 *     parent="organizations/123456789",
 *     title="my policy")
 * access_levels = gcp.accesscontextmanager.AccessLevels("access-levels",
 *     parent=access_policy.name.apply(lambda name: f"accessPolicies/{name}"),
 *     access_levels=[
 *         gcp.accesscontextmanager.AccessLevelsAccessLevelArgs(
 *             name=access_policy.name.apply(lambda name: f"accessPolicies/{name}/accessLevels/chromeos_no_lock"),
 *             title="chromeos_no_lock",
 *             basic=gcp.accesscontextmanager.AccessLevelsAccessLevelBasicArgs(
 *                 conditions=[gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionArgs(
 *                     device_policy=gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs(
 *                         require_screen_lock=True,
 *                         os_constraints=[gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs(
 *                             os_type="DESKTOP_CHROME_OS",
 *                         )],
 *                     ),
 *                     regions=[
 *                         "CH",
 *                         "IT",
 *                         "US",
 *                     ],
 *                 )],
 *             ),
 *         ),
 *         gcp.accesscontextmanager.AccessLevelsAccessLevelArgs(
 *             name=access_policy.name.apply(lambda name: f"accessPolicies/{name}/accessLevels/mac_no_lock"),
 *             title="mac_no_lock",
 *             basic=gcp.accesscontextmanager.AccessLevelsAccessLevelBasicArgs(
 *                 conditions=[gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionArgs(
 *                     device_policy=gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs(
 *                         require_screen_lock=True,
 *                         os_constraints=[gcp.accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs(
 *                             os_type="DESKTOP_MAC",
 *                         )],
 *                     ),
 *                     regions=[
 *                         "CH",
 *                         "IT",
 *                         "US",
 *                     ],
 *                 )],
 *             ),
 *         ),
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var access_policy = new Gcp.AccessContextManager.AccessPolicy("access-policy", new()
 *     {
 *         Parent = "organizations/123456789",
 *         Title = "my policy",
 *     });
 *     var access_levels = new Gcp.AccessContextManager.AccessLevels("access-levels", new()
 *     {
 *         Parent = access_policy.Name.Apply(name => $"accessPolicies/{name}"),
 *         AccessLevelDetails = new[]
 *         {
 *             new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelArgs
 *             {
 *                 Name = access_policy.Name.Apply(name => $"accessPolicies/{name}/accessLevels/chromeos_no_lock"),
 *                 Title = "chromeos_no_lock",
 *                 Basic = new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicArgs
 *                 {
 *                     Conditions = new[]
 *                     {
 *                         new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionArgs
 *                         {
 *                             DevicePolicy = new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs
 *                             {
 *                                 RequireScreenLock = true,
 *                                 OsConstraints = new[]
 *                                 {
 *                                     new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs
 *                                     {
 *                                         OsType = "DESKTOP_CHROME_OS",
 *                                     },
 *                                 },
 *                             },
 *                             Regions = new[]
 *                             {
 *                                 "CH",
 *                                 "IT",
 *                                 "US",
 *                             },
 *                         },
 *                     },
 *                 },
 *             },
 *             new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelArgs
 *             {
 *                 Name = access_policy.Name.Apply(name => $"accessPolicies/{name}/accessLevels/mac_no_lock"),
 *                 Title = "mac_no_lock",
 *                 Basic = new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicArgs
 *                 {
 *                     Conditions = new[]
 *                     {
 *                         new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionArgs
 *                         {
 *                             DevicePolicy = new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs
 *                             {
 *                                 RequireScreenLock = true,
 *                                 OsConstraints = new[]
 *                                 {
 *                                     new Gcp.AccessContextManager.Inputs.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs
 *                                     {
 *                                         OsType = "DESKTOP_MAC",
 *                                     },
 *                                 },
 *                             },
 *                             Regions = new[]
 *                             {
 *                                 "CH",
 *                                 "IT",
 *                                 "US",
 *                             },
 *                         },
 *                     },
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/accesscontextmanager"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := accesscontextmanager.NewAccessPolicy(ctx, "access-policy", &accesscontextmanager.AccessPolicyArgs{
 * 			Parent: pulumi.String("organizations/123456789"),
 * 			Title:  pulumi.String("my policy"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = accesscontextmanager.NewAccessLevels(ctx, "access-levels", &accesscontextmanager.AccessLevelsArgs{
 * 			Parent: access_policy.Name.ApplyT(func(name string) (string, error) {
 * 				return fmt.Sprintf("accessPolicies/%v", name), nil
 * 			}).(pulumi.StringOutput),
 * 			AccessLevels: accesscontextmanager.AccessLevelsAccessLevelArray{
 * 				&accesscontextmanager.AccessLevelsAccessLevelArgs{
 * 					Name: access_policy.Name.ApplyT(func(name string) (string, error) {
 * 						return fmt.Sprintf("accessPolicies/%v/accessLevels/chromeos_no_lock", name), nil
 * 					}).(pulumi.StringOutput),
 * 					Title: pulumi.String("chromeos_no_lock"),
 * 					Basic: &accesscontextmanager.AccessLevelsAccessLevelBasicArgs{
 * 						Conditions: accesscontextmanager.AccessLevelsAccessLevelBasicConditionArray{
 * 							&accesscontextmanager.AccessLevelsAccessLevelBasicConditionArgs{
 * 								DevicePolicy: &accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs{
 * 									RequireScreenLock: pulumi.Bool(true),
 * 									OsConstraints: accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArray{
 * 										&accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs{
 * 											OsType: pulumi.String("DESKTOP_CHROME_OS"),
 * 										},
 * 									},
 * 								},
 * 								Regions: pulumi.StringArray{
 * 									pulumi.String("CH"),
 * 									pulumi.String("IT"),
 * 									pulumi.String("US"),
 * 								},
 * 							},
 * 						},
 * 					},
 * 				},
 * 				&accesscontextmanager.AccessLevelsAccessLevelArgs{
 * 					Name: access_policy.Name.ApplyT(func(name string) (string, error) {
 * 						return fmt.Sprintf("accessPolicies/%v/accessLevels/mac_no_lock", name), nil
 * 					}).(pulumi.StringOutput),
 * 					Title: pulumi.String("mac_no_lock"),
 * 					Basic: &accesscontextmanager.AccessLevelsAccessLevelBasicArgs{
 * 						Conditions: accesscontextmanager.AccessLevelsAccessLevelBasicConditionArray{
 * 							&accesscontextmanager.AccessLevelsAccessLevelBasicConditionArgs{
 * 								DevicePolicy: &accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyArgs{
 * 									RequireScreenLock: pulumi.Bool(true),
 * 									OsConstraints: accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArray{
 * 										&accesscontextmanager.AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs{
 * 											OsType: pulumi.String("DESKTOP_MAC"),
 * 										},
 * 									},
 * 								},
 * 								Regions: pulumi.StringArray{
 * 									pulumi.String("CH"),
 * 									pulumi.String("IT"),
 * 									pulumi.String("US"),
 * 								},
 * 							},
 * 						},
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.accesscontextmanager.AccessPolicy;
 * import com.pulumi.gcp.accesscontextmanager.AccessPolicyArgs;
 * import com.pulumi.gcp.accesscontextmanager.AccessLevels;
 * import com.pulumi.gcp.accesscontextmanager.AccessLevelsArgs;
 * import com.pulumi.gcp.accesscontextmanager.inputs.AccessLevelsAccessLevelArgs;
 * import com.pulumi.gcp.accesscontextmanager.inputs.AccessLevelsAccessLevelBasicArgs;
 * 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 access_policy = new AccessPolicy("access-policy", AccessPolicyArgs.builder()
 *             .parent("organizations/123456789")
 *             .title("my policy")
 *             .build());
 *         var access_levels = new AccessLevels("access-levels", AccessLevelsArgs.builder()
 *             .parent(access_policy.name().applyValue(name -> String.format("accessPolicies/%s", name)))
 *             .accessLevels(
 *                 AccessLevelsAccessLevelArgs.builder()
 *                     .name(access_policy.name().applyValue(name -> String.format("accessPolicies/%s/accessLevels/chromeos_no_lock", name)))
 *                     .title("chromeos_no_lock")
 *                     .basic(AccessLevelsAccessLevelBasicArgs.builder()
 *                         .conditions(AccessLevelsAccessLevelBasicConditionArgs.builder()
 *                             .devicePolicy(AccessLevelsAccessLevelBasicConditionDevicePolicyArgs.builder()
 *                                 .requireScreenLock(true)
 *                                 .osConstraints(AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs.builder()
 *                                     .osType("DESKTOP_CHROME_OS")
 *                                     .build())
 *                                 .build())
 *                             .regions(
 *                                 "CH",
 *                                 "IT",
 *                                 "US")
 *                             .build())
 *                         .build())
 *                     .build(),
 *                 AccessLevelsAccessLevelArgs.builder()
 *                     .name(access_policy.name().applyValue(name -> String.format("accessPolicies/%s/accessLevels/mac_no_lock", name)))
 *                     .title("mac_no_lock")
 *                     .basic(AccessLevelsAccessLevelBasicArgs.builder()
 *                         .conditions(AccessLevelsAccessLevelBasicConditionArgs.builder()
 *                             .devicePolicy(AccessLevelsAccessLevelBasicConditionDevicePolicyArgs.builder()
 *                                 .requireScreenLock(true)
 *                                 .osConstraints(AccessLevelsAccessLevelBasicConditionDevicePolicyOsConstraintArgs.builder()
 *                                     .osType("DESKTOP_MAC")
 *                                     .build())
 *                                 .build())
 *                             .regions(
 *                                 "CH",
 *                                 "IT",
 *                                 "US")
 *                             .build())
 *                         .build())
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   access-levels:
 *     type: gcp:accesscontextmanager:AccessLevels
 *     properties:
 *       parent: accessPolicies/${["access-policy"].name}
 *       accessLevels:
 *         - name: accessPolicies/${["access-policy"].name}/accessLevels/chromeos_no_lock
 *           title: chromeos_no_lock
 *           basic:
 *             conditions:
 *               - devicePolicy:
 *                   requireScreenLock: true
 *                   osConstraints:
 *                     - osType: DESKTOP_CHROME_OS
 *                 regions:
 *                   - CH
 *                   - IT
 *                   - US
 *         - name: accessPolicies/${["access-policy"].name}/accessLevels/mac_no_lock
 *           title: mac_no_lock
 *           basic:
 *             conditions:
 *               - devicePolicy:
 *                   requireScreenLock: true
 *                   osConstraints:
 *                     - osType: DESKTOP_MAC
 *                 regions:
 *                   - CH
 *                   - IT
 *                   - US
 *   access-policy:
 *     type: gcp:accesscontextmanager:AccessPolicy
 *     properties:
 *       parent: organizations/123456789
 *       title: my policy
 * ```
 * 
 * ## Import
 * AccessLevels can be imported using any of these accepted formats:
 * * `{{parent}}/accessLevels`
 * * `{{parent}}`
 * When using the `pulumi import` command, AccessLevels can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:accesscontextmanager/accessLevels:AccessLevels default {{parent}}/accessLevels
 * ```
 * ```sh
 * $ pulumi import gcp:accesscontextmanager/accessLevels:AccessLevels default {{parent}}
 * ```
 */
public class AccessLevels internal constructor(
    override val javaResource: com.pulumi.gcp.accesscontextmanager.AccessLevels,
) : KotlinCustomResource(javaResource, AccessLevelsMapper) {
    /**
     * The desired Access Levels that should replace all existing Access Levels in the Access Policy.
     * Structure is documented below.
     */
    public val accessLevels: Output>?
        get() = javaResource.accessLevels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> toKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * The AccessPolicy this AccessLevel lives in.
     * Format: accessPolicies/{policy_id}
     * - - -
     */
    public val parent: Output
        get() = javaResource.parent().applyValue({ args0 -> args0 })
}

public object AccessLevelsMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.accesscontextmanager.AccessLevels::class == javaResource::class

    override fun map(javaResource: Resource): AccessLevels = AccessLevels(
        javaResource as
            com.pulumi.gcp.accesscontextmanager.AccessLevels,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy