diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/client.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/client.py index df5ab425f833..501337603ea4 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/client.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/client.py @@ -11,7 +11,7 @@ from azure.core.tracing.decorator import distributed_trace from ._shared import KeyVaultClientBase -from ._shared.exceptions import error_map +from ._shared.exceptions import error_map as _error_map from .models import ( Certificate, CertificateProperties, @@ -138,7 +138,7 @@ def get_certificate_with_policy(self, name, **kwargs): :dedent: 8 """ bundle = self._client.get_certificate( - vault_base_url=self.vault_url, certificate_name=name, certificate_version="", error_map=error_map, **kwargs + vault_base_url=self.vault_url, certificate_name=name, certificate_version="", error_map=_error_map, **kwargs ) return Certificate._from_certificate_bundle(certificate_bundle=bundle) @@ -170,7 +170,7 @@ def get_certificate(self, name, version, **kwargs): vault_base_url=self.vault_url, certificate_name=name, certificate_version=version, - error_map=error_map, + error_map=_error_map, **kwargs ) return Certificate._from_certificate_bundle(certificate_bundle=bundle) @@ -201,7 +201,7 @@ def delete_certificate(self, name, **kwargs): :dedent: 8 """ bundle = self._client.delete_certificate( - vault_base_url=self.vault_url, certificate_name=name, error_map=error_map, **kwargs + vault_base_url=self.vault_url, certificate_name=name, error_map=_error_map, **kwargs ) return DeletedCertificate._from_deleted_certificate_bundle(deleted_certificate_bundle=bundle) @@ -231,7 +231,7 @@ def get_deleted_certificate(self, name, **kwargs): :dedent: 8 """ bundle = self._client.get_deleted_certificate( - vault_base_url=self.vault_url, certificate_name=name, error_map=error_map, **kwargs + vault_base_url=self.vault_url, certificate_name=name, error_map=_error_map, **kwargs ) return DeletedCertificate._from_deleted_certificate_bundle(deleted_certificate_bundle=bundle) @@ -447,7 +447,7 @@ def backup_certificate(self, name, **kwargs): :dedent: 8 """ backup_result = self._client.backup_certificate( - vault_base_url=self.vault_url, certificate_name=name, error_map=error_map, **kwargs + vault_base_url=self.vault_url, certificate_name=name, error_map=_error_map, **kwargs ) return backup_result.value @@ -670,7 +670,7 @@ def get_certificate_operation(self, name, **kwargs): """ bundle = self._client.get_certificate_operation( - vault_base_url=self.vault_url, certificate_name=name, error_map=error_map, **kwargs + vault_base_url=self.vault_url, certificate_name=name, error_map=_error_map, **kwargs ) return CertificateOperation._from_certificate_operation_bundle(certificate_operation_bundle=bundle) @@ -796,7 +796,7 @@ def get_pending_certificate_signing_request( response = pipeline_response.http_response if response.status_code not in [200]: - self._client.map_error(status_code=response.status_code, response=response, error_map=error_map) + self._client.map_error(status_code=response.status_code, response=response, error_map=_error_map) raise self._client.models.KeyVaultErrorException(response, self._client._deserialize) deserialized = None @@ -830,7 +830,7 @@ def get_issuer(self, name, **kwargs): :dedent: 8 """ issuer_bundle = self._client.get_certificate_issuer( - vault_base_url=self.vault_url, issuer_name=name, error_map=error_map, **kwargs + vault_base_url=self.vault_url, issuer_name=name, error_map=_error_map, **kwargs ) return Issuer._from_issuer_bundle(issuer_bundle=issuer_bundle) diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/client.py index b7a146027c11..ce9bfd3f8762 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/client.py @@ -10,7 +10,7 @@ from azure.keyvault.keys.models import DeletedKey, JsonWebKey, Key, KeyProperties from azure.keyvault.keys._shared import AsyncKeyVaultClientBase -from .._shared.exceptions import error_map +from .._shared.exceptions import error_map as _error_map from ..crypto.aio import CryptographyClient @@ -231,7 +231,7 @@ async def delete_key(self, name: str, **kwargs: "**Any") -> DeletedKey: :caption: Delete a key :dedent: 8 """ - bundle = await self._client.delete_key(self.vault_url, name, error_map=error_map, **kwargs) + bundle = await self._client.delete_key(self.vault_url, name, _error_map=_error_map, **kwargs) return DeletedKey._from_deleted_key_bundle(bundle) @distributed_trace_async @@ -257,7 +257,7 @@ async def get_key(self, name: str, version: Optional[str] = None, **kwargs: "**A if version is None: version = "" - bundle = await self._client.get_key(self.vault_url, name, version, error_map=error_map, **kwargs) + bundle = await self._client.get_key(self.vault_url, name, version, _error_map=_error_map, **kwargs) return Key._from_key_bundle(bundle) @distributed_trace_async @@ -280,7 +280,7 @@ async def get_deleted_key(self, name: str, **kwargs: "**Any") -> DeletedKey: :caption: Get a deleted key :dedent: 8 """ - bundle = await self._client.get_deleted_key(self.vault_url, name, error_map=error_map, **kwargs) + bundle = await self._client.get_deleted_key(self.vault_url, name, _error_map=_error_map, **kwargs) return DeletedKey._from_deleted_key_bundle(bundle) @distributed_trace @@ -449,7 +449,7 @@ async def update_key_properties( key_ops=key_operations, tags=tags, key_attributes=attributes, - error_map=error_map, + _error_map=_error_map, **kwargs, ) return Key._from_key_bundle(bundle) @@ -477,7 +477,7 @@ async def backup_key(self, name: str, **kwargs: "**Any") -> bytes: :caption: Get a key backup :dedent: 8 """ - backup_result = await self._client.backup_key(self.vault_url, name, error_map=error_map, **kwargs) + backup_result = await self._client.backup_key(self.vault_url, name, _error_map=_error_map, **kwargs) return backup_result.value @distributed_trace_async @@ -503,7 +503,7 @@ async def restore_key(self, backup: bytes, **kwargs: "**Any") -> Key: :caption: Restore a key backup :dedent: 8 """ - bundle = await self._client.restore_key(self.vault_url, backup, error_map=error_map, **kwargs) + bundle = await self._client.restore_key(self.vault_url, backup, _error_map=_error_map, **kwargs) return Key._from_key_bundle(bundle) @distributed_trace_async diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py index c14f9b1b5d2f..44b374531ab0 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py @@ -5,7 +5,7 @@ from azure.core.tracing.decorator import distributed_trace from ._shared import KeyVaultClientBase -from ._shared.exceptions import error_map +from ._shared.exceptions import error_map as _error_map from .crypto import CryptographyClient from .models import Key, KeyProperties, DeletedKey @@ -245,7 +245,7 @@ def delete_key(self, name, **kwargs): :caption: Delete a key :dedent: 8 """ - bundle = self._client.delete_key(self.vault_url, name, error_map=error_map, **kwargs) + bundle = self._client.delete_key(self.vault_url, name, error_map=_error_map, **kwargs) return DeletedKey._from_deleted_key_bundle(bundle) @distributed_trace @@ -269,7 +269,7 @@ def get_key(self, name, version=None, **kwargs): :caption: Get a key :dedent: 8 """ - bundle = self._client.get_key(self.vault_url, name, key_version=version or "", error_map=error_map, **kwargs) + bundle = self._client.get_key(self.vault_url, name, key_version=version or "", error_map=_error_map, **kwargs) return Key._from_key_bundle(bundle) @distributed_trace @@ -294,7 +294,7 @@ def get_deleted_key(self, name, **kwargs): :dedent: 8 """ # TODO: which exception is raised when soft-delete is not enabled - bundle = self._client.get_deleted_key(self.vault_url, name, error_map=error_map, **kwargs) + bundle = self._client.get_deleted_key(self.vault_url, name, error_map=_error_map, **kwargs) return DeletedKey._from_deleted_key_bundle(bundle) @distributed_trace @@ -468,7 +468,7 @@ def update_key_properties( key_ops=key_operations, tags=tags, key_attributes=attributes, - error_map=error_map, + error_map=_error_map, **kwargs ) return Key._from_key_bundle(bundle) @@ -497,7 +497,7 @@ def backup_key(self, name, **kwargs): :caption: Get a key backup :dedent: 8 """ - backup_result = self._client.backup_key(self.vault_url, name, error_map=error_map, **kwargs) + backup_result = self._client.backup_key(self.vault_url, name, error_map=_error_map, **kwargs) return backup_result.value @distributed_trace @@ -524,7 +524,7 @@ def restore_key(self, backup, **kwargs): :caption: Restore a key backup :dedent: 8 """ - bundle = self._client.restore_key(self.vault_url, backup, error_map=error_map, **kwargs) + bundle = self._client.restore_key(self.vault_url, backup, error_map=_error_map, **kwargs) return Key._from_key_bundle(bundle) @distributed_trace diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/client.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/client.py index fc1e465cfde9..5be9f2535ba8 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/client.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/client.py @@ -5,12 +5,12 @@ from datetime import datetime from typing import Any, AsyncIterable, Optional, Dict -from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.keyvault.secrets.models import Secret, DeletedSecret, SecretProperties from .._shared import AsyncKeyVaultClientBase +from .._shared.exceptions import error_map as _error_map class SecretClient(AsyncKeyVaultClientBase): @@ -51,7 +51,7 @@ async def get_secret(self, name: str, version: Optional[str] = None, **kwargs: " :dedent: 8 """ bundle = await self._client.get_secret( - self.vault_url, name, version or "", error_map={404: ResourceNotFoundError}, **kwargs + self.vault_url, name, version or "", error_map=_error_map, **kwargs ) return Secret._from_secret_bundle(bundle) @@ -144,7 +144,7 @@ async def update_secret_properties( content_type=content_type, tags=tags, secret_attributes=attributes, - error_map={404: ResourceNotFoundError}, + error_map=_error_map, **kwargs ) return SecretProperties._from_secret_bundle(bundle) # pylint: disable=protected-access @@ -219,7 +219,7 @@ async def backup_secret(self, name: str, **kwargs: "**Any") -> bytes: :dedent: 8 """ backup_result = await self._client.backup_secret( - self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs + self.vault_url, name, error_map=_error_map, **kwargs ) return backup_result.value @@ -243,7 +243,7 @@ async def restore_secret(self, backup: bytes, **kwargs: "**Any") -> SecretProper :dedent: 8 """ bundle = await self._client.restore_secret( - self.vault_url, backup, error_map={409: ResourceExistsError}, **kwargs + self.vault_url, backup, error_map=_error_map, **kwargs ) return SecretProperties._from_secret_bundle(bundle) @@ -266,7 +266,7 @@ async def delete_secret(self, name: str, **kwargs: "**Any") -> DeletedSecret: :dedent: 8 """ bundle = await self._client.delete_secret( - self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs + self.vault_url, name, error_map=_error_map, **kwargs ) return DeletedSecret._from_deleted_secret_bundle(bundle) @@ -290,7 +290,7 @@ async def get_deleted_secret(self, name: str, **kwargs: "**Any") -> DeletedSecre :dedent: 8 """ bundle = await self._client.get_deleted_secret( - self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs + self.vault_url, name, error_map=_error_map, **kwargs ) return DeletedSecret._from_deleted_secret_bundle(bundle) diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/client.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/client.py index 54706838282e..05abe82d53cb 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/client.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/client.py @@ -2,10 +2,10 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError from azure.core.tracing.decorator import distributed_trace from ._shared import KeyVaultClientBase +from ._shared.exceptions import error_map as _error_map from .models import Secret, DeletedSecret, SecretProperties try: @@ -62,7 +62,7 @@ def get_secret(self, name, version=None, **kwargs): vault_base_url=self._vault_url, secret_name=name, secret_version=version or "", - error_map={404: ResourceNotFoundError}, + error_map=_error_map, **kwargs ) return Secret._from_secret_bundle(bundle) @@ -166,7 +166,7 @@ def update_secret_properties( content_type=content_type, tags=tags, secret_attributes=attributes, - error_map={404: ResourceNotFoundError}, + error_map=_error_map, **kwargs ) return SecretProperties._from_secret_bundle(bundle) # pylint: disable=protected-access @@ -247,7 +247,7 @@ def backup_secret(self, name, **kwargs): """ backup_result = self._client.backup_secret( - self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs + self.vault_url, name, error_map=_error_map, **kwargs ) return backup_result.value @@ -272,7 +272,7 @@ def restore_secret(self, backup, **kwargs): :dedent: 8 """ - bundle = self._client.restore_secret(self.vault_url, backup, error_map={409: ResourceExistsError}, **kwargs) + bundle = self._client.restore_secret(self.vault_url, backup, error_map=_error_map, **kwargs) return SecretProperties._from_secret_bundle(bundle) @distributed_trace @@ -295,7 +295,7 @@ def delete_secret(self, name, **kwargs): :dedent: 8 """ - bundle = self._client.delete_secret(self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs) + bundle = self._client.delete_secret(self.vault_url, name, error_map=_error_map, **kwargs) return DeletedSecret._from_deleted_secret_bundle(bundle) @distributed_trace @@ -319,7 +319,7 @@ def get_deleted_secret(self, name, **kwargs): :dedent: 8 """ - bundle = self._client.get_deleted_secret(self.vault_url, name, error_map={404: ResourceNotFoundError}, **kwargs) + bundle = self._client.get_deleted_secret(self.vault_url, name, error_map=_error_map, **kwargs) return DeletedSecret._from_deleted_secret_bundle(bundle) @distributed_trace