Skip to content

[Key Vault] Support 7.5 API version in Administration #34057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions sdk/keyvault/azure-keyvault-administration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
## 4.4.0b3 (Unreleased)

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

### Breaking Changes

### Bugs Fixed

### Other Changes
- Python 3.7 is no longer supported. Please use Python version 3.8 or later.
- Key Vault API version `7.5` is now the default
- Updated minimum `azure-core` version to 1.29.5
- Dropped `azure-common` requirement

## 4.4.0b2 (2023-11-03)

Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/azure-keyvault-administration/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-administration",
"Tag": "python/keyvault/azure-keyvault-administration_fe726effe9"
"Tag": "python/keyvault/azure-keyvault-administration_b16e831fc9"
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def begin_backup(self, blob_storage_url: str, *args: str, **kwargs: Any) -> LROP
:keyword use_managed_identity: Indicates which authentication method should be used. If set to True, Managed HSM
will use the configured user-assigned managed identity to authenticate with Azure Storage. Otherwise, a SAS
token has to be specified.
:paramtype use_managed_identity: Literal[True]
:paramtype use_managed_identity: bool
:keyword str continuation_token: A continuation token to restart polling from a saved state.

:returns: An :class:`~azure.core.polling.LROPoller` instance. Call `result()` on this object to wait for the
Expand Down Expand Up @@ -169,7 +169,7 @@ def begin_restore(self, folder_url: str, *args: str, **kwargs: Any) -> LROPoller
:keyword use_managed_identity: Indicates which authentication method should be used. If set to True, Managed HSM
will use the configured user-assigned managed identity to authenticate with Azure Storage. Otherwise, a SAS
token has to be specified.
:paramtype use_managed_identity: Literal[True]
:paramtype use_managed_identity: bool
:keyword str key_name: Name of a single key in the backup. When set, only this key will be restored.
:keyword str continuation_token: A continuation token to restart polling from a saved state.

Expand Down
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,6 +10,7 @@
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
Expand All @@ -23,11 +24,11 @@ class KeyVaultClient(KeyVaultClientOperationsMixin): # pylint: disable=client-a
Vault service.

:ivar role_definitions: RoleDefinitionsOperations operations
:vartype role_definitions: key_vault_client.operations.RoleDefinitionsOperations
:vartype role_definitions: azure.keyvault.v7_5.operations.RoleDefinitionsOperations
:ivar role_assignments: RoleAssignmentsOperations operations
:vartype role_assignments: key_vault_client.operations.RoleAssignmentsOperations
:keyword api_version: Api Version. Default value is "7.5-preview.1". Note that overriding this
default value may result in unsupported behavior.
:vartype role_assignments: azure.keyvault.v7_5.operations.RoleAssignmentsOperations
: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
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand All @@ -36,9 +37,27 @@ class KeyVaultClient(KeyVaultClientOperationsMixin): # pylint: disable=client-a
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
Expand All @@ -49,13 +68,13 @@ def __init__(self, **kwargs: Any) -> None: # pylint: disable=missing-client-con
self._client, self._config, self._serialize, self._deserialize
)

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 @@ -69,7 +88,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")
Loading