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

com.pulumi.gcp.organizations.kotlin.Folder.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.organizations.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

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

    public var args: FolderArgs = FolderArgs()

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

/**
 * Allows management of a Google Cloud Platform folder. For more information see
 * [the official documentation](https://cloud.google.com/resource-manager/docs/creating-managing-folders)
 * and
 * [API](https://cloud.google.com/resource-manager/reference/rest/v2/folders).
 * A folder can contain projects, other folders, or a combination of both. You can use folders to group projects under an organization in a hierarchy. For example, your organization might contain multiple departments, each with its own set of Cloud Platform resources. Folders allows you to group these resources on a per-department basis. Folders are used to group resources that share common IAM policies.
 * Folders created live inside an Organization. See the [Organization documentation](https://cloud.google.com/resource-manager/docs/quickstarts) for more details.
 * The service account used to run the provider when creating a `gcp.organizations.Folder`
 * resource must have `roles/resourcemanager.folderCreator`. See the
 * [Access Control for Folders Using IAM](https://cloud.google.com/resource-manager/docs/access-control-folders)
 * doc for more information.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * // Top-level folder under an organization.
 * const department1 = new gcp.organizations.Folder("department1", {
 *     displayName: "Department 1",
 *     parent: "organizations/1234567",
 * });
 * // Folder nested under another folder.
 * const team_abc = new gcp.organizations.Folder("team-abc", {
 *     displayName: "Team ABC",
 *     parent: department1.name,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * # Top-level folder under an organization.
 * department1 = gcp.organizations.Folder("department1",
 *     display_name="Department 1",
 *     parent="organizations/1234567")
 * # Folder nested under another folder.
 * team_abc = gcp.organizations.Folder("team-abc",
 *     display_name="Team ABC",
 *     parent=department1.name)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     // Top-level folder under an organization.
 *     var department1 = new Gcp.Organizations.Folder("department1", new()
 *     {
 *         DisplayName = "Department 1",
 *         Parent = "organizations/1234567",
 *     });
 *     // Folder nested under another folder.
 *     var team_abc = new Gcp.Organizations.Folder("team-abc", new()
 *     {
 *         DisplayName = "Team ABC",
 *         Parent = department1.Name,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		// Top-level folder under an organization.
 * 		department1, err := organizations.NewFolder(ctx, "department1", &organizations.FolderArgs{
 * 			DisplayName: pulumi.String("Department 1"),
 * 			Parent:      pulumi.String("organizations/1234567"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Folder nested under another folder.
 * 		_, err = organizations.NewFolder(ctx, "team-abc", &organizations.FolderArgs{
 * 			DisplayName: pulumi.String("Team ABC"),
 * 			Parent:      department1.Name,
 * 		})
 * 		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.organizations.Folder;
 * import com.pulumi.gcp.organizations.FolderArgs;
 * 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) {
 *         // Top-level folder under an organization.
 *         var department1 = new Folder("department1", FolderArgs.builder()
 *             .displayName("Department 1")
 *             .parent("organizations/1234567")
 *             .build());
 *         // Folder nested under another folder.
 *         var team_abc = new Folder("team-abc", FolderArgs.builder()
 *             .displayName("Team ABC")
 *             .parent(department1.name())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   # Top-level folder under an organization.
 *   department1:
 *     type: gcp:organizations:Folder
 *     properties:
 *       displayName: Department 1
 *       parent: organizations/1234567
 *   # Folder nested under another folder.
 *   team-abc:
 *     type: gcp:organizations:Folder
 *     properties:
 *       displayName: Team ABC
 *       parent: ${department1.name}
 * ```
 * 
 * ## Import
 * Folders can be imported using the folder's id, e.g.
 * * `folders/{{folder_id}}`
 * * `{{folder_id}}`
 * When using the `pulumi import` command, Folders can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:organizations/folder:Folder default {{folder_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:organizations/folder:Folder default folders/{{folder_id}}
 * ```
 */
public class Folder internal constructor(
    override val javaResource: com.pulumi.gcp.organizations.Folder,
) : KotlinCustomResource(javaResource, FolderMapper) {
    /**
     * Timestamp when the Folder was created. Assigned by the server.
     * A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * The folder’s display name.
     * A folder’s display name must be unique amongst its siblings, e.g. no two folders with the same parent can share the same display name. The display name must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be no longer than 30 characters.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * The folder id from the name "folders/{folder_id}"
     */
    public val folderId: Output
        get() = javaResource.folderId().applyValue({ args0 -> args0 })

    /**
     * The lifecycle state of the folder such as `ACTIVE` or `DELETE_REQUESTED`.
     */
    public val lifecycleState: Output
        get() = javaResource.lifecycleState().applyValue({ args0 -> args0 })

    /**
     * The resource name of the Folder. Its format is folders/{folder_id}.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The resource name of the parent Folder or Organization.
     * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
     */
    public val parent: Output
        get() = javaResource.parent().applyValue({ args0 -> args0 })
}

public object FolderMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.organizations.Folder::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy