Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CryptographyClient initialization snippets
  • Loading branch information
chlowell committed Sep 10, 2019
commit 827410c445d3a9dce7bf7c9131ba4a023ba3ada3
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,43 @@ class CryptographyClient(AsyncKeyVaultClientBase):

:param key:
Either a :class:`~azure.keyvault.keys.models.Key` instance as returned by
:func:`~azure.keyvault.keys.KeyClient.get_key`, or a string.
:func:`~azure.keyvault.keys.aio.KeyClient.get_key`, or a string.
If a string, the value must be the full identifier of an Azure Key Vault key with a version.
:type key: str or :class:`~azure.keyvault.keys.models.Key`
:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity`
:mod:`azure.identity.aio`

Keyword arguments
- *api_version* - version of the Key Vault API to use. Defaults to the most recent.
- **api_version** - version of the Key Vault API to use. Defaults to the most recent.

Creating a ``CryptographyClient``:

.. code-block:: python

from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.keys.crypto.aio import CryptographyClient

credential = DefaultAzureCredential()

# create a CryptographyClient using a Key instance
key = await key_client.get_key("mykey")
crypto_client = CryptographyClient(key, credential)

# or a Key's id, which must include a version
key_id = "https://<your vault>.vault.azure.net/keys/mykey/fe4fdcab688c479a9aa80f01ffeac26"
crypto_client = CryptographyClient(key_id, credential)

You can also obtain a ``CryptographyClient`` from a :class:`~azure.keyvault.keys.aio.KeyClient`:

.. code-block:: python

from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.keys.aio import KeyClient

credential = DefaultAzureCredential()
key_client = KeyClient(vault_url=<your vault url>, credential=credential)
crypto_client = key_client.get_cryptography_client("mykey")

"""

def __init__(self, key: "Union[Key, str]", credential: "TokenCredential", **kwargs: "**Any") -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,36 @@ class CryptographyClient(KeyVaultClientBase):
:mod:`azure.identity`

Keyword arguments
- *api_version* - version of the Key Vault API to use. Defaults to the most recent.
- **api_version** - version of the Key Vault API to use. Defaults to the most recent.

Creating a ``CryptographyClient``:

.. code-block:: python

from azure.identity import DefaultAzureCredential
from azure.keyvault.keys.crypto import CryptographyClient

credential = DefaultAzureCredential()

# create a CryptographyClient using a Key instance
key = key_client.get_key("mykey")
crypto_client = CryptographyClient(key, credential)

# or a Key's id, which must include a version
key_id = "https://<your vault>.vault.azure.net/keys/mykey/fe4fdcab688c479a9aa80f01ffeac26"
crypto_client = CryptographyClient(key_id, credential)

You can also obtain a ``CryptographyClient`` from a :class:`~azure.keyvault.keys.KeyClient`:

.. code-block:: python

from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient

credential = DefaultAzureCredential()
key_client = KeyClient(vault_url=<your vault url>, credential=credential)
crypto_client = key_client.get_cryptography_client("mykey")

"""

def __init__(self, key, credential, **kwargs):
Expand Down