# 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__ = [
    'GetBackendKeyResult',
    'AwaitableGetBackendKeyResult',
    'get_backend_key',
    'get_backend_key_output',
]

@pulumi.output_type
class GetBackendKeyResult:
    """
    A collection of values returned by getBackendKey.
    """
    def __init__(__self__, backend=None, id=None, key_id=None, key_name=None, key_ref=None, key_type=None, namespace=None):
        if backend and not isinstance(backend, str):
            raise TypeError("Expected argument 'backend' to be a str")
        pulumi.set(__self__, "backend", backend)
        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 key_name and not isinstance(key_name, str):
            raise TypeError("Expected argument 'key_name' to be a str")
        pulumi.set(__self__, "key_name", key_name)
        if key_ref and not isinstance(key_ref, str):
            raise TypeError("Expected argument 'key_ref' to be a str")
        pulumi.set(__self__, "key_ref", key_ref)
        if key_type and not isinstance(key_type, str):
            raise TypeError("Expected argument 'key_type' to be a str")
        pulumi.set(__self__, "key_type", key_type)
        if namespace and not isinstance(namespace, str):
            raise TypeError("Expected argument 'namespace' to be a str")
        pulumi.set(__self__, "namespace", namespace)

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

    @_builtins.property
    @pulumi.getter
    def id(self) -> _builtins.str:
        """
        The provider-assigned unique ID for this managed resource.
        """
        return pulumi.get(self, "id")

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

    @_builtins.property
    @pulumi.getter(name="keyName")
    def key_name(self) -> _builtins.str:
        """
        Name of the key.
        """
        return pulumi.get(self, "key_name")

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

    @_builtins.property
    @pulumi.getter(name="keyType")
    def key_type(self) -> _builtins.str:
        """
        Type of the key.
        """
        return pulumi.get(self, "key_type")

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


class AwaitableGetBackendKeyResult(GetBackendKeyResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetBackendKeyResult(
            backend=self.backend,
            id=self.id,
            key_id=self.key_id,
            key_name=self.key_name,
            key_ref=self.key_ref,
            key_type=self.key_type,
            namespace=self.namespace)


def get_backend_key(backend: Optional[_builtins.str] = None,
                    key_ref: Optional[_builtins.str] = None,
                    namespace: Optional[_builtins.str] = None,
                    opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetBackendKeyResult:
    """
    Reads key data from Vault.

    > **Important** All data retrieved from Vault will be
    written in cleartext to state file generated by Terraform, will appear in
    the console output when Terraform runs, and may be included in plan files
    if secrets are interpolated into any resource attributes.
    Protect these artifacts accordingly. See
    the main provider documentation
    for more details.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_vault as vault

    pki = vault.Mount("pki",
        path="pki",
        type="pki",
        description="PKI secret engine mount")
    key = vault.pkisecret.SecretBackendKey("key",
        backend=pki.path,
        type="internal",
        key_name="example",
        key_type="rsa",
        key_bits=4096)
    example = key.key_id.apply(lambda key_id: vault.pkiSecret.get_backend_key_output(backend=key_vault_mount["path"],
        key_ref=key_id))
    ```


    :param _builtins.str backend: The path to the PKI secret backend to
           read the key from, with no leading or trailing `/`s.
    :param _builtins.str key_ref: Reference to an existing key.
    :param _builtins.str namespace: The namespace of the target resource.
           The value should not contain leading or trailing forward slashes.
           The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
           *Available only for Vault Enterprise*.
    """
    __args__ = dict()
    __args__['backend'] = backend
    __args__['keyRef'] = key_ref
    __args__['namespace'] = namespace
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('vault:pkiSecret/getBackendKey:getBackendKey', __args__, opts=opts, typ=GetBackendKeyResult).value

    return AwaitableGetBackendKeyResult(
        backend=pulumi.get(__ret__, 'backend'),
        id=pulumi.get(__ret__, 'id'),
        key_id=pulumi.get(__ret__, 'key_id'),
        key_name=pulumi.get(__ret__, 'key_name'),
        key_ref=pulumi.get(__ret__, 'key_ref'),
        key_type=pulumi.get(__ret__, 'key_type'),
        namespace=pulumi.get(__ret__, 'namespace'))
def get_backend_key_output(backend: Optional[pulumi.Input[_builtins.str]] = None,
                           key_ref: Optional[pulumi.Input[_builtins.str]] = None,
                           namespace: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                           opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetBackendKeyResult]:
    """
    Reads key data from Vault.

    > **Important** All data retrieved from Vault will be
    written in cleartext to state file generated by Terraform, will appear in
    the console output when Terraform runs, and may be included in plan files
    if secrets are interpolated into any resource attributes.
    Protect these artifacts accordingly. See
    the main provider documentation
    for more details.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_vault as vault

    pki = vault.Mount("pki",
        path="pki",
        type="pki",
        description="PKI secret engine mount")
    key = vault.pkisecret.SecretBackendKey("key",
        backend=pki.path,
        type="internal",
        key_name="example",
        key_type="rsa",
        key_bits=4096)
    example = key.key_id.apply(lambda key_id: vault.pkiSecret.get_backend_key_output(backend=key_vault_mount["path"],
        key_ref=key_id))
    ```


    :param _builtins.str backend: The path to the PKI secret backend to
           read the key from, with no leading or trailing `/`s.
    :param _builtins.str key_ref: Reference to an existing key.
    :param _builtins.str namespace: The namespace of the target resource.
           The value should not contain leading or trailing forward slashes.
           The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
           *Available only for Vault Enterprise*.
    """
    __args__ = dict()
    __args__['backend'] = backend
    __args__['keyRef'] = key_ref
    __args__['namespace'] = namespace
    opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('vault:pkiSecret/getBackendKey:getBackendKey', __args__, opts=opts, typ=GetBackendKeyResult)
    return __ret__.apply(lambda __response__: GetBackendKeyResult(
        backend=pulumi.get(__response__, 'backend'),
        id=pulumi.get(__response__, 'id'),
        key_id=pulumi.get(__response__, 'key_id'),
        key_name=pulumi.get(__response__, 'key_name'),
        key_ref=pulumi.get(__response__, 'key_ref'),
        key_type=pulumi.get(__response__, 'key_type'),
        namespace=pulumi.get(__response__, 'namespace')))
