Skip to content

Commit

Permalink
[Key Vault] Support 7.5 API version in Keys (Azure#34233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored Feb 14, 2024
1 parent f412402 commit d7ed3e0
Show file tree
Hide file tree
Showing 31 changed files with 1,313 additions and 1,476 deletions.
3 changes: 3 additions & 0 deletions sdk/keyvault/azure-keyvault-keys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 4.9.0b4 (Unreleased)

### Features Added
- Added support for service API version `7.5`

### Breaking Changes

Expand All @@ -12,6 +13,8 @@
- Python 3.7 is no longer supported. Please use Python version 3.8 or later.
- `asyncio` is no longer directly referenced by the library
([#33819](https://github.com/Azure/azure-sdk-for-python/pull/33819))
- Updated minimum `azure-core` version to 1.29.5
- Dropped `azure-common` requirement

## 4.9.0b3 (2023-11-03)

Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/azure-keyvault-keys/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/keyvault/azure-keyvault-keys",
"Tag": "python/keyvault/azure-keyvault-keys_cac2051a50"
"Tag": "python/keyvault/azure-keyvault-keys_d3b8eaba1a"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._key_vault_client import KeyVaultClient
from ._client import KeyVaultClient

try:
from ._patch import __all__ as _patch_all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,59 @@
from typing import Any

from azure.core import PipelineClient
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from . import models as _models
from ._configuration import KeyVaultClientConfiguration
from ._operations import KeyVaultClientOperationsMixin
from ._serialization import Deserializer, Serializer
from .operations import KeyVaultClientOperationsMixin


class KeyVaultClient(KeyVaultClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""The key vault client performs cryptographic key operations and vault operations against the Key
Vault service.
:keyword api_version: Api Version. Default value is "7.5-preview.1". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "7.5". Note that overriding this default
value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, **kwargs: Any) -> None: # pylint: disable=missing-client-constructor-parameter-credential
_endpoint = "{vaultBaseUrl}"
self._config = KeyVaultClientConfiguration(**kwargs)
self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)

client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)

client_models = {k: v for k, v in _models._models.__dict__.items() if isinstance(v, type)}
client_models.update({k: v for k, v in _models.__dict__.items() if isinstance(v, type)})
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False

def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
Expand All @@ -57,7 +76,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,28 @@

from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

VERSION = "unknown"


class KeyVaultClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
class KeyVaultClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for KeyVaultClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:keyword api_version: Api Version. Default value is "7.5-preview.1". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "7.5". Note that overriding this default
value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, **kwargs: Any) -> None:
super(KeyVaultClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "7.5-preview.1")
api_version: str = kwargs.pop("api_version", "7.5")

self.api_version = api_version
kwargs.setdefault("sdk_moniker", "keyvault/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _configure(self, **kwargs: Any) -> None:
Expand All @@ -39,7 +38,7 @@ def _configure(self, **kwargs: Any) -> None:
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._key_vault_client_operations import KeyVaultClientOperationsMixin
from ._operations import KeyVaultClientOperationsMixin

from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
Expand Down
Loading

0 comments on commit d7ed3e0

Please sign in to comment.