Skip to content

Commit d69e803

Browse files
authored
[key vault] Regenerate keys (Azure#12101)
1 parent 48a8133 commit d69e803

File tree

138 files changed

+46620
-50356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+46620
-50356
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- Updated minimum `azure-core` version to 1.4.0
77
- `CryptographyClient` will no longer perform encrypt or wrap operations when
88
its key has expired or is not yet valid.
9+
- Users can pass in CustomHookPolicy through the kwarg `custom_hook_policy` when initializing the client
10+
- RequestIdPolicy is now always set for all requests. This policy sets the id of the request in the header.
911

1012
## 4.2.0b1 (2020-03-10)
1113
- Support for Key Vault API version 7.1-preview

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License.
44
# -------------------------------------
55
from ._enums import KeyCurveName, KeyOperation, KeyType
6-
from ._shared.multi_api import ApiVersion
6+
from ._shared.client_base import ApiVersion
77
from ._models import DeletedKey, JsonWebKey, KeyProperties, KeyVaultKey
88
from ._client import KeyClient
99

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py

+32-9
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ def create_key(self, name, key_type, **kwargs):
8787
else:
8888
attributes = None
8989

90-
bundle = self._client.create_key(
91-
vault_base_url=self.vault_url,
92-
key_name=name,
90+
parameters = self._models.KeyCreateParameters(
9391
kty=key_type,
9492
key_size=kwargs.pop("size", None),
9593
key_attributes=attributes,
9694
key_ops=kwargs.pop("key_operations", None),
95+
tags=kwargs.pop("tags", None),
96+
curve=kwargs.pop("curve", None)
97+
)
98+
99+
bundle = self._client.create_key(
100+
vault_base_url=self.vault_url,
101+
key_name=name,
102+
parameters=parameters,
97103
error_map=_error_map,
98104
**kwargs
99105
)
@@ -439,12 +445,18 @@ def update_key_properties(self, name, version=None, **kwargs):
439445
attributes = self._models.KeyAttributes(enabled=enabled, not_before=not_before, expires=expires_on)
440446
else:
441447
attributes = None
448+
449+
parameters = self._models.KeyUpdateParameters(
450+
key_ops=kwargs.pop("key_operations", None),
451+
key_attributes=attributes,
452+
tags=kwargs.pop("tags", None)
453+
)
454+
442455
bundle = self._client.update_key(
443456
self.vault_url,
444457
name,
445458
key_version=version or "",
446-
key_ops=kwargs.pop("key_operations", None),
447-
key_attributes=attributes,
459+
parameters=parameters,
448460
error_map=_error_map,
449461
**kwargs
450462
)
@@ -500,7 +512,12 @@ def restore_key_backup(self, backup, **kwargs):
500512
:caption: Restore a key backup
501513
:dedent: 8
502514
"""
503-
bundle = self._client.restore_key(self.vault_url, backup, error_map=_error_map, **kwargs)
515+
bundle = self._client.restore_key(
516+
self.vault_url,
517+
parameters=self._models.KeyRestoreParameters(key_bundle_backup=backup),
518+
error_map=_error_map,
519+
**kwargs
520+
)
504521
return KeyVaultKey._from_key_bundle(bundle)
505522

506523
@distributed_trace
@@ -530,12 +547,18 @@ def import_key(self, name, key, **kwargs):
530547
attributes = self._models.KeyAttributes(enabled=enabled, not_before=not_before, expires=expires_on)
531548
else:
532549
attributes = None
533-
bundle = self._client.import_key(
534-
self.vault_url,
535-
name,
550+
551+
parameters = self._models.KeyImportParameters(
536552
key=key._to_generated_model(),
537553
key_attributes=attributes,
538554
hsm=kwargs.pop("hardware_protected", None),
555+
tags=kwargs.pop("tags", None)
556+
)
557+
558+
bundle = self._client.import_key(
559+
self.vault_url,
560+
name,
561+
parameters=parameters,
539562
error_map=_error_map,
540563
**kwargs
541564
)
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

129
from ._key_vault_client import KeyVaultClient
1310
__all__ = ['KeyVaultClient']
1411

15-
from .version import VERSION
16-
17-
__version__ = VERSION
18-
12+
try:
13+
from ._patch import patch_sdk # type: ignore
14+
patch_sdk()
15+
except ImportError:
16+
pass
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,42 @@
88
# Changes may cause incorrect behavior and will be lost if the code is
99
# regenerated.
1010
# --------------------------------------------------------------------------
11+
from typing import Any
12+
1113
from azure.core.configuration import Configuration
1214
from azure.core.pipeline import policies
1315

14-
from .version import VERSION
16+
from ._version import VERSION
1517

1618

1719
class KeyVaultClientConfiguration(Configuration):
18-
"""Configuration for KeyVaultClient
20+
"""Configuration for KeyVaultClient.
21+
1922
Note that all parameters used to create this instance are saved as instance
2023
attributes.
21-
22-
:param credentials: Credentials needed for the client to connect to Azure.
23-
:type credentials: :mod:`A msrestazure Credentials
24-
object<msrestazure.azure_active_directory>`
2524
"""
2625

27-
def __init__(self, credentials, **kwargs):
28-
29-
if credentials is None:
30-
raise ValueError("Parameter 'credentials' must not be None.")
31-
26+
def __init__(
27+
self,
28+
**kwargs # type: Any
29+
):
30+
# type: (...) -> None
3231
super(KeyVaultClientConfiguration, self).__init__(**kwargs)
33-
self._configure(**kwargs)
3432

35-
self.user_agent_policy.add_user_agent('azsdk-python-azure-keyvault/{}'.format(VERSION))
36-
self.generate_client_request_id = True
37-
38-
self.credentials = credentials
33+
kwargs.setdefault('sdk_moniker', 'azure-keyvault/{}'.format(VERSION))
34+
self._configure(**kwargs)
3935

40-
def _configure(self, **kwargs):
36+
def _configure(
37+
self,
38+
**kwargs # type: Any
39+
):
40+
# type: (...) -> None
4141
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
4242
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
4343
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
4444
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
45+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
4546
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
4647
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
4748
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
49+
self.authentication_policy = kwargs.get('authentication_policy')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from azure.core import PipelineClient
13+
from msrest import Serializer, Deserializer
14+
15+
from azure.profiles import KnownProfiles, ProfileDefinition
16+
from azure.profiles.multiapiclient import MultiApiClientMixin
17+
from ._configuration import KeyVaultClientConfiguration
18+
from ._operations_mixin import KeyVaultClientOperationsMixin
19+
class _SDKClient(object):
20+
def __init__(self, *args, **kwargs):
21+
"""This is a fake class to support current implemetation of MultiApiClientMixin."
22+
Will be removed in final version of multiapi azure-core based client
23+
"""
24+
pass
25+
26+
class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKClient):
27+
"""The key vault client performs cryptographic key operations and vault operations against the Key Vault service.
28+
29+
This ready contains multiple API versions, to help you deal with all of the Azure clouds
30+
(Azure Stack, Azure Government, Azure China, etc.).
31+
By default, it uses the latest API version available on public Azure.
32+
For production, you should stick to a particular api-version and/or profile.
33+
The profile sets a mapping between an operation group and its API version.
34+
The api-version parameter sets the default API version if the operation
35+
group is not described in the profile.
36+
:param str api_version: API version to use if no profile is provided, or if
37+
missing in profile.
38+
:param profile: A profile definition, from KnownProfiles to dict.
39+
:type profile: azure.profiles.KnownProfiles
40+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
41+
"""
42+
43+
DEFAULT_API_VERSION = '7.1'
44+
_PROFILE_TAG = "azure.keyvault.KeyVaultClient"
45+
LATEST_PROFILE = ProfileDefinition({
46+
_PROFILE_TAG: {
47+
None: DEFAULT_API_VERSION,
48+
'backup_certificate': '7.0',
49+
'backup_secret': '7.0',
50+
'backup_storage_account': '7.0',
51+
'create_certificate': '7.0',
52+
'delete_certificate': '7.0',
53+
'delete_certificate_contacts': '7.0',
54+
'delete_certificate_issuer': '7.0',
55+
'delete_certificate_operation': '7.0',
56+
'delete_sas_definition': '7.0',
57+
'delete_secret': '7.0',
58+
'delete_storage_account': '7.0',
59+
'get_certificate': '7.0',
60+
'get_certificate_contacts': '7.0',
61+
'get_certificate_issuer': '7.0',
62+
'get_certificate_issuers': '7.0',
63+
'get_certificate_operation': '7.0',
64+
'get_certificate_policy': '7.0',
65+
'get_certificate_versions': '7.0',
66+
'get_certificates': '7.0',
67+
'get_deleted_certificate': '7.0',
68+
'get_deleted_certificates': '7.0',
69+
'get_deleted_sas_definition': '7.0',
70+
'get_deleted_sas_definitions': '7.0',
71+
'get_deleted_secret': '7.0',
72+
'get_deleted_secrets': '7.0',
73+
'get_deleted_storage_account': '7.0',
74+
'get_deleted_storage_accounts': '7.0',
75+
'get_sas_definition': '7.0',
76+
'get_sas_definitions': '7.0',
77+
'get_secret': '7.0',
78+
'get_secret_versions': '7.0',
79+
'get_secrets': '7.0',
80+
'get_storage_account': '7.0',
81+
'get_storage_accounts': '7.0',
82+
'import_certificate': '7.0',
83+
'merge_certificate': '7.0',
84+
'purge_deleted_certificate': '7.0',
85+
'purge_deleted_secret': '7.0',
86+
'purge_deleted_storage_account': '7.0',
87+
'recover_deleted_certificate': '7.0',
88+
'recover_deleted_sas_definition': '7.0',
89+
'recover_deleted_secret': '7.0',
90+
'recover_deleted_storage_account': '7.0',
91+
'regenerate_storage_account_key': '7.0',
92+
'restore_certificate': '7.0',
93+
'restore_secret': '7.0',
94+
'restore_storage_account': '7.0',
95+
'set_certificate_contacts': '7.0',
96+
'set_certificate_issuer': '7.0',
97+
'set_sas_definition': '7.0',
98+
'set_secret': '7.0',
99+
'set_storage_account': '7.0',
100+
'update_certificate': '7.0',
101+
'update_certificate_issuer': '7.0',
102+
'update_certificate_operation': '7.0',
103+
'update_certificate_policy': '7.0',
104+
'update_sas_definition': '7.0',
105+
'update_secret': '7.0',
106+
'update_storage_account': '7.0',
107+
}},
108+
_PROFILE_TAG + " latest"
109+
)
110+
111+
def __init__(
112+
self,
113+
api_version=None,
114+
profile=KnownProfiles.default,
115+
**kwargs # type: Any
116+
):
117+
if api_version == '2016-10-01' or api_version == '7.0' or api_version == '7.1':
118+
base_url = '{vaultBaseUrl}'
119+
else:
120+
raise NotImplementedError("APIVersion {} is not available".format(api_version))
121+
self._config = KeyVaultClientConfiguration(**kwargs)
122+
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
123+
super(KeyVaultClient, self).__init__(
124+
api_version=api_version,
125+
profile=profile
126+
)
127+
128+
@classmethod
129+
def _models_dict(cls, api_version):
130+
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
131+
132+
@classmethod
133+
def models(cls, api_version=DEFAULT_API_VERSION):
134+
"""Module depends on the API version:
135+
136+
* 2016-10-01: :mod:`v2016_10_01.models<azure.keyvault.v2016_10_01.models>`
137+
* 7.0: :mod:`v7_0.models<azure.keyvault.v7_0.models>`
138+
* 7.1: :mod:`v7_1.models<azure.keyvault.v7_1.models>`
139+
"""
140+
if api_version == '2016-10-01':
141+
from .v2016_10_01 import models
142+
return models
143+
elif api_version == '7.0':
144+
from .v7_0 import models
145+
return models
146+
elif api_version == '7.1':
147+
from .v7_1 import models
148+
return models
149+
raise NotImplementedError("APIVersion {} is not available".format(api_version))
150+
151+
def close(self):
152+
self._client.close()
153+
def __enter__(self):
154+
self._client.__enter__()
155+
return self
156+
def __exit__(self, *exc_details):
157+
self._client.__exit__(*exc_details)

0 commit comments

Comments
 (0)