Skip to content
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

[Key Vault] Add API version 7.2 for administration #18997

Merged
merged 5 commits into from
Jun 3, 2021
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
3 changes: 3 additions & 0 deletions sdk/keyvault/azure-keyvault-administration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release History

## 4.0.0b4 (Unreleased)
### Changed
- Key Vault API version 7.2 is now the default

### Added
- `KeyVaultAccessControlClient.set_role_definition` accepts an optional
`assignable_scopes` keyword-only argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any
from typing import TYPE_CHECKING

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

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

class KeyVaultClientConfiguration(Configuration):
"""Configuration for KeyVaultClient.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
# regenerated.
# --------------------------------------------------------------------------

from azure.core import PipelineClient
from msrest import Serializer, Deserializer
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from msrest import Deserializer, Serializer

from ._configuration import KeyVaultClientConfiguration
from ._operations_mixin import KeyVaultClientOperationsMixin

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from azure.core.pipeline.transport import HttpRequest, HttpResponse

class _SDKClient(object):
def __init__(self, *args, **kwargs):
"""This is a fake class to support current implemetation of MultiApiClientMixin."
Expand All @@ -33,14 +42,14 @@ class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKCli
The profile sets a mapping between an operation group and its API version.
The api-version parameter sets the default API version if the operation
group is not described in the profile.
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param api_version: API version to use if no profile is provided, or if missing in profile.
:type api_version: str
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

DEFAULT_API_VERSION = '7.2-preview'
DEFAULT_API_VERSION = '7.2'
_PROFILE_TAG = "azure.keyvault.KeyVaultClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
Expand All @@ -51,14 +60,14 @@ class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKCli

def __init__(
self,
api_version=None,
profile=KnownProfiles.default,
api_version=None, # type: Optional[str]
profile=KnownProfiles.default, # type: KnownProfiles
**kwargs # type: Any
):
if api_version == '7.2-preview':
if api_version == '7.2':
base_url = '{vaultBaseUrl}'
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
self._config = KeyVaultClientConfiguration(**kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
super(KeyVaultClient, self).__init__(
Expand All @@ -74,37 +83,37 @@ def _models_dict(cls, api_version):
def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:

* 7.2-preview: :mod:`v7_2_preview.models<azure.keyvault.v7_2_preview.models>`
* 7.2: :mod:`v7_2.models<azure.keyvault.v7_2.models>`
"""
if api_version == '7.2-preview':
from .v7_2_preview import models
if api_version == '7.2':
from .v7_2 import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

@property
def role_assignments(self):
"""Instance depends on the API version:

* 7.2-preview: :class:`RoleAssignmentsOperations<azure.keyvault.v7_2_preview.operations.RoleAssignmentsOperations>`
* 7.2: :class:`RoleAssignmentsOperations<azure.keyvault.v7_2.operations.RoleAssignmentsOperations>`
"""
api_version = self._get_api_version('role_assignments')
if api_version == '7.2-preview':
from .v7_2_preview.operations import RoleAssignmentsOperations as OperationClass
if api_version == '7.2':
from .v7_2.operations import RoleAssignmentsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation group 'role_assignments'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def role_definitions(self):
"""Instance depends on the API version:

* 7.2-preview: :class:`RoleDefinitionsOperations<azure.keyvault.v7_2_preview.operations.RoleDefinitionsOperations>`
* 7.2: :class:`RoleDefinitionsOperations<azure.keyvault.v7_2.operations.RoleDefinitionsOperations>`
"""
api_version = self._get_api_version('role_definitions')
if api_version == '7.2-preview':
from .v7_2_preview.operations import RoleDefinitionsOperations as OperationClass
if api_version == '7.2':
from .v7_2.operations import RoleDefinitionsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation group 'role_definitions'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import TYPE_CHECKING
import warnings

from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
Expand All @@ -28,7 +28,7 @@ class KeyVaultClientOperationsMixin(object):
def begin_full_backup(
self,
vault_base_url, # type: str
azure_storage_blob_container_uri=None, # type: Optional["models.SASTokenParameter"]
azure_storage_blob_container_uri=None, # type: Optional["_models.SASTokenParameter"]
**kwargs # type: Any
):
"""Creates a full backup using a user-provided SAS token to an Azure blob storage container.
Expand All @@ -41,30 +41,31 @@ def begin_full_backup(
:type azure_storage_blob_container_uri: ~azure.keyvault.v7_2.models.SASTokenParameter
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: By default, your polling method will be LROBasePolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either FullBackupOperation or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.v7_2.models.FullBackupOperation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
api_version = self._get_api_version('begin_full_backup')
if api_version == '7.2-preview':
from .v7_2_preview.operations import KeyVaultClientOperationsMixin as OperationClass
if api_version == '7.2':
from .v7_2.operations import KeyVaultClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'begin_full_backup'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_full_backup(vault_base_url, azure_storage_blob_container_uri, **kwargs)

def begin_full_restore_operation(
self,
vault_base_url, # type: str
restore_blob_details=None, # type: Optional["models.RestoreOperationParameters"]
restore_blob_details=None, # type: Optional["_models.RestoreOperationParameters"]
**kwargs # type: Any
):
"""Restores all key materials using the SAS token pointing to a previously stored Azure Blob
Expand All @@ -77,31 +78,32 @@ def begin_full_restore_operation(
:type restore_blob_details: ~azure.keyvault.v7_2.models.RestoreOperationParameters
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: By default, your polling method will be LROBasePolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either RestoreOperation or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.v7_2.models.RestoreOperation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
api_version = self._get_api_version('begin_full_restore_operation')
if api_version == '7.2-preview':
from .v7_2_preview.operations import KeyVaultClientOperationsMixin as OperationClass
if api_version == '7.2':
from .v7_2.operations import KeyVaultClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'begin_full_restore_operation'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_full_restore_operation(vault_base_url, restore_blob_details, **kwargs)

def begin_selective_key_restore_operation(
self,
vault_base_url, # type: str
key_name, # type: str
restore_blob_details=None, # type: Optional["models.SelectiveKeyRestoreOperationParameters"]
restore_blob_details=None, # type: Optional["_models.SelectiveKeyRestoreOperationParameters"]
**kwargs # type: Any
):
"""Restores all key versions of a given key using user supplied SAS token pointing to a previously
Expand All @@ -116,23 +118,24 @@ def begin_selective_key_restore_operation(
:type restore_blob_details: ~azure.keyvault.v7_2.models.SelectiveKeyRestoreOperationParameters
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: By default, your polling method will be LROBasePolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either SelectiveKeyRestoreOperation or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.v7_2.models.SelectiveKeyRestoreOperation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
api_version = self._get_api_version('begin_selective_key_restore_operation')
if api_version == '7.2-preview':
from .v7_2_preview.operations import KeyVaultClientOperationsMixin as OperationClass
if api_version == '7.2':
from .v7_2.operations import KeyVaultClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'begin_selective_key_restore_operation'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_selective_key_restore_operation(vault_base_url, key_name, restore_blob_details, **kwargs)

Expand All @@ -154,14 +157,15 @@ def full_backup_status(
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = self._get_api_version('full_backup_status')
if api_version == '7.2-preview':
from .v7_2_preview.operations import KeyVaultClientOperationsMixin as OperationClass
if api_version == '7.2':
from .v7_2.operations import KeyVaultClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'full_backup_status'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.full_backup_status(vault_base_url, job_id, **kwargs)

Expand All @@ -183,13 +187,14 @@ def restore_status(
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = self._get_api_version('restore_status')
if api_version == '7.2-preview':
from .v7_2_preview.operations import KeyVaultClientOperationsMixin as OperationClass
if api_version == '7.2':
from .v7_2.operations import KeyVaultClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'restore_status'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.restore_status(vault_base_url, job_id, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._key_vault_client_async import KeyVaultClient
from ._key_vault_client import KeyVaultClient
__all__ = ['KeyVaultClient']
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .._version import VERSION


class KeyVaultClientConfiguration(Configuration):
"""Configuration for KeyVaultClient.

Expand Down
Loading