# 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
from . import outputs

__all__ = [
    'GetKeyResult',
    'AwaitableGetKeyResult',
    'get_key',
    'get_key_output',
]

@pulumi.output_type
class GetKeyResult:
    """
    A collection of values returned by getKey.
    """
    def __init__(__self__, algorithm=None, created_at=None, description=None, id=None, key_id=None, locked=None, name=None, origin=None, project_id=None, protected=None, region=None, rotated_at=None, rotation_count=None, rotation_policies=None, state=None, tags=None, unprotected=None, updated_at=None, usage=None):
        if algorithm and not isinstance(algorithm, str):
            raise TypeError("Expected argument 'algorithm' to be a str")
        pulumi.set(__self__, "algorithm", algorithm)
        if created_at and not isinstance(created_at, str):
            raise TypeError("Expected argument 'created_at' to be a str")
        pulumi.set(__self__, "created_at", created_at)
        if description and not isinstance(description, str):
            raise TypeError("Expected argument 'description' to be a str")
        pulumi.set(__self__, "description", description)
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if key_id and not isinstance(key_id, str):
            raise TypeError("Expected argument 'key_id' to be a str")
        pulumi.set(__self__, "key_id", key_id)
        if locked and not isinstance(locked, bool):
            raise TypeError("Expected argument 'locked' to be a bool")
        pulumi.set(__self__, "locked", locked)
        if name and not isinstance(name, str):
            raise TypeError("Expected argument 'name' to be a str")
        pulumi.set(__self__, "name", name)
        if origin and not isinstance(origin, str):
            raise TypeError("Expected argument 'origin' to be a str")
        pulumi.set(__self__, "origin", origin)
        if project_id and not isinstance(project_id, str):
            raise TypeError("Expected argument 'project_id' to be a str")
        pulumi.set(__self__, "project_id", project_id)
        if protected and not isinstance(protected, bool):
            raise TypeError("Expected argument 'protected' to be a bool")
        pulumi.set(__self__, "protected", protected)
        if region and not isinstance(region, str):
            raise TypeError("Expected argument 'region' to be a str")
        pulumi.set(__self__, "region", region)
        if rotated_at and not isinstance(rotated_at, str):
            raise TypeError("Expected argument 'rotated_at' to be a str")
        pulumi.set(__self__, "rotated_at", rotated_at)
        if rotation_count and not isinstance(rotation_count, int):
            raise TypeError("Expected argument 'rotation_count' to be a int")
        pulumi.set(__self__, "rotation_count", rotation_count)
        if rotation_policies and not isinstance(rotation_policies, list):
            raise TypeError("Expected argument 'rotation_policies' to be a list")
        pulumi.set(__self__, "rotation_policies", rotation_policies)
        if state and not isinstance(state, str):
            raise TypeError("Expected argument 'state' to be a str")
        pulumi.set(__self__, "state", state)
        if tags and not isinstance(tags, list):
            raise TypeError("Expected argument 'tags' to be a list")
        pulumi.set(__self__, "tags", tags)
        if unprotected and not isinstance(unprotected, bool):
            raise TypeError("Expected argument 'unprotected' to be a bool")
        pulumi.set(__self__, "unprotected", unprotected)
        if updated_at and not isinstance(updated_at, str):
            raise TypeError("Expected argument 'updated_at' to be a str")
        pulumi.set(__self__, "updated_at", updated_at)
        if usage and not isinstance(usage, str):
            raise TypeError("Expected argument 'usage' to be a str")
        pulumi.set(__self__, "usage", usage)

    @_builtins.property
    @pulumi.getter
    def algorithm(self) -> _builtins.str:
        return pulumi.get(self, "algorithm")

    @_builtins.property
    @pulumi.getter(name="createdAt")
    def created_at(self) -> _builtins.str:
        return pulumi.get(self, "created_at")

    @_builtins.property
    @pulumi.getter
    def description(self) -> _builtins.str:
        return pulumi.get(self, "description")

    @_builtins.property
    @pulumi.getter
    def id(self) -> _builtins.str:
        return pulumi.get(self, "id")

    @_builtins.property
    @pulumi.getter(name="keyId")
    def key_id(self) -> _builtins.str:
        return pulumi.get(self, "key_id")

    @_builtins.property
    @pulumi.getter
    def locked(self) -> _builtins.bool:
        return pulumi.get(self, "locked")

    @_builtins.property
    @pulumi.getter
    def name(self) -> _builtins.str:
        return pulumi.get(self, "name")

    @_builtins.property
    @pulumi.getter
    def origin(self) -> _builtins.str:
        return pulumi.get(self, "origin")

    @_builtins.property
    @pulumi.getter(name="projectId")
    def project_id(self) -> _builtins.str:
        return pulumi.get(self, "project_id")

    @_builtins.property
    @pulumi.getter
    def protected(self) -> _builtins.bool:
        return pulumi.get(self, "protected")

    @_builtins.property
    @pulumi.getter
    def region(self) -> Optional[_builtins.str]:
        return pulumi.get(self, "region")

    @_builtins.property
    @pulumi.getter(name="rotatedAt")
    def rotated_at(self) -> _builtins.str:
        return pulumi.get(self, "rotated_at")

    @_builtins.property
    @pulumi.getter(name="rotationCount")
    def rotation_count(self) -> _builtins.int:
        return pulumi.get(self, "rotation_count")

    @_builtins.property
    @pulumi.getter(name="rotationPolicies")
    def rotation_policies(self) -> Sequence['outputs.GetKeyRotationPolicyResult']:
        return pulumi.get(self, "rotation_policies")

    @_builtins.property
    @pulumi.getter
    def state(self) -> _builtins.str:
        return pulumi.get(self, "state")

    @_builtins.property
    @pulumi.getter
    def tags(self) -> Sequence[_builtins.str]:
        return pulumi.get(self, "tags")

    @_builtins.property
    @pulumi.getter
    def unprotected(self) -> _builtins.bool:
        return pulumi.get(self, "unprotected")

    @_builtins.property
    @pulumi.getter(name="updatedAt")
    def updated_at(self) -> _builtins.str:
        return pulumi.get(self, "updated_at")

    @_builtins.property
    @pulumi.getter
    def usage(self) -> _builtins.str:
        return pulumi.get(self, "usage")


class AwaitableGetKeyResult(GetKeyResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetKeyResult(
            algorithm=self.algorithm,
            created_at=self.created_at,
            description=self.description,
            id=self.id,
            key_id=self.key_id,
            locked=self.locked,
            name=self.name,
            origin=self.origin,
            project_id=self.project_id,
            protected=self.protected,
            region=self.region,
            rotated_at=self.rotated_at,
            rotation_count=self.rotation_count,
            rotation_policies=self.rotation_policies,
            state=self.state,
            tags=self.tags,
            unprotected=self.unprotected,
            updated_at=self.updated_at,
            usage=self.usage)


def get_key(key_id: Optional[_builtins.str] = None,
            region: Optional[_builtins.str] = None,
            opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetKeyResult:
    """
    Gets information about a Key Manager Key. For more information, refer to the [Key Manager API documentation](https://www.scaleway.com/en/developers/api/key-manager/#path-keys-get-key-metadata).

    ## Example Usage

    ### Create a key and get its information

    The following commands allow you to:

    - create a key named `my-kms-key`
    - retrieve the key's information using the key's ID

    ```python
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway

    # Create a key
    symmetric = scaleway.keymanager.Key("symmetric",
        name="my-kms-key",
        region="fr-par",
        project_id="your-project-id",
        usage="symmetric_encryption",
        algorithm="aes_256_gcm",
        description="Key for encrypting secrets",
        tags=[
            "env:prod",
            "kms",
        ],
        unprotected=True,
        rotation_policy={
            "rotation_period": "720h",
        })
    # Get the key information by its ID
    by_id = scaleway.keymanager.get_key(key_id="11111111-1111-1111-1111-111111111111")
    ```


    :param _builtins.str key_id: ID of the key to target. Can be a plain UUID or a regional ID.
    :param _builtins.str region: `region`) The region in which the key was created.
    """
    __args__ = dict()
    __args__['keyId'] = key_id
    __args__['region'] = region
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('scaleway:keymanager/getKey:getKey', __args__, opts=opts, typ=GetKeyResult).value

    return AwaitableGetKeyResult(
        algorithm=pulumi.get(__ret__, 'algorithm'),
        created_at=pulumi.get(__ret__, 'created_at'),
        description=pulumi.get(__ret__, 'description'),
        id=pulumi.get(__ret__, 'id'),
        key_id=pulumi.get(__ret__, 'key_id'),
        locked=pulumi.get(__ret__, 'locked'),
        name=pulumi.get(__ret__, 'name'),
        origin=pulumi.get(__ret__, 'origin'),
        project_id=pulumi.get(__ret__, 'project_id'),
        protected=pulumi.get(__ret__, 'protected'),
        region=pulumi.get(__ret__, 'region'),
        rotated_at=pulumi.get(__ret__, 'rotated_at'),
        rotation_count=pulumi.get(__ret__, 'rotation_count'),
        rotation_policies=pulumi.get(__ret__, 'rotation_policies'),
        state=pulumi.get(__ret__, 'state'),
        tags=pulumi.get(__ret__, 'tags'),
        unprotected=pulumi.get(__ret__, 'unprotected'),
        updated_at=pulumi.get(__ret__, 'updated_at'),
        usage=pulumi.get(__ret__, 'usage'))
def get_key_output(key_id: Optional[pulumi.Input[_builtins.str]] = None,
                   region: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                   opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetKeyResult]:
    """
    Gets information about a Key Manager Key. For more information, refer to the [Key Manager API documentation](https://www.scaleway.com/en/developers/api/key-manager/#path-keys-get-key-metadata).

    ## Example Usage

    ### Create a key and get its information

    The following commands allow you to:

    - create a key named `my-kms-key`
    - retrieve the key's information using the key's ID

    ```python
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway

    # Create a key
    symmetric = scaleway.keymanager.Key("symmetric",
        name="my-kms-key",
        region="fr-par",
        project_id="your-project-id",
        usage="symmetric_encryption",
        algorithm="aes_256_gcm",
        description="Key for encrypting secrets",
        tags=[
            "env:prod",
            "kms",
        ],
        unprotected=True,
        rotation_policy={
            "rotation_period": "720h",
        })
    # Get the key information by its ID
    by_id = scaleway.keymanager.get_key(key_id="11111111-1111-1111-1111-111111111111")
    ```


    :param _builtins.str key_id: ID of the key to target. Can be a plain UUID or a regional ID.
    :param _builtins.str region: `region`) The region in which the key was created.
    """
    __args__ = dict()
    __args__['keyId'] = key_id
    __args__['region'] = region
    opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('scaleway:keymanager/getKey:getKey', __args__, opts=opts, typ=GetKeyResult)
    return __ret__.apply(lambda __response__: GetKeyResult(
        algorithm=pulumi.get(__response__, 'algorithm'),
        created_at=pulumi.get(__response__, 'created_at'),
        description=pulumi.get(__response__, 'description'),
        id=pulumi.get(__response__, 'id'),
        key_id=pulumi.get(__response__, 'key_id'),
        locked=pulumi.get(__response__, 'locked'),
        name=pulumi.get(__response__, 'name'),
        origin=pulumi.get(__response__, 'origin'),
        project_id=pulumi.get(__response__, 'project_id'),
        protected=pulumi.get(__response__, 'protected'),
        region=pulumi.get(__response__, 'region'),
        rotated_at=pulumi.get(__response__, 'rotated_at'),
        rotation_count=pulumi.get(__response__, 'rotation_count'),
        rotation_policies=pulumi.get(__response__, 'rotation_policies'),
        state=pulumi.get(__response__, 'state'),
        tags=pulumi.get(__response__, 'tags'),
        unprotected=pulumi.get(__response__, 'unprotected'),
        updated_at=pulumi.get(__response__, 'updated_at'),
        usage=pulumi.get(__response__, 'usage')))
