Skip to content

Commit

Permalink
[Key Vault] Get default API version from sync client base (Azure#20379)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored Sep 29, 2021
1 parent b0acdfb commit 2257388
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
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

if TYPE_CHECKING:
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
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

if TYPE_CHECKING:
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
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

if TYPE_CHECKING:
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 2257388

Please sign in to comment.