Skip to content

Commit 2d2c064

Browse files
authored
[Key Vault] Align administration models (Azure#18745)
1 parent 2ec0448 commit 2d2c064

File tree

11 files changed

+197
-164
lines changed

11 files changed

+197
-164
lines changed

sdk/keyvault/azure-keyvault-administration/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,27 @@
88
### Breaking Changes
99
- Changed parameter order in `KeyVaultAccessControlClient.set_role_definition`.
1010
`permissions` is now an optional keyword-only argument
11+
- Renamed `BackupOperation` to `KeyVaultBackupOperation`
12+
- Renamed `RestoreOperation` to `KeyVaultRestoreOperation`
13+
- Renamed `SelectiveKeyRestoreOperation` to
14+
`KeyVaultSelectiveKeyRestoreOperation`
15+
- Renamed `KeyVaultBackupClient.begin_selective_restore` to `begin_selective_key_restore`
16+
- Changed parameter order from `folder_url, sas_token, key_name` to
17+
`key_name, folder_url, sas_token`
18+
- `KeyVaultRoleAssignment`'s `principal_id`, `role_definition_id`, and `scope`
19+
are now properties of a `properties` property
20+
```
21+
# before (4.0.0b3):
22+
print(KeyVaultRoleAssignment.scope)
1123
24+
# after:
25+
print(KeyVaultRoleAssignment.properties.scope)
26+
```
27+
- Renamed `KeyVaultPermission` properties:
28+
- `allowed_actions` -> `actions`
29+
- `denied_actions` -> `not_actions`
30+
- `allowed_data_actions` -> `data_actions`
31+
- `denied_data_actions` -> `denied_data_actions`
1232

1333
## 4.0.0b3 (2021-02-09)
1434
### Added

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@
77
from ._enums import KeyVaultRoleScope, KeyVaultDataAction
88
from ._internal.client_base import ApiVersion
99
from ._models import (
10-
BackupOperation,
10+
KeyVaultBackupOperation,
1111
KeyVaultPermission,
1212
KeyVaultRoleAssignment,
13+
KeyVaultRoleAssignmentProperties,
1314
KeyVaultRoleDefinition,
14-
RestoreOperation,
15-
SelectiveKeyRestoreOperation,
15+
KeyVaultRestoreOperation,
16+
KeyVaultSelectiveKeyRestoreOperation,
1617
)
1718

1819

1920
__all__ = [
2021
"ApiVersion",
21-
"BackupOperation",
22+
"KeyVaultBackupOperation",
2223
"KeyVaultAccessControlClient",
2324
"KeyVaultBackupClient",
2425
"KeyVaultDataAction",
2526
"KeyVaultPermission",
2627
"KeyVaultRoleAssignment",
28+
"KeyVaultRoleAssignmentProperties",
2729
"KeyVaultRoleDefinition",
2830
"KeyVaultRoleScope",
29-
"RestoreOperation",
30-
"SelectiveKeyRestoreOperation",
31+
"KeyVaultRestoreOperation",
32+
"KeyVaultSelectiveKeyRestoreOperation",
3133
]

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def create_role_assignment(self, role_scope, role_definition_id, principal_id, *
4141
principal can be a user, service principal, or security group.
4242
:keyword role_assignment_name: a name for the role assignment. Must be a UUID.
4343
:paramtype role_assignment_name: str or uuid.UUID
44-
:rtype: KeyVaultRoleAssignment
44+
:rtype: ~azure.keyvault.administration.KeyVaultRoleAssignment
4545
"""
4646
role_assignment_name = kwargs.pop("role_assignment_name", None) or uuid4()
4747

@@ -70,7 +70,7 @@ def delete_role_assignment(self, role_scope, role_assignment_name, **kwargs):
7070
:param role_assignment_name: the assignment's name.
7171
:type role_assignment_name: str or uuid.UUID
7272
:returns: the deleted assignment
73-
:rtype: KeyVaultRoleAssignment
73+
:rtype: ~azure.keyvault.administration.KeyVaultRoleAssignment
7474
"""
7575
assignment = self._client.role_assignments.delete(
7676
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
@@ -87,7 +87,7 @@ def get_role_assignment(self, role_scope, role_assignment_name, **kwargs):
8787
:type role_scope: str or KeyVaultRoleScope
8888
:param role_assignment_name: the assignment's name.
8989
:type role_assignment_name: str or uuid.UUID
90-
:rtype: KeyVaultRoleAssignment
90+
:rtype: ~azure.keyvault.administration.KeyVaultRoleAssignment
9191
"""
9292
assignment = self._client.role_assignments.get(
9393
vault_base_url=self._vault_url, scope=role_scope, role_assignment_name=str(role_assignment_name), **kwargs
@@ -102,7 +102,7 @@ def list_role_assignments(self, role_scope, **kwargs):
102102
:param role_scope: scope of the role assignments. :class:`KeyVaultRoleScope` defines common broad scopes.
103103
Specify a narrower scope as a string.
104104
:type role_scope: str or KeyVaultRoleScope
105-
:rtype: ~azure.core.paging.ItemPaged[KeyVaultRoleAssignment]
105+
:rtype: ~azure.core.paging.ItemPaged[~azure.keyvault.administration.KeyVaultRoleAssignment]
106106
"""
107107
return self._client.role_assignments.list_for_scope(
108108
self._vault_url,
@@ -133,14 +133,14 @@ def set_role_definition(self, role_scope, role_definition_name=None, **kwargs):
133133
:keyword assignable_scopes: the scopes for which the role definition can be assigned.
134134
:paramtype assignable_scopes: Iterable[str] or Iterable[KeyVaultRoleScope]
135135
:returns: The created or updated role definition
136-
:rtype: KeyVaultRoleDefinition
136+
:rtype: ~azure.keyvault.administration.KeyVaultRoleDefinition
137137
"""
138138
permissions = [
139139
self._client.role_definitions.models.Permission(
140-
actions=p.allowed_actions,
141-
not_actions=p.denied_actions,
142-
data_actions=p.allowed_data_actions,
143-
not_data_actions=p.denied_data_actions,
140+
actions=p.actions,
141+
not_actions=p.not_actions,
142+
data_actions=p.data_actions,
143+
not_data_actions=p.not_data_actions,
144144
)
145145
for p in kwargs.pop("permissions", None) or []
146146
]
@@ -172,7 +172,7 @@ def get_role_definition(self, role_scope, role_definition_name, **kwargs):
172172
:type role_scope: str or KeyVaultRoleScope
173173
:param role_definition_name: the role definition's name.
174174
:type role_definition_name: str or uuid.UUID
175-
:rtype: KeyVaultRoleDefinition
175+
:rtype: ~azure.keyvault.administration.KeyVaultRoleDefinition
176176
"""
177177
definition = self._client.role_definitions.get(
178178
vault_base_url=self._vault_url, scope=role_scope, role_definition_name=str(role_definition_name), **kwargs
@@ -190,7 +190,7 @@ def delete_role_definition(self, role_scope, role_definition_name, **kwargs):
190190
:param role_definition_name: the role definition's name.
191191
:type role_definition_name: str or uuid.UUID
192192
:returns: the deleted role definition
193-
:rtype: KeyVaultRoleDefinition
193+
:rtype: ~azure.keyvault.administration.KeyVaultRoleDefinition
194194
"""
195195
definition = self._client.role_definitions.delete(
196196
vault_base_url=self._vault_url, scope=role_scope, role_definition_name=str(role_definition_name), **kwargs
@@ -205,7 +205,7 @@ def list_role_definitions(self, role_scope, **kwargs):
205205
:param role_scope: scope of the role definitions. :class:`KeyVaultRoleScope` defines common broad scopes.
206206
Specify a narrower scope as a string.
207207
:type role_scope: str or KeyVaultRoleScope
208-
:rtype: ~azure.core.paging.ItemPaged[KeyVaultRoleDefinition]
208+
:rtype: ~azure.core.paging.ItemPaged[~azure.keyvault.administration.KeyVaultRoleDefinition]
209209
"""
210210
return self._client.role_definitions.list(
211211
self._vault_url,

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from azure.core.polling.base_polling import LROBasePolling
88

9-
from ._models import BackupOperation, RestoreOperation, SelectiveKeyRestoreOperation
9+
from ._models import KeyVaultBackupOperation, KeyVaultRestoreOperation, KeyVaultSelectiveKeyRestoreOperation
1010
from ._internal import KeyVaultClientBase, parse_folder_url
1111
from ._internal.polling import KeyVaultBackupClientPolling
1212

@@ -26,36 +26,37 @@ class KeyVaultBackupClient(KeyVaultClientBase):
2626

2727
# pylint:disable=protected-access
2828
def begin_backup(self, blob_storage_url, sas_token, **kwargs):
29-
# type: (str, str, **Any) -> LROPoller[BackupOperation]
29+
# type: (str, str, **Any) -> LROPoller[KeyVaultBackupOperation]
3030
"""Begin a full backup of the Key Vault.
3131
3232
:param str blob_storage_url: URL of the blob storage container in which the backup will be stored, for example
3333
https://<account>.blob.core.windows.net/backup
3434
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
3535
:keyword str continuation_token: a continuation token to restart polling from a saved state
36-
:returns: An instance of an LROPoller. Call `result()` on the poller object to get a :class:`BackupOperation`.
37-
:rtype: ~azure.core.polling.LROPoller[BackupOperation]
36+
:returns: An instance of an LROPoller. Call `result()` on the poller object to get a
37+
:class:`KeyVaultBackupOperation`.
38+
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.administration.KeyVaultBackupOperation]
3839
"""
3940
polling_interval = kwargs.pop("_polling_interval", 5)
4041
sas_parameter = self._models.SASTokenParameter(storage_resource_uri=blob_storage_url, token=sas_token)
4142
return self._client.begin_full_backup(
4243
vault_base_url=self._vault_url,
4344
azure_storage_blob_container_uri=sas_parameter,
44-
cls=BackupOperation._wrap_generated,
45+
cls=KeyVaultBackupOperation._wrap_generated,
4546
continuation_token=kwargs.pop("continuation_token", None),
4647
polling=LROBasePolling(lro_algorithms=[KeyVaultBackupClientPolling()], timeout=polling_interval, **kwargs),
4748
**kwargs
4849
)
4950

5051
def begin_restore(self, folder_url, sas_token, **kwargs):
51-
# type: (str, str, **Any) -> LROPoller[RestoreOperation]
52+
# type: (str, str, **Any) -> LROPoller[KeyVaultRestoreOperation]
5253
"""Restore a full backup of a Key Vault.
5354
5455
:param str folder_url: URL of the blob holding the backup. This would be the `folder_url` of a
55-
:class:`BackupOperation` returned by :func:`begin_backup` or :func:`get_backup_status`, for example
56+
:class:`KeyVaultBackupOperation` returned by :func:`begin_backup` or :func:`get_backup_status`, for example
5657
https://<account>.blob.core.windows.net/backup/mhsm-account-2020090117323313
5758
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
58-
:rtype: ~azure.core.polling.LROPoller[RestoreOperation]
59+
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.administration.KeyVaultRestoreOperation]
5960
"""
6061
polling_interval = kwargs.pop("_polling_interval", 5)
6162
container_url, folder_name = parse_folder_url(folder_url)
@@ -66,23 +67,23 @@ def begin_restore(self, folder_url, sas_token, **kwargs):
6667
return self._client.begin_full_restore_operation(
6768
vault_base_url=self._vault_url,
6869
restore_blob_details=restore_details,
69-
cls=RestoreOperation._wrap_generated,
70+
cls=KeyVaultRestoreOperation._wrap_generated,
7071
continuation_token=kwargs.pop("continuation_token", None),
7172
polling=LROBasePolling(lro_algorithms=[KeyVaultBackupClientPolling()], timeout=polling_interval, **kwargs),
7273
**kwargs
7374
)
7475

75-
def begin_selective_restore(self, folder_url, sas_token, key_name, **kwargs):
76-
# type: (str, str, str, **Any) -> LROPoller[SelectiveKeyRestoreOperation]
76+
def begin_selective_key_restore(self, key_name, folder_url, sas_token, **kwargs):
77+
# type: (str, str, str, **Any) -> LROPoller[KeyVaultSelectiveKeyRestoreOperation]
7778
"""Restore a single key from a full Key Vault backup.
7879
80+
:param str key_name: name of the key to restore from the backup
7981
:param str folder_url: URL for the blob storage resource, including the path to the blob holding the
80-
backup. This would be the `folder_url` of a :class:`BackupOperation` returned by
82+
backup. This would be the `folder_url` of a :class:`KeyVaultBackupOperation` returned by
8183
:func:`begin_backup` or :func:`get_backup_status`, for example
8284
https://<account>.blob.core.windows.net/backup/mhsm-account-2020090117323313
8385
:param str sas_token: a Shared Access Signature (SAS) token authorizing access to the blob storage resource
84-
:param str key_name: name of the key to restore from the backup
85-
:rtype: ~azure.core.polling.LROPoller[RestoreOperation]
86+
:rtype: ~azure.core.polling.LROPoller[~azure.keyvault.administration.KeyVaultSelectiveKeyRestoreOperation]
8687
"""
8788
polling_interval = kwargs.pop("_polling_interval", 5)
8889
container_url, folder_name = parse_folder_url(folder_url)
@@ -94,34 +95,34 @@ def begin_selective_restore(self, folder_url, sas_token, key_name, **kwargs):
9495
vault_base_url=self._vault_url,
9596
key_name=key_name,
9697
restore_blob_details=restore_details,
97-
cls=SelectiveKeyRestoreOperation._wrap_generated,
98+
cls=KeyVaultSelectiveKeyRestoreOperation._wrap_generated,
9899
continuation_token=kwargs.pop("continuation_token", None),
99100
polling=LROBasePolling(lro_algorithms=[KeyVaultBackupClientPolling()], timeout=polling_interval, **kwargs),
100101
**kwargs
101102
)
102103

103104
def get_backup_status(self, job_id, **kwargs):
104-
# type: (str, **Any) -> BackupOperation
105+
# type: (str, **Any) -> KeyVaultBackupOperation
105106
"""Returns the status of a full backup operation.
106107
107108
:param job_id: The job ID returned as part of the backup request
108109
:type job_id: str
109-
:return: The full backup operation status as a :class:`BackupOperation`
110-
:rtype: BackupOperation
110+
:return: The full backup operation status as a :class:`KeyVaultBackupOperation`
111+
:rtype: ~azure.keyvault.administration.KeyVaultBackupOperation
111112
"""
112113
return self._client.full_backup_status(
113-
vault_base_url=self._vault_url, job_id=job_id, cls=BackupOperation._wrap_generated, **kwargs
114+
vault_base_url=self._vault_url, job_id=job_id, cls=KeyVaultBackupOperation._wrap_generated, **kwargs
114115
)
115116

116117
def get_restore_status(self, job_id, **kwargs):
117-
# type: (str, **Any) -> RestoreOperation
118+
# type: (str, **Any) -> KeyVaultRestoreOperation
118119
"""Returns the status of a restore operation.
119120
120121
:param job_id: The job ID returned as part of the restore request
121122
:type job_id: str
122-
:return: The restore operation status as a :class:`RestoreOperation`
123-
:rtype: RestoreOperation
123+
:return: The restore operation status as a :class:`KeyVaultRestoreOperation`
124+
:rtype: ~azure.keyvault.administration.KeyVaultRestoreOperation
124125
"""
125126
return self._client.restore_status(
126-
vault_base_url=self.vault_url, job_id=job_id, cls=RestoreOperation._wrap_generated, **kwargs
127+
vault_base_url=self.vault_url, job_id=job_id, cls=KeyVaultRestoreOperation._wrap_generated, **kwargs
127128
)

0 commit comments

Comments
 (0)