# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
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__ = ['ProjectDeployTokenArgs', 'ProjectDeployToken']

@pulumi.input_type
class ProjectDeployTokenArgs:
    def __init__(__self__, *,
                 project: pulumi.Input[_builtins.str],
                 scopes: pulumi.Input[Sequence[pulumi.Input[_builtins.str]]],
                 expires_at: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 username: Optional[pulumi.Input[_builtins.str]] = None,
                 validate_past_expiration_date: Optional[pulumi.Input[_builtins.bool]] = None):
        """
        The set of arguments for constructing a ProjectDeployToken resource.
        :param pulumi.Input[_builtins.str] project: The Id or full path of the project.
        :param pulumi.Input[Sequence[pulumi.Input[_builtins.str]]] scopes: The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        :param pulumi.Input[_builtins.str] expires_at: Time the token expires in RFC3339 format. Not set by default.
        :param pulumi.Input[_builtins.str] name: A name to describe the deploy token with.
        :param pulumi.Input[_builtins.str] username: A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        :param pulumi.Input[_builtins.bool] validate_past_expiration_date: Wether to validate if the expiration date is in the future.
        """
        pulumi.set(__self__, "project", project)
        pulumi.set(__self__, "scopes", scopes)
        if expires_at is not None:
            pulumi.set(__self__, "expires_at", expires_at)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if username is not None:
            pulumi.set(__self__, "username", username)
        if validate_past_expiration_date is not None:
            pulumi.set(__self__, "validate_past_expiration_date", validate_past_expiration_date)

    @_builtins.property
    @pulumi.getter
    def project(self) -> pulumi.Input[_builtins.str]:
        """
        The Id or full path of the project.
        """
        return pulumi.get(self, "project")

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

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]:
        """
        The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        """
        return pulumi.get(self, "scopes")

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

    @_builtins.property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Time the token expires in RFC3339 format. Not set by default.
        """
        return pulumi.get(self, "expires_at")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        A name to describe the deploy token with.
        """
        return pulumi.get(self, "name")

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

    @_builtins.property
    @pulumi.getter
    def username(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        """
        return pulumi.get(self, "username")

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

    @_builtins.property
    @pulumi.getter(name="validatePastExpirationDate")
    def validate_past_expiration_date(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Wether to validate if the expiration date is in the future.
        """
        return pulumi.get(self, "validate_past_expiration_date")

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


@pulumi.input_type
class _ProjectDeployTokenState:
    def __init__(__self__, *,
                 expired: Optional[pulumi.Input[_builtins.bool]] = None,
                 expires_at: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 project: Optional[pulumi.Input[_builtins.str]] = None,
                 revoked: Optional[pulumi.Input[_builtins.bool]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]] = None,
                 token: Optional[pulumi.Input[_builtins.str]] = None,
                 username: Optional[pulumi.Input[_builtins.str]] = None,
                 validate_past_expiration_date: Optional[pulumi.Input[_builtins.bool]] = None):
        """
        Input properties used for looking up and filtering ProjectDeployToken resources.
        :param pulumi.Input[_builtins.bool] expired: True if the token is expired.
        :param pulumi.Input[_builtins.str] expires_at: Time the token expires in RFC3339 format. Not set by default.
        :param pulumi.Input[_builtins.str] name: A name to describe the deploy token with.
        :param pulumi.Input[_builtins.str] project: The Id or full path of the project.
        :param pulumi.Input[_builtins.bool] revoked: True if the token is revoked.
        :param pulumi.Input[Sequence[pulumi.Input[_builtins.str]]] scopes: The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        :param pulumi.Input[_builtins.str] token: The secret token. This is only populated when creating a new deploy token. **Note**: The token is not available for imported resources.
        :param pulumi.Input[_builtins.str] username: A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        :param pulumi.Input[_builtins.bool] validate_past_expiration_date: Wether to validate if the expiration date is in the future.
        """
        if expired is not None:
            pulumi.set(__self__, "expired", expired)
        if expires_at is not None:
            pulumi.set(__self__, "expires_at", expires_at)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if project is not None:
            pulumi.set(__self__, "project", project)
        if revoked is not None:
            pulumi.set(__self__, "revoked", revoked)
        if scopes is not None:
            pulumi.set(__self__, "scopes", scopes)
        if token is not None:
            pulumi.set(__self__, "token", token)
        if username is not None:
            pulumi.set(__self__, "username", username)
        if validate_past_expiration_date is not None:
            pulumi.set(__self__, "validate_past_expiration_date", validate_past_expiration_date)

    @_builtins.property
    @pulumi.getter
    def expired(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        True if the token is expired.
        """
        return pulumi.get(self, "expired")

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

    @_builtins.property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Time the token expires in RFC3339 format. Not set by default.
        """
        return pulumi.get(self, "expires_at")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        A name to describe the deploy token with.
        """
        return pulumi.get(self, "name")

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

    @_builtins.property
    @pulumi.getter
    def project(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The Id or full path of the project.
        """
        return pulumi.get(self, "project")

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

    @_builtins.property
    @pulumi.getter
    def revoked(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        True if the token is revoked.
        """
        return pulumi.get(self, "revoked")

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

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]]:
        """
        The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        """
        return pulumi.get(self, "scopes")

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

    @_builtins.property
    @pulumi.getter
    def token(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The secret token. This is only populated when creating a new deploy token. **Note**: The token is not available for imported resources.
        """
        return pulumi.get(self, "token")

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

    @_builtins.property
    @pulumi.getter
    def username(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        """
        return pulumi.get(self, "username")

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

    @_builtins.property
    @pulumi.getter(name="validatePastExpirationDate")
    def validate_past_expiration_date(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Wether to validate if the expiration date is in the future.
        """
        return pulumi.get(self, "validate_past_expiration_date")

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


@pulumi.type_token("gitlab:index/projectDeployToken:ProjectDeployToken")
class ProjectDeployToken(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 expires_at: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 project: Optional[pulumi.Input[_builtins.str]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]] = None,
                 username: Optional[pulumi.Input[_builtins.str]] = None,
                 validate_past_expiration_date: Optional[pulumi.Input[_builtins.bool]] = None,
                 __props__=None):
        """
        The `ProjectDeployToken` resource allows you to manage the lifecycle of deploy tokens on a project.

        **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/api/deploy_tokens/#project-deploy-tokens)

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab
        import pulumi_std as std

        # Example Usage
        example = gitlab.ProjectDeployToken("example",
            project="example/deploying",
            name="Example project deploy token",
            username="example-username",
            expires_at="2020-03-14T00:00:00.000Z",
            scopes=[
                "read_repository",
                "read_registry",
            ])
        example_two = gitlab.ProjectDeployToken("example-two",
            project="12345678",
            name="Example project deploy token expires in 24h",
            expires_at=std.timeadd(duration=std.timestamp().result,
                timestamp="24h").result,
            scopes=[
                "read_repository",
                "read_registry",
            ])
        ```

        ## Import

        Starting in Terraform v1.5.0, you can use an import block to import `gitlab_project_deploy_token`. For example:

        terraform

        import {

          to = gitlab_project_deploy_token.example

          id = "see CLI command below for ID"

        }

        Importing using the CLI is supported with the following syntax:

        GitLab project deploy tokens can be imported using an id made up of `{project_id}:{deploy_token_id}`.

        ```sh
        $ pulumi import gitlab:index/projectDeployToken:ProjectDeployToken project_token 1:4
        ```

        Note: the `token` resource attribute is not available for imported resources as this information cannot be read from the GitLab API.

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] expires_at: Time the token expires in RFC3339 format. Not set by default.
        :param pulumi.Input[_builtins.str] name: A name to describe the deploy token with.
        :param pulumi.Input[_builtins.str] project: The Id or full path of the project.
        :param pulumi.Input[Sequence[pulumi.Input[_builtins.str]]] scopes: The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        :param pulumi.Input[_builtins.str] username: A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        :param pulumi.Input[_builtins.bool] validate_past_expiration_date: Wether to validate if the expiration date is in the future.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: ProjectDeployTokenArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        The `ProjectDeployToken` resource allows you to manage the lifecycle of deploy tokens on a project.

        **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/api/deploy_tokens/#project-deploy-tokens)

        ## Example Usage

        ```python
        import pulumi
        import pulumi_gitlab as gitlab
        import pulumi_std as std

        # Example Usage
        example = gitlab.ProjectDeployToken("example",
            project="example/deploying",
            name="Example project deploy token",
            username="example-username",
            expires_at="2020-03-14T00:00:00.000Z",
            scopes=[
                "read_repository",
                "read_registry",
            ])
        example_two = gitlab.ProjectDeployToken("example-two",
            project="12345678",
            name="Example project deploy token expires in 24h",
            expires_at=std.timeadd(duration=std.timestamp().result,
                timestamp="24h").result,
            scopes=[
                "read_repository",
                "read_registry",
            ])
        ```

        ## Import

        Starting in Terraform v1.5.0, you can use an import block to import `gitlab_project_deploy_token`. For example:

        terraform

        import {

          to = gitlab_project_deploy_token.example

          id = "see CLI command below for ID"

        }

        Importing using the CLI is supported with the following syntax:

        GitLab project deploy tokens can be imported using an id made up of `{project_id}:{deploy_token_id}`.

        ```sh
        $ pulumi import gitlab:index/projectDeployToken:ProjectDeployToken project_token 1:4
        ```

        Note: the `token` resource attribute is not available for imported resources as this information cannot be read from the GitLab API.

        :param str resource_name: The name of the resource.
        :param ProjectDeployTokenArgs 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(ProjectDeployTokenArgs, 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,
                 expires_at: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 project: Optional[pulumi.Input[_builtins.str]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]] = None,
                 username: Optional[pulumi.Input[_builtins.str]] = None,
                 validate_past_expiration_date: Optional[pulumi.Input[_builtins.bool]] = 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__ = ProjectDeployTokenArgs.__new__(ProjectDeployTokenArgs)

            __props__.__dict__["expires_at"] = expires_at
            __props__.__dict__["name"] = name
            if project is None and not opts.urn:
                raise TypeError("Missing required property 'project'")
            __props__.__dict__["project"] = project
            if scopes is None and not opts.urn:
                raise TypeError("Missing required property 'scopes'")
            __props__.__dict__["scopes"] = scopes
            __props__.__dict__["username"] = username
            __props__.__dict__["validate_past_expiration_date"] = validate_past_expiration_date
            __props__.__dict__["expired"] = None
            __props__.__dict__["revoked"] = None
            __props__.__dict__["token"] = None
        secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["token"])
        opts = pulumi.ResourceOptions.merge(opts, secret_opts)
        super(ProjectDeployToken, __self__).__init__(
            'gitlab:index/projectDeployToken:ProjectDeployToken',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            expired: Optional[pulumi.Input[_builtins.bool]] = None,
            expires_at: Optional[pulumi.Input[_builtins.str]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            project: Optional[pulumi.Input[_builtins.str]] = None,
            revoked: Optional[pulumi.Input[_builtins.bool]] = None,
            scopes: Optional[pulumi.Input[Sequence[pulumi.Input[_builtins.str]]]] = None,
            token: Optional[pulumi.Input[_builtins.str]] = None,
            username: Optional[pulumi.Input[_builtins.str]] = None,
            validate_past_expiration_date: Optional[pulumi.Input[_builtins.bool]] = None) -> 'ProjectDeployToken':
        """
        Get an existing ProjectDeployToken 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[_builtins.bool] expired: True if the token is expired.
        :param pulumi.Input[_builtins.str] expires_at: Time the token expires in RFC3339 format. Not set by default.
        :param pulumi.Input[_builtins.str] name: A name to describe the deploy token with.
        :param pulumi.Input[_builtins.str] project: The Id or full path of the project.
        :param pulumi.Input[_builtins.bool] revoked: True if the token is revoked.
        :param pulumi.Input[Sequence[pulumi.Input[_builtins.str]]] scopes: The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        :param pulumi.Input[_builtins.str] token: The secret token. This is only populated when creating a new deploy token. **Note**: The token is not available for imported resources.
        :param pulumi.Input[_builtins.str] username: A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        :param pulumi.Input[_builtins.bool] validate_past_expiration_date: Wether to validate if the expiration date is in the future.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _ProjectDeployTokenState.__new__(_ProjectDeployTokenState)

        __props__.__dict__["expired"] = expired
        __props__.__dict__["expires_at"] = expires_at
        __props__.__dict__["name"] = name
        __props__.__dict__["project"] = project
        __props__.__dict__["revoked"] = revoked
        __props__.__dict__["scopes"] = scopes
        __props__.__dict__["token"] = token
        __props__.__dict__["username"] = username
        __props__.__dict__["validate_past_expiration_date"] = validate_past_expiration_date
        return ProjectDeployToken(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter
    def expired(self) -> pulumi.Output[_builtins.bool]:
        """
        True if the token is expired.
        """
        return pulumi.get(self, "expired")

    @_builtins.property
    @pulumi.getter(name="expiresAt")
    def expires_at(self) -> pulumi.Output[_builtins.str]:
        """
        Time the token expires in RFC3339 format. Not set by default.
        """
        return pulumi.get(self, "expires_at")

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Output[_builtins.str]:
        """
        A name to describe the deploy token with.
        """
        return pulumi.get(self, "name")

    @_builtins.property
    @pulumi.getter
    def project(self) -> pulumi.Output[_builtins.str]:
        """
        The Id or full path of the project.
        """
        return pulumi.get(self, "project")

    @_builtins.property
    @pulumi.getter
    def revoked(self) -> pulumi.Output[_builtins.bool]:
        """
        True if the token is revoked.
        """
        return pulumi.get(self, "revoked")

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> pulumi.Output[Sequence[_builtins.str]]:
        """
        The scopes of the project deploy token. Valid values are: `read_repository`, `read_registry`, `write_registry`, `read_virtual_registry`, `write_virtual_registry`, `read_package_registry`, `write_package_registry`
        """
        return pulumi.get(self, "scopes")

    @_builtins.property
    @pulumi.getter
    def token(self) -> pulumi.Output[_builtins.str]:
        """
        The secret token. This is only populated when creating a new deploy token. **Note**: The token is not available for imported resources.
        """
        return pulumi.get(self, "token")

    @_builtins.property
    @pulumi.getter
    def username(self) -> pulumi.Output[_builtins.str]:
        """
        A username for the deploy token. Default is `gitlab+deploy-token-{n}`.
        """
        return pulumi.get(self, "username")

    @_builtins.property
    @pulumi.getter(name="validatePastExpirationDate")
    def validate_past_expiration_date(self) -> pulumi.Output[_builtins.bool]:
        """
        Wether to validate if the expiration date is in the future.
        """
        return pulumi.get(self, "validate_past_expiration_date")

