From 65ec970e2b4425b7f9789eed7f63bef94b49d399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?McCoy=20Pati=C3=B1o?= Date: Fri, 20 Aug 2021 16:31:39 -0700 Subject: [PATCH 1/2] Get default API version from sync --- .../azure/keyvault/certificates/_shared/async_client_base.py | 5 +---- .../azure/keyvault/certificates/_shared/client_base.py | 3 +-- .../azure/keyvault/keys/_shared/async_client_base.py | 5 +---- .../azure/keyvault/keys/_shared/client_base.py | 3 +-- .../azure/keyvault/secrets/_shared/async_client_base.py | 5 +---- .../azure/keyvault/secrets/_shared/client_base.py | 3 +-- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/async_client_base.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/async_client_base.py index 8868c4ea82d5..5e638d4ead62 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/async_client_base.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/async_client_base.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from azure.core.pipeline.policies import HttpLoggingPolicy from . import AsyncChallengeAuthPolicy -from .client_base import ApiVersion +from .client_base import ApiVersion, DEFAULT_VERSION from .._sdk_moniker import SDK_MONIKER from .._generated.aio import KeyVaultClient as _KeyVaultClient @@ -13,14 +13,11 @@ try: # pylint:disable=unused-import from typing import Any - from azure.core.configuration import Configuration - from azure.core.pipeline.transport import AsyncHttpTransport from azure.core.credentials_async import AsyncTokenCredential except ImportError: # AsyncTokenCredential is a typing_extensions.Protocol; we don't depend on that package pass -DEFAULT_VERSION = ApiVersion.V7_3_PREVIEW class AsyncKeyVaultClientBase(object): def __init__(self, vault_url: str, credential: "AsyncTokenCredential", **kwargs: "Any") -> None: diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py index 147af8e22dfd..2cfe70f2ec04 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py @@ -16,8 +16,7 @@ # pylint:disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpTransport - from azure.core.configuration import Configuration + class ApiVersion(str, Enum): """Key Vault API versions supported by this package""" diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/async_client_base.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/async_client_base.py index 8868c4ea82d5..5e638d4ead62 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/async_client_base.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/async_client_base.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from azure.core.pipeline.policies import HttpLoggingPolicy from . import AsyncChallengeAuthPolicy -from .client_base import ApiVersion +from .client_base import ApiVersion, DEFAULT_VERSION from .._sdk_moniker import SDK_MONIKER from .._generated.aio import KeyVaultClient as _KeyVaultClient @@ -13,14 +13,11 @@ try: # pylint:disable=unused-import from typing import Any - from azure.core.configuration import Configuration - from azure.core.pipeline.transport import AsyncHttpTransport from azure.core.credentials_async import AsyncTokenCredential except ImportError: # AsyncTokenCredential is a typing_extensions.Protocol; we don't depend on that package pass -DEFAULT_VERSION = ApiVersion.V7_3_PREVIEW class AsyncKeyVaultClientBase(object): def __init__(self, vault_url: str, credential: "AsyncTokenCredential", **kwargs: "Any") -> None: diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py index 147af8e22dfd..2cfe70f2ec04 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py @@ -16,8 +16,7 @@ # pylint:disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpTransport - from azure.core.configuration import Configuration + class ApiVersion(str, Enum): """Key Vault API versions supported by this package""" diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_client_base.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_client_base.py index 8868c4ea82d5..5e638d4ead62 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_client_base.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_client_base.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from azure.core.pipeline.policies import HttpLoggingPolicy from . import AsyncChallengeAuthPolicy -from .client_base import ApiVersion +from .client_base import ApiVersion, DEFAULT_VERSION from .._sdk_moniker import SDK_MONIKER from .._generated.aio import KeyVaultClient as _KeyVaultClient @@ -13,14 +13,11 @@ try: # pylint:disable=unused-import from typing import Any - from azure.core.configuration import Configuration - from azure.core.pipeline.transport import AsyncHttpTransport from azure.core.credentials_async import AsyncTokenCredential except ImportError: # AsyncTokenCredential is a typing_extensions.Protocol; we don't depend on that package pass -DEFAULT_VERSION = ApiVersion.V7_3_PREVIEW class AsyncKeyVaultClientBase(object): def __init__(self, vault_url: str, credential: "AsyncTokenCredential", **kwargs: "Any") -> None: diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py index 147af8e22dfd..2cfe70f2ec04 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py @@ -16,8 +16,7 @@ # pylint:disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpTransport - from azure.core.configuration import Configuration + class ApiVersion(str, Enum): """Key Vault API versions supported by this package""" From a14168a665a87c47db5bbcab65631ec6c5d6072b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?McCoy=20Pati=C3=B1o?= Date: Wed, 29 Sep 2021 11:59:45 -0700 Subject: [PATCH 2/2] Align __init__.py files --- .../keyvault/certificates/_shared/__init__.py | 2 +- .../azure/keyvault/keys/_shared/__init__.py | 6 +++--- .../azure/keyvault/secrets/_shared/__init__.py | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/__init__.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/__init__.py index 3c99166efa6b..3329ce2df068 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/__init__.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/__init__.py @@ -61,7 +61,7 @@ def parse_key_vault_id(source_id): path = list(filter(None, parsed_uri.path.split("/"))) if len(path) < 2 or len(path) > 3: - raise ValueError("'{}' is not not a valid vault ID".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) return KeyVaultResourceId( source_id=source_id, diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/__init__.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/__init__.py index c981f211427e..3329ce2df068 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/__init__.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/__init__.py @@ -54,14 +54,14 @@ def parse_key_vault_id(source_id): try: parsed_uri = parse.urlparse(source_id) except Exception: # pylint: disable=broad-except - raise ValueError("'{}' is not not a valid url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) if not (parsed_uri.scheme and parsed_uri.hostname): - raise ValueError("'{}' is not not a valid url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) path = list(filter(None, parsed_uri.path.split("/"))) if len(path) < 2 or len(path) > 3: - raise ValueError("'{}' is not not a valid vault url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) return KeyVaultResourceId( source_id=source_id, diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/__init__.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/__init__.py index 578deccfb147..3329ce2df068 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/__init__.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/__init__.py @@ -37,11 +37,11 @@ class KeyVaultResourceId(): """ def __init__( - self, - source_id, # type: str - vault_url, # type: str - name, # type: str - version=None # type: Optional[str] + self, + source_id, # type: str + vault_url, # type: str + name, # type: str + version=None # type: Optional[str] ): self.source_id = source_id self.vault_url = vault_url @@ -54,14 +54,14 @@ def parse_key_vault_id(source_id): try: parsed_uri = parse.urlparse(source_id) except Exception: # pylint: disable=broad-except - raise ValueError("'{}' is not not a valid url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) if not (parsed_uri.scheme and parsed_uri.hostname): - raise ValueError("'{}' is not not a valid url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) path = list(filter(None, parsed_uri.path.split("/"))) if len(path) < 2 or len(path) > 3: - raise ValueError("'{}' is not not a valid vault url".format(source_id)) + raise ValueError("'{}' is not not a valid ID".format(source_id)) return KeyVaultResourceId( source_id=source_id,