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

com.pulumi.gcp.cloudidentity.kotlin.GroupMembership.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.cloudidentity.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipMemberKey
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipPreferredMemberKey
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipRole
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
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipMemberKey.Companion.toKotlin as groupMembershipMemberKeyToKotlin
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipPreferredMemberKey.Companion.toKotlin as groupMembershipPreferredMemberKeyToKotlin
import com.pulumi.gcp.cloudidentity.kotlin.outputs.GroupMembershipRole.Companion.toKotlin as groupMembershipRoleToKotlin

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

    public var args: GroupMembershipArgs = GroupMembershipArgs()

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

/**
 * A Membership defines a relationship between a Group and an entity belonging to that Group, referred to as a "member".
 * To get more information about GroupMembership, see:
 * * [API documentation](https://cloud.google.com/identity/docs/reference/rest/v1/groups.memberships)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/identity/docs/how-to/memberships-google-groups)
 * > **Warning:** If you are using User ADCs (Application Default Credentials) with this resource,
 * you must specify a `billing_project` and set `user_project_override` to true
 * in the provider configuration. Otherwise the Cloud Identity API will return a 403 error.
 * Your account must have the `serviceusage.services.use` permission on the
 * `billing_project` you defined.
 * ## Example Usage
 * ### Cloud Identity Group Membership
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const group = new gcp.cloudidentity.Group("group", {
 *     displayName: "my-identity-group",
 *     parent: "customers/A01b123xz",
 *     groupKey: {
 *         id: "[email protected]",
 *     },
 *     labels: {
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     },
 * });
 * const child_group = new gcp.cloudidentity.Group("child-group", {
 *     displayName: "my-identity-group-child",
 *     parent: "customers/A01b123xz",
 *     groupKey: {
 *         id: "[email protected]",
 *     },
 *     labels: {
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     },
 * });
 * const cloudIdentityGroupMembershipBasic = new gcp.cloudidentity.GroupMembership("cloud_identity_group_membership_basic", {
 *     group: group.id,
 *     preferredMemberKey: {
 *         id: child_group.groupKey.apply(groupKey => groupKey.id),
 *     },
 *     roles: [{
 *         name: "MEMBER",
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * group = gcp.cloudidentity.Group("group",
 *     display_name="my-identity-group",
 *     parent="customers/A01b123xz",
 *     group_key=gcp.cloudidentity.GroupGroupKeyArgs(
 *         id="[email protected]",
 *     ),
 *     labels={
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     })
 * child_group = gcp.cloudidentity.Group("child-group",
 *     display_name="my-identity-group-child",
 *     parent="customers/A01b123xz",
 *     group_key=gcp.cloudidentity.GroupGroupKeyArgs(
 *         id="[email protected]",
 *     ),
 *     labels={
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     })
 * cloud_identity_group_membership_basic = gcp.cloudidentity.GroupMembership("cloud_identity_group_membership_basic",
 *     group=group.id,
 *     preferred_member_key=gcp.cloudidentity.GroupMembershipPreferredMemberKeyArgs(
 *         id=child_group.group_key.id,
 *     ),
 *     roles=[gcp.cloudidentity.GroupMembershipRoleArgs(
 *         name="MEMBER",
 *     )])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @group = new Gcp.CloudIdentity.Group("group", new()
 *     {
 *         DisplayName = "my-identity-group",
 *         Parent = "customers/A01b123xz",
 *         GroupKey = new Gcp.CloudIdentity.Inputs.GroupGroupKeyArgs
 *         {
 *             Id = "[email protected]",
 *         },
 *         Labels =
 *         {
 *             { "cloudidentity.googleapis.com/groups.discussion_forum", "" },
 *         },
 *     });
 *     var child_group = new Gcp.CloudIdentity.Group("child-group", new()
 *     {
 *         DisplayName = "my-identity-group-child",
 *         Parent = "customers/A01b123xz",
 *         GroupKey = new Gcp.CloudIdentity.Inputs.GroupGroupKeyArgs
 *         {
 *             Id = "[email protected]",
 *         },
 *         Labels =
 *         {
 *             { "cloudidentity.googleapis.com/groups.discussion_forum", "" },
 *         },
 *     });
 *     var cloudIdentityGroupMembershipBasic = new Gcp.CloudIdentity.GroupMembership("cloud_identity_group_membership_basic", new()
 *     {
 *         Group = @group.Id,
 *         PreferredMemberKey = new Gcp.CloudIdentity.Inputs.GroupMembershipPreferredMemberKeyArgs
 *         {
 *             Id = child_group.GroupKey.Apply(groupKey => groupKey.Id),
 *         },
 *         Roles = new[]
 *         {
 *             new Gcp.CloudIdentity.Inputs.GroupMembershipRoleArgs
 *             {
 *                 Name = "MEMBER",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudidentity"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		group, err := cloudidentity.NewGroup(ctx, "group", &cloudidentity.GroupArgs{
 * 			DisplayName: pulumi.String("my-identity-group"),
 * 			Parent:      pulumi.String("customers/A01b123xz"),
 * 			GroupKey: &cloudidentity.GroupGroupKeyArgs{
 * 				Id: pulumi.String("[email protected]"),
 * 			},
 * 			Labels: pulumi.StringMap{
 * 				"cloudidentity.googleapis.com/groups.discussion_forum": pulumi.String(""),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudidentity.NewGroup(ctx, "child-group", &cloudidentity.GroupArgs{
 * 			DisplayName: pulumi.String("my-identity-group-child"),
 * 			Parent:      pulumi.String("customers/A01b123xz"),
 * 			GroupKey: &cloudidentity.GroupGroupKeyArgs{
 * 				Id: pulumi.String("[email protected]"),
 * 			},
 * 			Labels: pulumi.StringMap{
 * 				"cloudidentity.googleapis.com/groups.discussion_forum": pulumi.String(""),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudidentity.NewGroupMembership(ctx, "cloud_identity_group_membership_basic", &cloudidentity.GroupMembershipArgs{
 * 			Group: group.ID(),
 * 			PreferredMemberKey: &cloudidentity.GroupMembershipPreferredMemberKeyArgs{
 * 				Id: child_group.GroupKey.ApplyT(func(groupKey cloudidentity.GroupGroupKey) (*string, error) {
 * 					return &groupKey.Id, nil
 * 				}).(pulumi.StringPtrOutput),
 * 			},
 * 			Roles: cloudidentity.GroupMembershipRoleArray{
 * 				&cloudidentity.GroupMembershipRoleArgs{
 * 					Name: pulumi.String("MEMBER"),
 * 				},
 * 			},
 * 		})
 * 		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.cloudidentity.Group;
 * import com.pulumi.gcp.cloudidentity.GroupArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupGroupKeyArgs;
 * import com.pulumi.gcp.cloudidentity.GroupMembership;
 * import com.pulumi.gcp.cloudidentity.GroupMembershipArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupMembershipPreferredMemberKeyArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupMembershipRoleArgs;
 * 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 group = new Group("group", GroupArgs.builder()
 *             .displayName("my-identity-group")
 *             .parent("customers/A01b123xz")
 *             .groupKey(GroupGroupKeyArgs.builder()
 *                 .id("[email protected]")
 *                 .build())
 *             .labels(Map.of("cloudidentity.googleapis.com/groups.discussion_forum", ""))
 *             .build());
 *         var child_group = new Group("child-group", GroupArgs.builder()
 *             .displayName("my-identity-group-child")
 *             .parent("customers/A01b123xz")
 *             .groupKey(GroupGroupKeyArgs.builder()
 *                 .id("[email protected]")
 *                 .build())
 *             .labels(Map.of("cloudidentity.googleapis.com/groups.discussion_forum", ""))
 *             .build());
 *         var cloudIdentityGroupMembershipBasic = new GroupMembership("cloudIdentityGroupMembershipBasic", GroupMembershipArgs.builder()
 *             .group(group.id())
 *             .preferredMemberKey(GroupMembershipPreferredMemberKeyArgs.builder()
 *                 .id(child_group.groupKey().applyValue(groupKey -> groupKey.id()))
 *                 .build())
 *             .roles(GroupMembershipRoleArgs.builder()
 *                 .name("MEMBER")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   group:
 *     type: gcp:cloudidentity:Group
 *     properties:
 *       displayName: my-identity-group
 *       parent: customers/A01b123xz
 *       groupKey:
 *         id: [email protected]
 *       labels:
 *         cloudidentity.googleapis.com/groups.discussion_forum:
 *   child-group:
 *     type: gcp:cloudidentity:Group
 *     properties:
 *       displayName: my-identity-group-child
 *       parent: customers/A01b123xz
 *       groupKey:
 *         id: [email protected]
 *       labels:
 *         cloudidentity.googleapis.com/groups.discussion_forum:
 *   cloudIdentityGroupMembershipBasic:
 *     type: gcp:cloudidentity:GroupMembership
 *     name: cloud_identity_group_membership_basic
 *     properties:
 *       group: ${group.id}
 *       preferredMemberKey:
 *         id: ${["child-group"].groupKey.id}
 *       roles:
 *         - name: MEMBER
 * ```
 * 
 * ### Cloud Identity Group Membership User
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const group = new gcp.cloudidentity.Group("group", {
 *     displayName: "my-identity-group",
 *     parent: "customers/A01b123xz",
 *     groupKey: {
 *         id: "[email protected]",
 *     },
 *     labels: {
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     },
 * });
 * const cloudIdentityGroupMembershipBasic = new gcp.cloudidentity.GroupMembership("cloud_identity_group_membership_basic", {
 *     group: group.id,
 *     preferredMemberKey: {
 *         id: "[email protected]",
 *     },
 *     roles: [
 *         {
 *             name: "MEMBER",
 *         },
 *         {
 *             name: "MANAGER",
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * group = gcp.cloudidentity.Group("group",
 *     display_name="my-identity-group",
 *     parent="customers/A01b123xz",
 *     group_key=gcp.cloudidentity.GroupGroupKeyArgs(
 *         id="[email protected]",
 *     ),
 *     labels={
 *         "cloudidentity.googleapis.com/groups.discussion_forum": "",
 *     })
 * cloud_identity_group_membership_basic = gcp.cloudidentity.GroupMembership("cloud_identity_group_membership_basic",
 *     group=group.id,
 *     preferred_member_key=gcp.cloudidentity.GroupMembershipPreferredMemberKeyArgs(
 *         id="[email protected]",
 *     ),
 *     roles=[
 *         gcp.cloudidentity.GroupMembershipRoleArgs(
 *             name="MEMBER",
 *         ),
 *         gcp.cloudidentity.GroupMembershipRoleArgs(
 *             name="MANAGER",
 *         ),
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @group = new Gcp.CloudIdentity.Group("group", new()
 *     {
 *         DisplayName = "my-identity-group",
 *         Parent = "customers/A01b123xz",
 *         GroupKey = new Gcp.CloudIdentity.Inputs.GroupGroupKeyArgs
 *         {
 *             Id = "[email protected]",
 *         },
 *         Labels =
 *         {
 *             { "cloudidentity.googleapis.com/groups.discussion_forum", "" },
 *         },
 *     });
 *     var cloudIdentityGroupMembershipBasic = new Gcp.CloudIdentity.GroupMembership("cloud_identity_group_membership_basic", new()
 *     {
 *         Group = @group.Id,
 *         PreferredMemberKey = new Gcp.CloudIdentity.Inputs.GroupMembershipPreferredMemberKeyArgs
 *         {
 *             Id = "[email protected]",
 *         },
 *         Roles = new[]
 *         {
 *             new Gcp.CloudIdentity.Inputs.GroupMembershipRoleArgs
 *             {
 *                 Name = "MEMBER",
 *             },
 *             new Gcp.CloudIdentity.Inputs.GroupMembershipRoleArgs
 *             {
 *                 Name = "MANAGER",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudidentity"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		group, err := cloudidentity.NewGroup(ctx, "group", &cloudidentity.GroupArgs{
 * 			DisplayName: pulumi.String("my-identity-group"),
 * 			Parent:      pulumi.String("customers/A01b123xz"),
 * 			GroupKey: &cloudidentity.GroupGroupKeyArgs{
 * 				Id: pulumi.String("[email protected]"),
 * 			},
 * 			Labels: pulumi.StringMap{
 * 				"cloudidentity.googleapis.com/groups.discussion_forum": pulumi.String(""),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudidentity.NewGroupMembership(ctx, "cloud_identity_group_membership_basic", &cloudidentity.GroupMembershipArgs{
 * 			Group: group.ID(),
 * 			PreferredMemberKey: &cloudidentity.GroupMembershipPreferredMemberKeyArgs{
 * 				Id: pulumi.String("[email protected]"),
 * 			},
 * 			Roles: cloudidentity.GroupMembershipRoleArray{
 * 				&cloudidentity.GroupMembershipRoleArgs{
 * 					Name: pulumi.String("MEMBER"),
 * 				},
 * 				&cloudidentity.GroupMembershipRoleArgs{
 * 					Name: pulumi.String("MANAGER"),
 * 				},
 * 			},
 * 		})
 * 		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.cloudidentity.Group;
 * import com.pulumi.gcp.cloudidentity.GroupArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupGroupKeyArgs;
 * import com.pulumi.gcp.cloudidentity.GroupMembership;
 * import com.pulumi.gcp.cloudidentity.GroupMembershipArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupMembershipPreferredMemberKeyArgs;
 * import com.pulumi.gcp.cloudidentity.inputs.GroupMembershipRoleArgs;
 * 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 group = new Group("group", GroupArgs.builder()
 *             .displayName("my-identity-group")
 *             .parent("customers/A01b123xz")
 *             .groupKey(GroupGroupKeyArgs.builder()
 *                 .id("[email protected]")
 *                 .build())
 *             .labels(Map.of("cloudidentity.googleapis.com/groups.discussion_forum", ""))
 *             .build());
 *         var cloudIdentityGroupMembershipBasic = new GroupMembership("cloudIdentityGroupMembershipBasic", GroupMembershipArgs.builder()
 *             .group(group.id())
 *             .preferredMemberKey(GroupMembershipPreferredMemberKeyArgs.builder()
 *                 .id("[email protected]")
 *                 .build())
 *             .roles(
 *                 GroupMembershipRoleArgs.builder()
 *                     .name("MEMBER")
 *                     .build(),
 *                 GroupMembershipRoleArgs.builder()
 *                     .name("MANAGER")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   group:
 *     type: gcp:cloudidentity:Group
 *     properties:
 *       displayName: my-identity-group
 *       parent: customers/A01b123xz
 *       groupKey:
 *         id: [email protected]
 *       labels:
 *         cloudidentity.googleapis.com/groups.discussion_forum:
 *   cloudIdentityGroupMembershipBasic:
 *     type: gcp:cloudidentity:GroupMembership
 *     name: cloud_identity_group_membership_basic
 *     properties:
 *       group: ${group.id}
 *       preferredMemberKey:
 *         id: [email protected]
 *       roles:
 *         - name: MEMBER
 *         - name: MANAGER
 * ```
 * 
 * ## Import
 * GroupMembership can be imported using any of these accepted formats:
 * * `{{name}}`
 * When using the `pulumi import` command, GroupMembership can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:cloudidentity/groupMembership:GroupMembership default {{name}}
 * ```
 */
public class GroupMembership internal constructor(
    override val javaResource: com.pulumi.gcp.cloudidentity.GroupMembership,
) : KotlinCustomResource(javaResource, GroupMembershipMapper) {
    /**
     * The time when the Membership was created.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * The name of the Group to create this membership in.
     */
    public val group: Output
        get() = javaResource.group().applyValue({ args0 -> args0 })

    /**
     * EntityKey of the member.
     */
    public val memberKey: Output
        get() = javaResource.memberKey().applyValue({ args0 ->
            args0.let({ args0 ->
                groupMembershipMemberKeyToKotlin(args0)
            })
        })

    /**
     * The resource name of the Membership, of the form groups/{group_id}/memberships/{membership_id}.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * EntityKey of the member.
     */
    public val preferredMemberKey: Output
        get() = javaResource.preferredMemberKey().applyValue({ args0 ->
            args0.let({ args0 ->
                groupMembershipPreferredMemberKeyToKotlin(args0)
            })
        })

    /**
     * The MembershipRoles that apply to the Membership.
     * Must not contain duplicate MembershipRoles with the same name.
     * Structure is documented below.
     */
    public val roles: Output>
        get() = javaResource.roles().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    groupMembershipRoleToKotlin(args0)
                })
            })
        })

    /**
     * The type of the membership.
     */
    public val type: Output
        get() = javaResource.type().applyValue({ args0 -> args0 })

    /**
     * The time when the Membership was last updated.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object GroupMembershipMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.cloudidentity.GroupMembership::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy