# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import copy
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from . import _utilities

__all__ = ['GroupMembershipArgs', 'GroupMembership']

@pulumi.input_type
class GroupMembershipArgs:
    def __init__(__self__, *,
                 access_level: pulumi.Input[str],
                 group_id: pulumi.Input[str],
                 user_id: pulumi.Input[int],
                 expires_at: Optional[pulumi.Input[str]] = None,
                 member_role_id: Optional[pulumi.Input[int]] = None,
                 skip_subresources_on_destroy: Optional[pulumi.Input[bool]] = None,
                 unassign_issuables_on_destroy: Optional[pulumi.Input[bool]] = None):
        """
        The set of arguments for constructing a GroupMembership resource.
        :param pulumi.Input[str] access_level: Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        :param pulumi.Input[str] group_id: The id of the group.
        :param pulumi.Input[int] user_id: The id of the user.
        :param pulumi.Input[str] expires_at: Expiration date for the group membership. Format: `YYYY-MM-DD`
        :param pulumi.Input[int] member_role_id: The ID of a custom member role. Only available for Ultimate instances.
        :param pulumi.Input[bool] skip_subresources_on_destroy: Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        :param pulumi.Input[bool] unassign_issuables_on_destroy: Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        """
        pulumi.set(__self__, "access_level", access_level)
        pulumi.set(__self__, "group_id", group_id)
        pulumi.set(__self__, "user_id", user_id)
        if expires_at is not None:
            pulumi.set(__self__, "expires_at", expires_at)
        if member_role_id is not None:
            pulumi.set(__self__, "member_role_id", member_role_id)
        if skip_subresources_on_destroy is not None:
            pulumi.set(__self__, "skip_subresources_on_destroy", skip_subresources_on_destroy)
        if unassign_issuables_on_destroy is not None:
            pulumi.set(__self__, "unassign_issuables_on_destroy", unassign_issuables_on_destroy)

    @property
    @pulumi.getter(name="accessLevel")
    def access_level(self) -> pulumi.Input[str]:
        """
        Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        """
        return pulumi.get(self, "access_level")

    @access_level.setter
    def access_level(self, value: pulumi.Input[str]):
        pulumi.set(self, "access_level", value)

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> pulumi.Input[str]:
        """
        The id of the group.
        """
        return pulumi.get(self, "group_id")

    @group_id.setter
    def group_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "group_id", value)

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> pulumi.Input[int]:
        """
        The id of the user.
        """
        return pulumi.get(self, "user_id")

    @user_id.setter
    def user_id(self, value: pulumi.Input[int]):
        pulumi.set(self, "user_id", value)

    @property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> Optional[pulumi.Input[str]]:
        """
        Expiration date for the group membership. Format: `YYYY-MM-DD`
        """
        return pulumi.get(self, "expires_at")

    @expires_at.setter
    def expires_at(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "expires_at", value)

    @property
    @pulumi.getter(name="memberRoleId")
    def member_role_id(self) -> Optional[pulumi.Input[int]]:
        """
        The ID of a custom member role. Only available for Ultimate instances.
        """
        return pulumi.get(self, "member_role_id")

    @member_role_id.setter
    def member_role_id(self, value: Optional[pulumi.Input[int]]):
        pulumi.set(self, "member_role_id", value)

    @property
    @pulumi.getter(name="skipSubresourcesOnDestroy")
    def skip_subresources_on_destroy(self) -> Optional[pulumi.Input[bool]]:
        """
        Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        """
        return pulumi.get(self, "skip_subresources_on_destroy")

    @skip_subresources_on_destroy.setter
    def skip_subresources_on_destroy(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "skip_subresources_on_destroy", value)

    @property
    @pulumi.getter(name="unassignIssuablesOnDestroy")
    def unassign_issuables_on_destroy(self) -> Optional[pulumi.Input[bool]]:
        """
        Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        """
        return pulumi.get(self, "unassign_issuables_on_destroy")

    @unassign_issuables_on_destroy.setter
    def unassign_issuables_on_destroy(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "unassign_issuables_on_destroy", value)


@pulumi.input_type
class _GroupMembershipState:
    def __init__(__self__, *,
                 access_level: Optional[pulumi.Input[str]] = None,
                 expires_at: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 member_role_id: Optional[pulumi.Input[int]] = None,
                 skip_subresources_on_destroy: Optional[pulumi.Input[bool]] = None,
                 unassign_issuables_on_destroy: Optional[pulumi.Input[bool]] = None,
                 user_id: Optional[pulumi.Input[int]] = None):
        """
        Input properties used for looking up and filtering GroupMembership resources.
        :param pulumi.Input[str] access_level: Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        :param pulumi.Input[str] expires_at: Expiration date for the group membership. Format: `YYYY-MM-DD`
        :param pulumi.Input[str] group_id: The id of the group.
        :param pulumi.Input[int] member_role_id: The ID of a custom member role. Only available for Ultimate instances.
        :param pulumi.Input[bool] skip_subresources_on_destroy: Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        :param pulumi.Input[bool] unassign_issuables_on_destroy: Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        :param pulumi.Input[int] user_id: The id of the user.
        """
        if access_level is not None:
            pulumi.set(__self__, "access_level", access_level)
        if expires_at is not None:
            pulumi.set(__self__, "expires_at", expires_at)
        if group_id is not None:
            pulumi.set(__self__, "group_id", group_id)
        if member_role_id is not None:
            pulumi.set(__self__, "member_role_id", member_role_id)
        if skip_subresources_on_destroy is not None:
            pulumi.set(__self__, "skip_subresources_on_destroy", skip_subresources_on_destroy)
        if unassign_issuables_on_destroy is not None:
            pulumi.set(__self__, "unassign_issuables_on_destroy", unassign_issuables_on_destroy)
        if user_id is not None:
            pulumi.set(__self__, "user_id", user_id)

    @property
    @pulumi.getter(name="accessLevel")
    def access_level(self) -> Optional[pulumi.Input[str]]:
        """
        Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        """
        return pulumi.get(self, "access_level")

    @access_level.setter
    def access_level(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "access_level", value)

    @property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> Optional[pulumi.Input[str]]:
        """
        Expiration date for the group membership. Format: `YYYY-MM-DD`
        """
        return pulumi.get(self, "expires_at")

    @expires_at.setter
    def expires_at(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "expires_at", value)

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> Optional[pulumi.Input[str]]:
        """
        The id of the group.
        """
        return pulumi.get(self, "group_id")

    @group_id.setter
    def group_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "group_id", value)

    @property
    @pulumi.getter(name="memberRoleId")
    def member_role_id(self) -> Optional[pulumi.Input[int]]:
        """
        The ID of a custom member role. Only available for Ultimate instances.
        """
        return pulumi.get(self, "member_role_id")

    @member_role_id.setter
    def member_role_id(self, value: Optional[pulumi.Input[int]]):
        pulumi.set(self, "member_role_id", value)

    @property
    @pulumi.getter(name="skipSubresourcesOnDestroy")
    def skip_subresources_on_destroy(self) -> Optional[pulumi.Input[bool]]:
        """
        Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        """
        return pulumi.get(self, "skip_subresources_on_destroy")

    @skip_subresources_on_destroy.setter
    def skip_subresources_on_destroy(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "skip_subresources_on_destroy", value)

    @property
    @pulumi.getter(name="unassignIssuablesOnDestroy")
    def unassign_issuables_on_destroy(self) -> Optional[pulumi.Input[bool]]:
        """
        Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        """
        return pulumi.get(self, "unassign_issuables_on_destroy")

    @unassign_issuables_on_destroy.setter
    def unassign_issuables_on_destroy(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "unassign_issuables_on_destroy", value)

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> Optional[pulumi.Input[int]]:
        """
        The id of the user.
        """
        return pulumi.get(self, "user_id")

    @user_id.setter
    def user_id(self, value: Optional[pulumi.Input[int]]):
        pulumi.set(self, "user_id", value)


class GroupMembership(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 access_level: Optional[pulumi.Input[str]] = None,
                 expires_at: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 member_role_id: Optional[pulumi.Input[int]] = None,
                 skip_subresources_on_destroy: Optional[pulumi.Input[bool]] = None,
                 unassign_issuables_on_destroy: Optional[pulumi.Input[bool]] = None,
                 user_id: Optional[pulumi.Input[int]] = None,
                 __props__=None):
        """
        The `GroupMembership` resource allows to manage the lifecycle of a users group membership.

        > If a group should grant membership to another group use the `GroupShareGroup` resource instead.

        **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/members.html)

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab

        test = gitlab.GroupMembership("test",
            group_id="12345",
            user_id=1337,
            access_level="guest",
            expires_at="2020-12-31")
        ```

        ## Import

        GitLab group membership can be imported using an id made up of `group_id:user_id`, e.g.

        ```sh
        $ pulumi import gitlab:index/groupMembership:GroupMembership test "12345:1337"
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] access_level: Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        :param pulumi.Input[str] expires_at: Expiration date for the group membership. Format: `YYYY-MM-DD`
        :param pulumi.Input[str] group_id: The id of the group.
        :param pulumi.Input[int] member_role_id: The ID of a custom member role. Only available for Ultimate instances.
        :param pulumi.Input[bool] skip_subresources_on_destroy: Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        :param pulumi.Input[bool] unassign_issuables_on_destroy: Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        :param pulumi.Input[int] user_id: The id of the user.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: GroupMembershipArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        The `GroupMembership` resource allows to manage the lifecycle of a users group membership.

        > If a group should grant membership to another group use the `GroupShareGroup` resource instead.

        **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/members.html)

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab

        test = gitlab.GroupMembership("test",
            group_id="12345",
            user_id=1337,
            access_level="guest",
            expires_at="2020-12-31")
        ```

        ## Import

        GitLab group membership can be imported using an id made up of `group_id:user_id`, e.g.

        ```sh
        $ pulumi import gitlab:index/groupMembership:GroupMembership test "12345:1337"
        ```

        :param str resource_name: The name of the resource.
        :param GroupMembershipArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(GroupMembershipArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 access_level: Optional[pulumi.Input[str]] = None,
                 expires_at: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 member_role_id: Optional[pulumi.Input[int]] = None,
                 skip_subresources_on_destroy: Optional[pulumi.Input[bool]] = None,
                 unassign_issuables_on_destroy: Optional[pulumi.Input[bool]] = None,
                 user_id: Optional[pulumi.Input[int]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = GroupMembershipArgs.__new__(GroupMembershipArgs)

            if access_level is None and not opts.urn:
                raise TypeError("Missing required property 'access_level'")
            __props__.__dict__["access_level"] = access_level
            __props__.__dict__["expires_at"] = expires_at
            if group_id is None and not opts.urn:
                raise TypeError("Missing required property 'group_id'")
            __props__.__dict__["group_id"] = group_id
            __props__.__dict__["member_role_id"] = member_role_id
            __props__.__dict__["skip_subresources_on_destroy"] = skip_subresources_on_destroy
            __props__.__dict__["unassign_issuables_on_destroy"] = unassign_issuables_on_destroy
            if user_id is None and not opts.urn:
                raise TypeError("Missing required property 'user_id'")
            __props__.__dict__["user_id"] = user_id
        super(GroupMembership, __self__).__init__(
            'gitlab:index/groupMembership:GroupMembership',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            access_level: Optional[pulumi.Input[str]] = None,
            expires_at: Optional[pulumi.Input[str]] = None,
            group_id: Optional[pulumi.Input[str]] = None,
            member_role_id: Optional[pulumi.Input[int]] = None,
            skip_subresources_on_destroy: Optional[pulumi.Input[bool]] = None,
            unassign_issuables_on_destroy: Optional[pulumi.Input[bool]] = None,
            user_id: Optional[pulumi.Input[int]] = None) -> 'GroupMembership':
        """
        Get an existing GroupMembership resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] access_level: Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        :param pulumi.Input[str] expires_at: Expiration date for the group membership. Format: `YYYY-MM-DD`
        :param pulumi.Input[str] group_id: The id of the group.
        :param pulumi.Input[int] member_role_id: The ID of a custom member role. Only available for Ultimate instances.
        :param pulumi.Input[bool] skip_subresources_on_destroy: Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        :param pulumi.Input[bool] unassign_issuables_on_destroy: Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        :param pulumi.Input[int] user_id: The id of the user.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _GroupMembershipState.__new__(_GroupMembershipState)

        __props__.__dict__["access_level"] = access_level
        __props__.__dict__["expires_at"] = expires_at
        __props__.__dict__["group_id"] = group_id
        __props__.__dict__["member_role_id"] = member_role_id
        __props__.__dict__["skip_subresources_on_destroy"] = skip_subresources_on_destroy
        __props__.__dict__["unassign_issuables_on_destroy"] = unassign_issuables_on_destroy
        __props__.__dict__["user_id"] = user_id
        return GroupMembership(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="accessLevel")
    def access_level(self) -> pulumi.Output[str]:
        """
        Access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`.
        """
        return pulumi.get(self, "access_level")

    @property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> pulumi.Output[Optional[str]]:
        """
        Expiration date for the group membership. Format: `YYYY-MM-DD`
        """
        return pulumi.get(self, "expires_at")

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> pulumi.Output[str]:
        """
        The id of the group.
        """
        return pulumi.get(self, "group_id")

    @property
    @pulumi.getter(name="memberRoleId")
    def member_role_id(self) -> pulumi.Output[Optional[int]]:
        """
        The ID of a custom member role. Only available for Ultimate instances.
        """
        return pulumi.get(self, "member_role_id")

    @property
    @pulumi.getter(name="skipSubresourcesOnDestroy")
    def skip_subresources_on_destroy(self) -> pulumi.Output[Optional[bool]]:
        """
        Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
        """
        return pulumi.get(self, "skip_subresources_on_destroy")

    @property
    @pulumi.getter(name="unassignIssuablesOnDestroy")
    def unassign_issuables_on_destroy(self) -> pulumi.Output[Optional[bool]]:
        """
        Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
        """
        return pulumi.get(self, "unassign_issuables_on_destroy")

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> pulumi.Output[int]:
        """
        The id of the user.
        """
        return pulumi.get(self, "user_id")

