# 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 warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from . import _utilities
from . import outputs
from ._inputs import *

__all__ = ['ProjectProtectedEnvironmentArgs', 'ProjectProtectedEnvironment']

@pulumi.input_type
class ProjectProtectedEnvironmentArgs:
    def __init__(__self__, *,
                 deploy_access_levels: pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs'],
                 environment: pulumi.Input[str],
                 project: pulumi.Input[str]):
        """
        The set of arguments for constructing a ProjectProtectedEnvironment resource.
        :param pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs'] deploy_access_levels: Array of access levels allowed to deploy, with each described by a hash.
        :param pulumi.Input[str] environment: The name of the environment.
        :param pulumi.Input[str] project: The ID or full path of the project which the protected environment is created against.
        """
        pulumi.set(__self__, "deploy_access_levels", deploy_access_levels)
        pulumi.set(__self__, "environment", environment)
        pulumi.set(__self__, "project", project)

    @property
    @pulumi.getter(name="deployAccessLevels")
    def deploy_access_levels(self) -> pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs']:
        """
        Array of access levels allowed to deploy, with each described by a hash.
        """
        return pulumi.get(self, "deploy_access_levels")

    @deploy_access_levels.setter
    def deploy_access_levels(self, value: pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs']):
        pulumi.set(self, "deploy_access_levels", value)

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

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

    @property
    @pulumi.getter
    def project(self) -> pulumi.Input[str]:
        """
        The ID or full path of the project which the protected environment is created against.
        """
        return pulumi.get(self, "project")

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


@pulumi.input_type
class _ProjectProtectedEnvironmentState:
    def __init__(__self__, *,
                 deploy_access_levels: Optional[pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs']] = None,
                 environment: Optional[pulumi.Input[str]] = None,
                 project: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering ProjectProtectedEnvironment resources.
        :param pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs'] deploy_access_levels: Array of access levels allowed to deploy, with each described by a hash.
        :param pulumi.Input[str] environment: The name of the environment.
        :param pulumi.Input[str] project: The ID or full path of the project which the protected environment is created against.
        """
        if deploy_access_levels is not None:
            pulumi.set(__self__, "deploy_access_levels", deploy_access_levels)
        if environment is not None:
            pulumi.set(__self__, "environment", environment)
        if project is not None:
            pulumi.set(__self__, "project", project)

    @property
    @pulumi.getter(name="deployAccessLevels")
    def deploy_access_levels(self) -> Optional[pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs']]:
        """
        Array of access levels allowed to deploy, with each described by a hash.
        """
        return pulumi.get(self, "deploy_access_levels")

    @deploy_access_levels.setter
    def deploy_access_levels(self, value: Optional[pulumi.Input['ProjectProtectedEnvironmentDeployAccessLevelsArgs']]):
        pulumi.set(self, "deploy_access_levels", value)

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

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

    @property
    @pulumi.getter
    def project(self) -> Optional[pulumi.Input[str]]:
        """
        The ID or full path of the project which the protected environment is created against.
        """
        return pulumi.get(self, "project")

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


class ProjectProtectedEnvironment(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 deploy_access_levels: Optional[pulumi.Input[pulumi.InputType['ProjectProtectedEnvironmentDeployAccessLevelsArgs']]] = None,
                 environment: Optional[pulumi.Input[str]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        The `ProjectProtectedEnvironment` resource allows to manage the lifecycle of a protected environment in a project.

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

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab

        this_group = gitlab.Group("thisGroup",
            path="example",
            description="An example group")
        this_project = gitlab.Project("thisProject",
            namespace_id=this_group.id,
            initialize_with_readme=True)
        this_project_environment = gitlab.ProjectEnvironment("thisProjectEnvironment",
            project=this_project.id,
            external_url="www.example.com")
        this_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                access_level="developer",
            ))
        this_index_project_protected_environment_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisIndex/projectProtectedEnvironmentProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                group_id=gitlab_group["test"]["id"],
            ))
        this_gitlab_index_project_protected_environment_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisGitlabIndex/projectProtectedEnvironmentProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                user_id=gitlab_user["test"]["id"],
            ))
        ```

        ## Import

        # GitLab protected environments can be imported using an id made up of `projectId:environmentName`, e.g.

        ```sh
         $ pulumi import gitlab:index/projectProtectedEnvironment:ProjectProtectedEnvironment bar 123:production
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[pulumi.InputType['ProjectProtectedEnvironmentDeployAccessLevelsArgs']] deploy_access_levels: Array of access levels allowed to deploy, with each described by a hash.
        :param pulumi.Input[str] environment: The name of the environment.
        :param pulumi.Input[str] project: The ID or full path of the project which the protected environment is created against.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: ProjectProtectedEnvironmentArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        The `ProjectProtectedEnvironment` resource allows to manage the lifecycle of a protected environment in a project.

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

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab

        this_group = gitlab.Group("thisGroup",
            path="example",
            description="An example group")
        this_project = gitlab.Project("thisProject",
            namespace_id=this_group.id,
            initialize_with_readme=True)
        this_project_environment = gitlab.ProjectEnvironment("thisProjectEnvironment",
            project=this_project.id,
            external_url="www.example.com")
        this_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                access_level="developer",
            ))
        this_index_project_protected_environment_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisIndex/projectProtectedEnvironmentProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                group_id=gitlab_group["test"]["id"],
            ))
        this_gitlab_index_project_protected_environment_project_protected_environment = gitlab.ProjectProtectedEnvironment("thisGitlabIndex/projectProtectedEnvironmentProjectProtectedEnvironment",
            project=this_project.id,
            environment=this_project_environment.name,
            deploy_access_levels=gitlab.ProjectProtectedEnvironmentDeployAccessLevelsArgs(
                user_id=gitlab_user["test"]["id"],
            ))
        ```

        ## Import

        # GitLab protected environments can be imported using an id made up of `projectId:environmentName`, e.g.

        ```sh
         $ pulumi import gitlab:index/projectProtectedEnvironment:ProjectProtectedEnvironment bar 123:production
        ```

        :param str resource_name: The name of the resource.
        :param ProjectProtectedEnvironmentArgs 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(ProjectProtectedEnvironmentArgs, 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,
                 deploy_access_levels: Optional[pulumi.Input[pulumi.InputType['ProjectProtectedEnvironmentDeployAccessLevelsArgs']]] = None,
                 environment: Optional[pulumi.Input[str]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        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__ = ProjectProtectedEnvironmentArgs.__new__(ProjectProtectedEnvironmentArgs)

            if deploy_access_levels is None and not opts.urn:
                raise TypeError("Missing required property 'deploy_access_levels'")
            __props__.__dict__["deploy_access_levels"] = deploy_access_levels
            if environment is None and not opts.urn:
                raise TypeError("Missing required property 'environment'")
            __props__.__dict__["environment"] = environment
            if project is None and not opts.urn:
                raise TypeError("Missing required property 'project'")
            __props__.__dict__["project"] = project
        super(ProjectProtectedEnvironment, __self__).__init__(
            'gitlab:index/projectProtectedEnvironment:ProjectProtectedEnvironment',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            deploy_access_levels: Optional[pulumi.Input[pulumi.InputType['ProjectProtectedEnvironmentDeployAccessLevelsArgs']]] = None,
            environment: Optional[pulumi.Input[str]] = None,
            project: Optional[pulumi.Input[str]] = None) -> 'ProjectProtectedEnvironment':
        """
        Get an existing ProjectProtectedEnvironment 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[pulumi.InputType['ProjectProtectedEnvironmentDeployAccessLevelsArgs']] deploy_access_levels: Array of access levels allowed to deploy, with each described by a hash.
        :param pulumi.Input[str] environment: The name of the environment.
        :param pulumi.Input[str] project: The ID or full path of the project which the protected environment is created against.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _ProjectProtectedEnvironmentState.__new__(_ProjectProtectedEnvironmentState)

        __props__.__dict__["deploy_access_levels"] = deploy_access_levels
        __props__.__dict__["environment"] = environment
        __props__.__dict__["project"] = project
        return ProjectProtectedEnvironment(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="deployAccessLevels")
    def deploy_access_levels(self) -> pulumi.Output['outputs.ProjectProtectedEnvironmentDeployAccessLevels']:
        """
        Array of access levels allowed to deploy, with each described by a hash.
        """
        return pulumi.get(self, "deploy_access_levels")

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

    @property
    @pulumi.getter
    def project(self) -> pulumi.Output[str]:
        """
        The ID or full path of the project which the protected environment is created against.
        """
        return pulumi.get(self, "project")

