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

com.pulumi.azure.management.kotlin.Group.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.management.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
import kotlin.collections.List

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

    public var args: GroupArgs = GroupArgs()

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

/**
 * Manages a Management Group.
 * !> **Note:** Configuring `subscription_ids` is not supported when using the `azure.management.GroupSubscriptionAssociation` resource, results will be unpredictable.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const current = azure.core.getSubscription({});
 * const exampleParent = new azure.management.Group("example_parent", {
 *     displayName: "ParentGroup",
 *     subscriptionIds: [current.then(current => current.subscriptionId)],
 * });
 * const exampleChild = new azure.management.Group("example_child", {
 *     displayName: "ChildGroup",
 *     parentManagementGroupId: exampleParent.id,
 *     subscriptionIds: [current.then(current => current.subscriptionId)],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * current = azure.core.get_subscription()
 * example_parent = azure.management.Group("example_parent",
 *     display_name="ParentGroup",
 *     subscription_ids=[current.subscription_id])
 * example_child = azure.management.Group("example_child",
 *     display_name="ChildGroup",
 *     parent_management_group_id=example_parent.id,
 *     subscription_ids=[current.subscription_id])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var current = Azure.Core.GetSubscription.Invoke();
 *     var exampleParent = new Azure.Management.Group("example_parent", new()
 *     {
 *         DisplayName = "ParentGroup",
 *         SubscriptionIds = new[]
 *         {
 *             current.Apply(getSubscriptionResult => getSubscriptionResult.SubscriptionId),
 *         },
 *     });
 *     var exampleChild = new Azure.Management.Group("example_child", new()
 *     {
 *         DisplayName = "ChildGroup",
 *         ParentManagementGroupId = exampleParent.Id,
 *         SubscriptionIds = new[]
 *         {
 *             current.Apply(getSubscriptionResult => getSubscriptionResult.SubscriptionId),
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/management"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		current, err := core.LookupSubscription(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleParent, err := management.NewGroup(ctx, "example_parent", &management.GroupArgs{
 * 			DisplayName: pulumi.String("ParentGroup"),
 * 			SubscriptionIds: pulumi.StringArray{
 * 				pulumi.String(current.SubscriptionId),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = management.NewGroup(ctx, "example_child", &management.GroupArgs{
 * 			DisplayName:             pulumi.String("ChildGroup"),
 * 			ParentManagementGroupId: exampleParent.ID(),
 * 			SubscriptionIds: pulumi.StringArray{
 * 				pulumi.String(current.SubscriptionId),
 * 			},
 * 		})
 * 		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.management.Group;
 * import com.pulumi.azure.management.GroupArgs;
 * 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.getSubscription();
 *         var exampleParent = new Group("exampleParent", GroupArgs.builder()
 *             .displayName("ParentGroup")
 *             .subscriptionIds(current.applyValue(getSubscriptionResult -> getSubscriptionResult.subscriptionId()))
 *             .build());
 *         var exampleChild = new Group("exampleChild", GroupArgs.builder()
 *             .displayName("ChildGroup")
 *             .parentManagementGroupId(exampleParent.id())
 *             .subscriptionIds(current.applyValue(getSubscriptionResult -> getSubscriptionResult.subscriptionId()))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleParent:
 *     type: azure:management:Group
 *     name: example_parent
 *     properties:
 *       displayName: ParentGroup
 *       subscriptionIds:
 *         - ${current.subscriptionId}
 *   exampleChild:
 *     type: azure:management:Group
 *     name: example_child
 *     properties:
 *       displayName: ChildGroup
 *       parentManagementGroupId: ${exampleParent.id}
 *       subscriptionIds: # other subscription IDs can go here
 *         - ${current.subscriptionId}
 * variables:
 *   current:
 *     fn::invoke:
 *       Function: azure:core:getSubscription
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Management Groups can be imported using the `management group resource id`, e.g.
 * ```sh
 * $ pulumi import azure:management/group:Group example /providers/Microsoft.Management/managementGroups/group1
 * ```
 */
public class Group internal constructor(
    override val javaResource: com.pulumi.azure.management.Group,
) : KotlinCustomResource(javaResource, GroupMapper) {
    /**
     * A friendly name for this Management Group. If not specified, this will be the same as the `name`.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * The name or UUID for this Management Group, which needs to be unique across your tenant. A new UUID will be generated if not provided. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the Parent Management Group.
     */
    public val parentManagementGroupId: Output
        get() = javaResource.parentManagementGroupId().applyValue({ args0 -> args0 })

    /**
     * A list of Subscription GUIDs which should be assigned to the Management Group.
     * > **Note:** To clear all Subscriptions from the Management Group set `subscription_ids` to an empty list
     */
    public val subscriptionIds: Output>
        get() = javaResource.subscriptionIds().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The Management Group ID with the Tenant ID prefix.
     */
    public val tenantScopedId: Output
        get() = javaResource.tenantScopedId().applyValue({ args0 -> args0 })
}

public object GroupMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.management.Group::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy