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

__all__ = ['TokenArgs', 'Token']

@pulumi.input_type
class TokenArgs:
    def __init__(__self__, *,
                 token_name: pulumi.Input[str],
                 user_id: pulumi.Input[str],
                 comment: Optional[pulumi.Input[str]] = None,
                 expiration_date: Optional[pulumi.Input[str]] = None,
                 privileges_separation: Optional[pulumi.Input[bool]] = None):
        """
        The set of arguments for constructing a Token resource.
        :param pulumi.Input[str] token_name: User-specific token identifier.
        :param pulumi.Input[str] user_id: User identifier.
        :param pulumi.Input[str] comment: Comment for the token.
        :param pulumi.Input[str] expiration_date: Expiration date for the token.
        :param pulumi.Input[bool] privileges_separation: Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        """
        pulumi.set(__self__, "token_name", token_name)
        pulumi.set(__self__, "user_id", user_id)
        if comment is not None:
            pulumi.set(__self__, "comment", comment)
        if expiration_date is not None:
            pulumi.set(__self__, "expiration_date", expiration_date)
        if privileges_separation is not None:
            pulumi.set(__self__, "privileges_separation", privileges_separation)

    @property
    @pulumi.getter(name="tokenName")
    def token_name(self) -> pulumi.Input[str]:
        """
        User-specific token identifier.
        """
        return pulumi.get(self, "token_name")

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

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> pulumi.Input[str]:
        """
        User identifier.
        """
        return pulumi.get(self, "user_id")

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

    @property
    @pulumi.getter
    def comment(self) -> Optional[pulumi.Input[str]]:
        """
        Comment for the token.
        """
        return pulumi.get(self, "comment")

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

    @property
    @pulumi.getter(name="expirationDate")
    def expiration_date(self) -> Optional[pulumi.Input[str]]:
        """
        Expiration date for the token.
        """
        return pulumi.get(self, "expiration_date")

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

    @property
    @pulumi.getter(name="privilegesSeparation")
    def privileges_separation(self) -> Optional[pulumi.Input[bool]]:
        """
        Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        """
        return pulumi.get(self, "privileges_separation")

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


@pulumi.input_type
class _TokenState:
    def __init__(__self__, *,
                 comment: Optional[pulumi.Input[str]] = None,
                 expiration_date: Optional[pulumi.Input[str]] = None,
                 privileges_separation: Optional[pulumi.Input[bool]] = None,
                 token_name: Optional[pulumi.Input[str]] = None,
                 user_id: Optional[pulumi.Input[str]] = None,
                 value: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering Token resources.
        :param pulumi.Input[str] comment: Comment for the token.
        :param pulumi.Input[str] expiration_date: Expiration date for the token.
        :param pulumi.Input[bool] privileges_separation: Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        :param pulumi.Input[str] token_name: User-specific token identifier.
        :param pulumi.Input[str] user_id: User identifier.
        :param pulumi.Input[str] value: API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
        """
        if comment is not None:
            pulumi.set(__self__, "comment", comment)
        if expiration_date is not None:
            pulumi.set(__self__, "expiration_date", expiration_date)
        if privileges_separation is not None:
            pulumi.set(__self__, "privileges_separation", privileges_separation)
        if token_name is not None:
            pulumi.set(__self__, "token_name", token_name)
        if user_id is not None:
            pulumi.set(__self__, "user_id", user_id)
        if value is not None:
            pulumi.set(__self__, "value", value)

    @property
    @pulumi.getter
    def comment(self) -> Optional[pulumi.Input[str]]:
        """
        Comment for the token.
        """
        return pulumi.get(self, "comment")

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

    @property
    @pulumi.getter(name="expirationDate")
    def expiration_date(self) -> Optional[pulumi.Input[str]]:
        """
        Expiration date for the token.
        """
        return pulumi.get(self, "expiration_date")

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

    @property
    @pulumi.getter(name="privilegesSeparation")
    def privileges_separation(self) -> Optional[pulumi.Input[bool]]:
        """
        Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        """
        return pulumi.get(self, "privileges_separation")

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

    @property
    @pulumi.getter(name="tokenName")
    def token_name(self) -> Optional[pulumi.Input[str]]:
        """
        User-specific token identifier.
        """
        return pulumi.get(self, "token_name")

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

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> Optional[pulumi.Input[str]]:
        """
        User identifier.
        """
        return pulumi.get(self, "user_id")

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

    @property
    @pulumi.getter
    def value(self) -> Optional[pulumi.Input[str]]:
        """
        API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
        """
        return pulumi.get(self, "value")

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


class Token(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 comment: Optional[pulumi.Input[str]] = None,
                 expiration_date: Optional[pulumi.Input[str]] = None,
                 privileges_separation: Optional[pulumi.Input[bool]] = None,
                 token_name: Optional[pulumi.Input[str]] = None,
                 user_id: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        User API tokens.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_proxmoxve as proxmoxve

        # if creating a user token, the user must be created first
        user = proxmoxve.permission.User("user",
            comment="Managed by Terraform",
            email="user@pve",
            enabled=True,
            expiration_date="2034-01-01T22:00:00Z",
            user_id="user@pve")
        user_token = proxmoxve.user.Token("userToken",
            comment="Managed by Terraform",
            expiration_date="2033-01-01T22:00:00Z",
            token_name="tk1",
            user_id=user.user_id)
        ```

        ## Import

        #!/usr/bin/env sh

        #Tokens can be imported using they identifiers in format `user_id!token_name` format, e.g.:

        ```sh
        $ pulumi import proxmoxve:User/token:Token token1 user@pve!token1
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] comment: Comment for the token.
        :param pulumi.Input[str] expiration_date: Expiration date for the token.
        :param pulumi.Input[bool] privileges_separation: Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        :param pulumi.Input[str] token_name: User-specific token identifier.
        :param pulumi.Input[str] user_id: User identifier.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: TokenArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        User API tokens.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_proxmoxve as proxmoxve

        # if creating a user token, the user must be created first
        user = proxmoxve.permission.User("user",
            comment="Managed by Terraform",
            email="user@pve",
            enabled=True,
            expiration_date="2034-01-01T22:00:00Z",
            user_id="user@pve")
        user_token = proxmoxve.user.Token("userToken",
            comment="Managed by Terraform",
            expiration_date="2033-01-01T22:00:00Z",
            token_name="tk1",
            user_id=user.user_id)
        ```

        ## Import

        #!/usr/bin/env sh

        #Tokens can be imported using they identifiers in format `user_id!token_name` format, e.g.:

        ```sh
        $ pulumi import proxmoxve:User/token:Token token1 user@pve!token1
        ```

        :param str resource_name: The name of the resource.
        :param TokenArgs 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(TokenArgs, 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,
                 comment: Optional[pulumi.Input[str]] = None,
                 expiration_date: Optional[pulumi.Input[str]] = None,
                 privileges_separation: Optional[pulumi.Input[bool]] = None,
                 token_name: Optional[pulumi.Input[str]] = None,
                 user_id: Optional[pulumi.Input[str]] = 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__ = TokenArgs.__new__(TokenArgs)

            __props__.__dict__["comment"] = comment
            __props__.__dict__["expiration_date"] = expiration_date
            __props__.__dict__["privileges_separation"] = privileges_separation
            if token_name is None and not opts.urn:
                raise TypeError("Missing required property 'token_name'")
            __props__.__dict__["token_name"] = token_name
            if user_id is None and not opts.urn:
                raise TypeError("Missing required property 'user_id'")
            __props__.__dict__["user_id"] = user_id
            __props__.__dict__["value"] = None
        secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["value"])
        opts = pulumi.ResourceOptions.merge(opts, secret_opts)
        super(Token, __self__).__init__(
            'proxmoxve:User/token:Token',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            comment: Optional[pulumi.Input[str]] = None,
            expiration_date: Optional[pulumi.Input[str]] = None,
            privileges_separation: Optional[pulumi.Input[bool]] = None,
            token_name: Optional[pulumi.Input[str]] = None,
            user_id: Optional[pulumi.Input[str]] = None,
            value: Optional[pulumi.Input[str]] = None) -> 'Token':
        """
        Get an existing Token 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] comment: Comment for the token.
        :param pulumi.Input[str] expiration_date: Expiration date for the token.
        :param pulumi.Input[bool] privileges_separation: Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        :param pulumi.Input[str] token_name: User-specific token identifier.
        :param pulumi.Input[str] user_id: User identifier.
        :param pulumi.Input[str] value: API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _TokenState.__new__(_TokenState)

        __props__.__dict__["comment"] = comment
        __props__.__dict__["expiration_date"] = expiration_date
        __props__.__dict__["privileges_separation"] = privileges_separation
        __props__.__dict__["token_name"] = token_name
        __props__.__dict__["user_id"] = user_id
        __props__.__dict__["value"] = value
        return Token(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def comment(self) -> pulumi.Output[Optional[str]]:
        """
        Comment for the token.
        """
        return pulumi.get(self, "comment")

    @property
    @pulumi.getter(name="expirationDate")
    def expiration_date(self) -> pulumi.Output[Optional[str]]:
        """
        Expiration date for the token.
        """
        return pulumi.get(self, "expiration_date")

    @property
    @pulumi.getter(name="privilegesSeparation")
    def privileges_separation(self) -> pulumi.Output[bool]:
        """
        Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
        """
        return pulumi.get(self, "privileges_separation")

    @property
    @pulumi.getter(name="tokenName")
    def token_name(self) -> pulumi.Output[str]:
        """
        User-specific token identifier.
        """
        return pulumi.get(self, "token_name")

    @property
    @pulumi.getter(name="userId")
    def user_id(self) -> pulumi.Output[str]:
        """
        User identifier.
        """
        return pulumi.get(self, "user_id")

    @property
    @pulumi.getter
    def value(self) -> pulumi.Output[str]:
        """
        API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
        """
        return pulumi.get(self, "value")

