Skip to content

Commit a15b24a

Browse files
Zim Kalinowski00Kai0
Zim Kalinowski
andauthored
[T2] keyvault - preview.7 (#11484)
* updated keyvault * preview.7 * 5.1.0-preview.1 * [T2 aiotest] keyvault (#11646) * add aio test for keyvault * add .result for async poller * aiohttp * fixing async test * add random group name (#11909) * changelog and version * fixed changelog Co-authored-by: Kerwin Sun <[email protected]>
1 parent 1e45362 commit a15b24a

File tree

84 files changed

+11883
-4850
lines changed

Some content is hidden

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

84 files changed

+11883
-4850
lines changed

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

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Release History
22

3+
## 7.0.0b1 (2020-06-17)
4+
5+
This is beta preview version.
6+
For detailed changelog please refer to equivalent stable version 2.2.0 (https://pypi.org/project/azure-mgmt-keyvault/2.2.0/)
7+
8+
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
9+
10+
**General breaking changes**
11+
12+
- Credential system has been completly revamped:
13+
14+
- `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/
15+
- `credentials` parameter has been renamed `credential`
16+
17+
- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of
18+
supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
19+
- You can't import a `version` module anymore, use `__version__` instead
20+
- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`.
21+
- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed).
22+
- Most of the operation kwarg have changed. Some of the most noticeable:
23+
24+
- `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user
25+
- For a complete set of
26+
supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
27+
28+
**General new features**
29+
30+
- Type annotations support using `typing`. SDKs are mypy ready.
31+
- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client.
32+
- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview.
33+
334
## 2.2.0 (2020-03-20)
435

536
**Features**

sdk/keyvault/azure-mgmt-keyvault/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Microsoft Azure SDK for Python
22

3-
This is the Microsoft Azure Key Vault Management Client Library.
3+
This is the Microsoft Azure MyService Management Client Library.
44
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8.
55
For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/)
66

77

88
# Usage
99

10-
For code examples, see [Key Vault Management](https://docs.microsoft.com/python/api/overview/azure/key-vault)
10+
For code examples, see [MyService Management](https://docs.microsoft.com/python/api/overview/azure/)
1111
on docs.microsoft.com.
1212

1313

Original file line numberDiff line numberDiff line change
@@ -1,19 +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

12-
from ._configuration import KeyVaultManagementClientConfiguration
139
from ._key_vault_management_client import KeyVaultManagementClient
14-
__all__ = ['KeyVaultManagementClient', 'KeyVaultManagementClientConfiguration']
15-
16-
from .version import VERSION
17-
18-
__version__ = VERSION
10+
__all__ = ['KeyVaultManagementClient']
1911

12+
try:
13+
from ._patch import patch_sdk
14+
patch_sdk()
15+
except ImportError:
16+
pass

sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_configuration.py

+41-26
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,58 @@
88
# Changes may cause incorrect behavior and will be lost if the code is
99
# regenerated.
1010
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
11+
from typing import Any
1212

13-
from .version import VERSION
13+
from azure.core.configuration import Configuration
14+
from azure.core.pipeline import policies
1415

16+
from ._version import VERSION
17+
18+
19+
class KeyVaultManagementClientConfiguration(Configuration):
20+
"""Configuration for KeyVaultManagementClient.
1521
16-
class KeyVaultManagementClientConfiguration(AzureConfiguration):
17-
"""Configuration for KeyVaultManagementClient
1822
Note that all parameters used to create this instance are saved as instance
1923
attributes.
2024
21-
:param credentials: Credentials needed for the client to connect to Azure.
22-
:type credentials: :mod:`A msrestazure Credentials
23-
object<msrestazure.azure_active_directory>`
24-
:param subscription_id: Subscription credentials which uniquely identify
25-
Microsoft Azure subscription. The subscription ID forms part of the URI
26-
for every service call.
25+
:param credential: Credential needed for the client to connect to Azure.
26+
:type credential: ~azure.core.credentials.TokenCredential
27+
:param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
2728
:type subscription_id: str
28-
:param str base_url: Service URL
2929
"""
3030

3131
def __init__(
32-
self, credentials, subscription_id, base_url=None):
33-
34-
if credentials is None:
35-
raise ValueError("Parameter 'credentials' must not be None.")
32+
self,
33+
credential, # type: "TokenCredential"
34+
subscription_id, # type: str
35+
**kwargs # type: Any
36+
):
37+
# type: (...) -> None
38+
if credential is None:
39+
raise ValueError("Parameter 'credential' must not be None.")
3640
if subscription_id is None:
3741
raise ValueError("Parameter 'subscription_id' must not be None.")
38-
if not base_url:
39-
base_url = 'https://management.azure.com'
40-
41-
super(KeyVaultManagementClientConfiguration, self).__init__(base_url)
42+
super(KeyVaultManagementClientConfiguration, self).__init__(**kwargs)
4243

43-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
44-
self.keep_alive = True
45-
46-
self.add_user_agent('azure-mgmt-keyvault/{}'.format(VERSION))
47-
self.add_user_agent('Azure-SDK-For-Python')
48-
49-
self.credentials = credentials
44+
self.credential = credential
5045
self.subscription_id = subscription_id
46+
self.credential_scopes = ['https://management.azure.com/.default']
47+
self.credential_scopes.extend(kwargs.pop('credential_scopes', []))
48+
kwargs.setdefault('sdk_moniker', 'azure-mgmt-keyvault/{}'.format(VERSION))
49+
self._configure(**kwargs)
50+
51+
def _configure(
52+
self,
53+
**kwargs # type: Any
54+
):
55+
# type: (...) -> None
56+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
57+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
58+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
59+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
60+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
61+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
62+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
63+
self.authentication_policy = kwargs.get('authentication_policy')
64+
if self.credential and not self.authentication_policy:
65+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py

+43-24
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,41 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from msrest.service_client import SDKClient
12+
from azure.mgmt.core import ARMPipelineClient
1313
from msrest import Serializer, Deserializer
1414

1515
from azure.profiles import KnownProfiles, ProfileDefinition
1616
from azure.profiles.multiapiclient import MultiApiClientMixin
1717
from ._configuration import KeyVaultManagementClientConfiguration
1818

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
1925

20-
21-
class KeyVaultManagementClient(MultiApiClientMixin, SDKClient):
26+
class KeyVaultManagementClient(MultiApiClientMixin, _SDKClient):
2227
"""The Azure management API provides a RESTful set of web services that interact with Azure Key Vault.
2328
24-
This ready contains multiple API versions, to help you deal with all Azure clouds
29+
This ready contains multiple API versions, to help you deal with all of the Azure clouds
2530
(Azure Stack, Azure Government, Azure China, etc.).
26-
By default, uses latest API version available on public Azure.
27-
For production, you should stick a particular api-version and/or profile.
28-
The profile sets a mapping between the operation group and an API version.
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.
2934
The api-version parameter sets the default API version if the operation
3035
group is not described in the profile.
3136
32-
:ivar config: Configuration for client.
33-
:vartype config: KeyVaultManagementClientConfiguration
34-
35-
:param credentials: Credentials needed for the client to connect to Azure.
36-
:type credentials: :mod:`A msrestazure Credentials
37-
object<msrestazure.azure_active_directory>`
38-
:param subscription_id: Subscription credentials which uniquely identify
39-
Microsoft Azure subscription. The subscription ID forms part of the URI
40-
for every service call.
37+
:param credential: Credential needed for the client to connect to Azure.
38+
:type credential: ~azure.core.credentials.TokenCredential
39+
:param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
4140
:type subscription_id: str
4241
:param str api_version: API version to use if no profile is provided, or if
4342
missing in profile.
4443
:param str base_url: Service URL
4544
:param profile: A profile definition, from KnownProfiles to dict.
4645
:type profile: azure.profiles.KnownProfiles
46+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
4747
"""
4848

4949
DEFAULT_API_VERSION = '2019-09-01'
@@ -55,11 +55,22 @@ class KeyVaultManagementClient(MultiApiClientMixin, SDKClient):
5555
_PROFILE_TAG + " latest"
5656
)
5757

58-
def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default):
59-
self.config = KeyVaultManagementClientConfiguration(credentials, subscription_id, base_url)
58+
def __init__(
59+
self,
60+
credential, # type: "TokenCredential"
61+
subscription_id, # type: str
62+
api_version=None,
63+
base_url=None,
64+
profile=KnownProfiles.default,
65+
**kwargs # type: Any
66+
):
67+
if not base_url:
68+
base_url = 'https://management.azure.com'
69+
self._config = KeyVaultManagementClientConfiguration(credential, subscription_id, **kwargs)
70+
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
6071
super(KeyVaultManagementClient, self).__init__(
61-
credentials,
62-
self.config,
72+
credential,
73+
self._config,
6374
api_version=api_version,
6475
profile=profile
6576
)
@@ -104,7 +115,7 @@ def operations(self):
104115
from .v2019_09_01.operations import Operations as OperationClass
105116
else:
106117
raise NotImplementedError("APIVersion {} is not available".format(api_version))
107-
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
118+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
108119

109120
@property
110121
def private_endpoint_connections(self):
@@ -120,7 +131,7 @@ def private_endpoint_connections(self):
120131
from .v2019_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass
121132
else:
122133
raise NotImplementedError("APIVersion {} is not available".format(api_version))
123-
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
134+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
124135

125136
@property
126137
def private_link_resources(self):
@@ -136,7 +147,7 @@ def private_link_resources(self):
136147
from .v2019_09_01.operations import PrivateLinkResourcesOperations as OperationClass
137148
else:
138149
raise NotImplementedError("APIVersion {} is not available".format(api_version))
139-
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
150+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
140151

141152
@property
142153
def vaults(self):
@@ -155,4 +166,12 @@ def vaults(self):
155166
from .v2019_09_01.operations import VaultsOperations as OperationClass
156167
else:
157168
raise NotImplementedError("APIVersion {} is not available".format(api_version))
158-
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
169+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
170+
171+
def close(self):
172+
self._client.close()
173+
def __enter__(self):
174+
self._client.__enter__()
175+
return self
176+
def __exit__(self, *exc_details):
177+
self._client.__exit__(*exc_details)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
8+
VERSION = "7.0.0b1"
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
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

12-
VERSION = "2019-09-01"
13-
9+
from ._key_vault_management_client_async import KeyVaultManagementClient
10+
__all__ = ['KeyVaultManagementClient']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
from typing import Any
12+
13+
from azure.core.configuration import Configuration
14+
from azure.core.pipeline import policies
15+
16+
from .._version import VERSION
17+
18+
19+
class KeyVaultManagementClientConfiguration(Configuration):
20+
"""Configuration for KeyVaultManagementClient.
21+
22+
Note that all parameters used to create this instance are saved as instance
23+
attributes.
24+
25+
:param credential: Credential needed for the client to connect to Azure.
26+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
27+
:param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
28+
:type subscription_id: str
29+
"""
30+
31+
def __init__(
32+
self,
33+
credential, # type: "AsyncTokenCredential"
34+
subscription_id, # type: str
35+
**kwargs # type: Any
36+
) -> None:
37+
# type: (...) -> None
38+
if credential is None:
39+
raise ValueError("Parameter 'credential' must not be None.")
40+
if subscription_id is None:
41+
raise ValueError("Parameter 'subscription_id' must not be None.")
42+
super(KeyVaultManagementClientConfiguration, self).__init__(**kwargs)
43+
44+
self.credential = credential
45+
self.subscription_id = subscription_id
46+
self.credential_scopes = ['https://management.azure.com/.default']
47+
self.credential_scopes.extend(kwargs.pop('credential_scopes', []))
48+
kwargs.setdefault('sdk_moniker', 'azure-mgmt-keyvault/{}'.format(VERSION))
49+
self._configure(**kwargs)
50+
51+
def _configure(
52+
self,
53+
**kwargs: Any
54+
) -> None:
55+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
56+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
57+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
58+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
59+
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
60+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
61+
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
62+
self.authentication_policy = kwargs.get('authentication_policy')
63+
if self.credential and not self.authentication_policy:
64+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)