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
Next Next commit
update docstrings
  • Loading branch information
chlowell committed Sep 17, 2019
commit 650c4b9c223de660300dce8a46d6f9174ecfaa07
43 changes: 37 additions & 6 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class KeyClient(AsyncKeyVaultClientBase):
"""A high-level asynchronous interface for managing a vault's keys.

:param str vault_url: URL of the vault the client will access
:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity.aio`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand All @@ -33,6 +33,18 @@ class KeyClient(AsyncKeyVaultClientBase):
# pylint:disable=protected-access

def get_cryptography_client(self, key: Union[Key, str], **kwargs: Any) -> CryptographyClient:
"""
Get a :class:`~azure.keyvault.keys.crypto.aio.CryptographyClient` capable of performing cryptographic operations
with a key.

:param key:
Either a :class:`~azure.keyvault.keys.Key` instance as returned by
: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.Key`
:rtype: :class:`~azure.keyvault.keys.crypto.aio.CryptographyClient`
"""

# the initializer requires a credential but won't actually use it in this case because we pass in this
# KeyClient's generated client, whose pipeline (and auth policy) is fully configured
credential = object()
Expand Down Expand Up @@ -69,6 +81,7 @@ async def create_key(
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -123,6 +136,7 @@ async def create_rsa_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -174,6 +188,7 @@ async def create_ec_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -204,7 +219,9 @@ async def delete_key(self, name: str, **kwargs: "**Any") -> DeletedKey:
:param str name: The name of the key to delete.
:returns: The deleted key
:rtype: ~azure.keyvault.keys.models.DeletedKey
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand All @@ -225,7 +242,9 @@ async def get_key(self, name: str, version: Optional[str] = None, **kwargs: "**A
:param str version: (optional) A specific version of the key to get. If not specified, gets the latest version
of the key.
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand All @@ -251,6 +270,9 @@ async def get_deleted_key(self, name: str, **kwargs: "**Any") -> DeletedKey:
:param str name: The name of the key
:returns: The deleted key
:rtype: ~azure.keyvault.keys.models.DeletedKey
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -346,6 +368,7 @@ async def purge_deleted_key(self, name: str, **kwargs: "**Any") -> None:

:param str name: The name of the key
:returns: None
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. code-block:: python
Expand All @@ -368,6 +391,7 @@ async def recover_deleted_key(self, name: str, **kwargs: "**Any") -> Key:
:param str name: The name of the deleted key
:returns: The recovered key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -405,7 +429,9 @@ async def update_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The updated key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -443,7 +469,9 @@ async def backup_key(self, name: str, **kwargs: "**Any") -> bytes:
:param str name: The name of the key
:returns: The raw bytes of the key backup
:rtype: bytes
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand All @@ -469,7 +497,9 @@ async def restore_key(self, backup: bytes, **kwargs: "**Any") -> Key:
:param bytes backup: The raw bytes of the key backup
:returns: The restored key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceExistsError` if the backed up key's name is already in use
:raises:
:class:`~azure.core.exceptions.ResourceExistsError` if the backed up key's name is already in use,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down Expand Up @@ -507,6 +537,7 @@ async def import_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The imported key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

"""
if enabled is not None or not_before is not None or expires is not None:
Expand Down
42 changes: 36 additions & 6 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
class KeyClient(KeyVaultClientBase):
"""A high-level interface for managing a vault's keys.

:param str vault_url: URL of the vault the client will access
:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand All @@ -41,6 +41,17 @@ class KeyClient(KeyVaultClientBase):

def get_cryptography_client(self, key, **kwargs):
# type: (Union[Key, str], **Any) -> CryptographyClient
"""
Get a :class:`~azure.keyvault.keys.crypto.CryptographyClient` capable of performing cryptographic operations
with a key.

:param key:
Either a :class:`~azure.keyvault.keys.Key` instance as returned by
:func:`~azure.keyvault.keys.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.Key`
:rtype: :class:`~azure.keyvault.keys.crypto.CryptographyClient`
"""

# the initializer requires a credential but won't actually use it in this case because we pass in this
# KeyClient's generated client, whose pipeline (and auth policy) is fully configured
Expand Down Expand Up @@ -79,6 +90,7 @@ def create_key(
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -134,6 +146,7 @@ def create_rsa_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -186,6 +199,7 @@ def create_ec_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -218,7 +232,9 @@ def delete_key(self, name, **kwargs):
:param str name: The name of the key to delete.
:returns: The deleted key
:rtype: ~azure.keyvault.keys.models.DeletedKey
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand All @@ -240,7 +256,9 @@ def get_key(self, name, version=None, **kwargs):
:param str version: (optional) A specific version of the key to get. If not specified, gets the latest version
of the key.
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand All @@ -264,6 +282,9 @@ def get_deleted_key(self, name, **kwargs):
:param str name: The name of the key
:returns: The deleted key
:rtype: ~azure.keyvault.keys.models.DeletedKey
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -362,6 +383,7 @@ def purge_deleted_key(self, name, **kwargs):

:param str name: The name of the key
:returns: None
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. code-block:: python
Expand Down Expand Up @@ -389,6 +411,7 @@ def recover_deleted_key(self, name, **kwargs):
:param str name: The name of the deleted key
:returns: The recovered key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -431,7 +454,9 @@ def update_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The updated key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -469,7 +494,9 @@ def backup_key(self, name, **kwargs):
:param str name: The name of the key
:returns: The raw bytes of the key backup
:rtype: bytes
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the key doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand All @@ -494,7 +521,9 @@ def restore_key(self, backup, **kwargs):
:param bytes backup: The raw bytes of the key backup
:returns: The restored key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.ResourceExistsError` if the backed up key's name is already in use
:raises:
:class:`~azure.core.exceptions.ResourceExistsError` if the backed up key's name is already in use,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_keys.py
Expand Down Expand Up @@ -533,6 +562,7 @@ def import_key(
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:returns: The imported key
:rtype: ~azure.keyvault.keys.models.Key
:raises: :class:`~azure.core.exceptions.HttpResponseError`

"""
if enabled is not None or not_before is not None or expires is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
class SecretClient(AsyncKeyVaultClientBase):
"""A high-level asynchronous interface for managing a vault's secrets.

:param str vault_url: URL of the vault the client will access
:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity.aio`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand All @@ -38,7 +38,9 @@ async def get_secret(self, name: str, version: Optional[str] = None, **kwargs: "
:param str name: The name of the secret
:param str version: (optional) Version of the secret to get. If unspecified, gets the latest version.
:rtype: ~azure.keyvault.secrets.models.Secret
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down Expand Up @@ -76,6 +78,7 @@ async def set_secret(
:param datetime.datetime expires: (optional) Expiry date of the secret in UTC
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:rtype: ~azure.keyvault.secrets.models.Secret
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down Expand Up @@ -118,7 +121,9 @@ async def update_secret(
:param datetime.datetime expires: (optional) Expiry date of the secret in UTC.
:param dict(str, str) tags: (optional) Application specific metadata in the form of key-value pairs.
:rtype: ~azure.keyvault.secrets.models.SecretAttributes
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down Expand Up @@ -201,7 +206,9 @@ async def backup_secret(self, name: str, **kwargs: "**Any") -> bytes:
:param str name: Name of the secret
:returns: The raw bytes of the secret backup
:rtype: bytes
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand All @@ -223,7 +230,9 @@ async def restore_secret(self, backup: bytes, **kwargs: "**Any") -> SecretAttrib
:param bytes backup: The raw bytes of the secret backup
:returns: The restored secret
:rtype: ~azure.keyvault.secrets.models.SecretAttributes
:raises: :class:`~azure.core.exceptions.ResourceExistsError` if the secret's name is already in use
:raises:
:class:`~azure.core.exceptions.ResourceExistsError` if the secret's name is already in use,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand All @@ -244,7 +253,9 @@ async def delete_secret(self, name: str, **kwargs: "**Any") -> DeletedSecret:

:param str name: Name of the secret
:rtype: ~azure.keyvault.secrets.models.DeletedSecret
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the secret doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand All @@ -266,7 +277,9 @@ async def get_deleted_secret(self, name: str, **kwargs: "**Any") -> DeletedSecre

:param str name: Name of the secret
:rtype: ~azure.keyvault.secrets.models.DeletedSecret
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError` if the deleted secret doesn't exist
:raises:
:class:`~azure.core.exceptions.ResourceNotFoundError` if the deleted secret doesn't exist,
:class:`~azure.core.exceptions.HttpResponseError` for other errors

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down Expand Up @@ -314,6 +327,7 @@ async def purge_deleted_secret(self, name: str, **kwargs: "**Any") -> None:

:param str name: Name of the secret
:returns: None
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. code-block:: python
Expand All @@ -333,6 +347,7 @@ async def recover_deleted_secret(self, name: str, **kwargs: "**Any") -> SecretAt
:param str name: Name of the secret
:returns: The recovered secret
:rtype: ~azure.keyvault.secrets.models.SecretAttributes
:raises: :class:`~azure.core.exceptions.HttpResponseError`

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down
Loading