Skip to content

Commit 56e4d11

Browse files
authored
[T2] Subscription (Azure#14943)
1 parent 76fb04c commit 56e4d11

31 files changed

+2864
-1774
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Release History
22

3+
## 1.0.0b1 (2020-10-23)
4+
5+
This is beta preview version.
6+
7+
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
8+
9+
General breaking changes
10+
11+
Credential system has been completly revamped:
12+
13+
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/
14+
credentials parameter has been renamed credential
15+
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 supported options, see the parameters accept in init documentation of azure-core
16+
17+
You can't import a version module anymore, use __version__ instead
18+
19+
Operations that used to return a msrest.polling.LROPoller now returns a azure.core.polling.LROPoller and are prefixed with begin_.
20+
21+
Exceptions tree have been simplified and most exceptions are now azure.core.exceptions.HttpResponseError (CloudError has been removed).
22+
23+
Most of the operation kwarg have changed. Some of the most noticeable:
24+
25+
raw has been removed. Equivalent feature can be found using cls, a callback that will give access to internal HTTP response for advanced user
26+
For a complete set of supported options, see the parameters accept in Request documentation of azure-core
27+
General new features
28+
29+
Type annotations support using typing. SDKs are mypy ready.
30+
This client has now stable and official support for async. Check the aio namespace of your package to find the async client.
31+
This client now support natively tracing library like OpenCensus or OpenTelemetry. See this tracing quickstart for an overview.
32+
333
## 0.5.0 (2019-08-21)
434

535
**Features**

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ library.
1414
For a more complete set of Azure libraries, see the
1515
[azure sdk python release](https://aka.ms/azsdk/python/all).
1616

17+
1718
## Usage
1819

1920
For code examples, see [Subscription
2021
Management](https://docs.microsoft.com/python/api/overview/azure/) on
2122
docs.microsoft.com.
2223

24+
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
25+
26+
27+
28+
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
29+
Code samples for this package can be found at [Subscription Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
30+
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
31+
32+
2333
## Provide Feedback
2434

2535
If you encounter any bugs or have suggestions, please file an issue in
Lines changed: 8 additions & 11 deletions
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 SubscriptionClientConfiguration
139
from ._subscription_client import SubscriptionClient
14-
__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration']
15-
16-
from .version import VERSION
17-
18-
__version__ = VERSION
10+
__all__ = ['SubscriptionClient']
1911

12+
try:
13+
from ._patch import patch_sdk # type: ignore
14+
patch_sdk()
15+
except ImportError:
16+
pass
Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
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
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
128

13-
from .version import VERSION
9+
from typing import TYPE_CHECKING
1410

11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
1514

16-
class SubscriptionClientConfiguration(AzureConfiguration):
17-
"""Configuration for SubscriptionClient
18-
Note that all parameters used to create this instance are saved as instance
19-
attributes.
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from typing import Any
2018

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 str base_url: Service URL
25-
"""
26-
27-
def __init__(
28-
self, credentials, base_url=None):
19+
from azure.core.credentials import TokenCredential
2920

30-
if credentials is None:
31-
raise ValueError("Parameter 'credentials' must not be None.")
32-
if not base_url:
33-
base_url = 'https://management.azure.com'
21+
VERSION = "unknown"
3422

35-
super(SubscriptionClientConfiguration, self).__init__(base_url)
23+
class SubscriptionClientConfiguration(Configuration):
24+
"""Configuration for SubscriptionClient.
3625
37-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
38-
self.keep_alive = True
26+
Note that all parameters used to create this instance are saved as instance
27+
attributes.
3928
40-
self.add_user_agent('azure-mgmt-subscription/{}'.format(VERSION))
41-
self.add_user_agent('Azure-SDK-For-Python')
29+
:param credential: Credential needed for the client to connect to Azure.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
"""
4232

43-
self.credentials = credentials
33+
def __init__(
34+
self,
35+
credential, # type: "TokenCredential"
36+
**kwargs # type: Any
37+
):
38+
# type: (...) -> None
39+
if credential is None:
40+
raise ValueError("Parameter 'credential' must not be None.")
41+
super(SubscriptionClientConfiguration, self).__init__(**kwargs)
42+
43+
self.credential = credential
44+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
45+
kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION))
46+
self._configure(**kwargs)
47+
48+
def _configure(
49+
self,
50+
**kwargs # type: Any
51+
):
52+
# type: (...) -> None
53+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
54+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
55+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
56+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
57+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
58+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
59+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
60+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
61+
self.authentication_policy = kwargs.get('authentication_policy')
62+
if self.credential and not self.authentication_policy:
63+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,87 @@
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 msrest.service_client import SDKClient
13-
from msrest import Serializer, Deserializer
9+
from typing import TYPE_CHECKING
10+
11+
from azure.mgmt.core import ARMPipelineClient
12+
from msrest import Deserializer, Serializer
13+
14+
if TYPE_CHECKING:
15+
# pylint: disable=unused-import,ungrouped-imports
16+
from typing import Any, Optional
17+
18+
from azure.core.credentials import TokenCredential
1419

1520
from ._configuration import SubscriptionClientConfiguration
1621
from .operations import SubscriptionsOperations
17-
from .operations import SubscriptionOperationOperations
18-
from .operations import SubscriptionFactoryOperations
22+
from .operations import TenantsOperations
1923
from .operations import SubscriptionOperations
2024
from .operations import Operations
21-
from .operations import TenantsOperations
25+
from .operations import AliasOperations
2226
from . import models
2327

2428

25-
class SubscriptionClient(SDKClient):
26-
"""The subscription client
27-
28-
:ivar config: Configuration for client.
29-
:vartype config: SubscriptionClientConfiguration
29+
class SubscriptionClient(object):
30+
"""The subscription client.
3031
31-
:ivar subscriptions: Subscriptions operations
32-
:vartype subscriptions: azure.mgmt.subscription.operations.SubscriptionsOperations
33-
:ivar subscription_operation: SubscriptionOperation operations
34-
:vartype subscription_operation: azure.mgmt.subscription.operations.SubscriptionOperationOperations
35-
:ivar subscription_factory: SubscriptionFactory operations
36-
:vartype subscription_factory: azure.mgmt.subscription.operations.SubscriptionFactoryOperations
37-
:ivar subscription_operations: SubscriptionOperations operations
38-
:vartype subscription_operations: azure.mgmt.subscription.operations.SubscriptionOperations
32+
:ivar subscriptions: SubscriptionsOperations operations
33+
:vartype subscriptions: subscription_client.operations.SubscriptionsOperations
34+
:ivar tenants: TenantsOperations operations
35+
:vartype tenants: subscription_client.operations.TenantsOperations
36+
:ivar subscription: SubscriptionOperations operations
37+
:vartype subscription: subscription_client.operations.SubscriptionOperations
3938
:ivar operations: Operations operations
40-
:vartype operations: azure.mgmt.subscription.operations.Operations
41-
:ivar tenants: Tenants operations
42-
:vartype tenants: azure.mgmt.subscription.operations.TenantsOperations
43-
44-
:param credentials: Credentials needed for the client to connect to Azure.
45-
:type credentials: :mod:`A msrestazure Credentials
46-
object<msrestazure.azure_active_directory>`
39+
:vartype operations: subscription_client.operations.Operations
40+
:ivar alias: AliasOperations operations
41+
:vartype alias: subscription_client.operations.AliasOperations
42+
:param credential: Credential needed for the client to connect to Azure.
43+
:type credential: ~azure.core.credentials.TokenCredential
4744
:param str base_url: Service URL
45+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
4846
"""
4947

5048
def __init__(
51-
self, credentials, base_url=None):
52-
53-
self.config = SubscriptionClientConfiguration(credentials, base_url)
54-
super(SubscriptionClient, self).__init__(self.config.credentials, self.config)
49+
self,
50+
credential, # type: "TokenCredential"
51+
base_url=None, # type: Optional[str]
52+
**kwargs # type: Any
53+
):
54+
# type: (...) -> None
55+
if not base_url:
56+
base_url = 'https://management.azure.com'
57+
self._config = SubscriptionClientConfiguration(credential, **kwargs)
58+
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
5559

5660
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
5761
self._serialize = Serializer(client_models)
62+
self._serialize.client_side_validation = False
5863
self._deserialize = Deserializer(client_models)
5964

6065
self.subscriptions = SubscriptionsOperations(
61-
self._client, self.config, self._serialize, self._deserialize)
62-
self.subscription_operation = SubscriptionOperationOperations(
63-
self._client, self.config, self._serialize, self._deserialize)
64-
self.subscription_factory = SubscriptionFactoryOperations(
65-
self._client, self.config, self._serialize, self._deserialize)
66-
self.subscription_operations = SubscriptionOperations(
67-
self._client, self.config, self._serialize, self._deserialize)
68-
self.operations = Operations(
69-
self._client, self.config, self._serialize, self._deserialize)
66+
self._client, self._config, self._serialize, self._deserialize)
7067
self.tenants = TenantsOperations(
71-
self._client, self.config, self._serialize, self._deserialize)
68+
self._client, self._config, self._serialize, self._deserialize)
69+
self.subscription = SubscriptionOperations(
70+
self._client, self._config, self._serialize, self._deserialize)
71+
self.operations = Operations(
72+
self._client, self._config, self._serialize, self._deserialize)
73+
self.alias = AliasOperations(
74+
self._client, self._config, self._serialize, self._deserialize)
75+
76+
def close(self):
77+
# type: () -> None
78+
self._client.close()
79+
80+
def __enter__(self):
81+
# type: () -> SubscriptionClient
82+
self._client.__enter__()
83+
return self
84+
85+
def __exit__(self, *exc_details):
86+
# type: (Any) -> None
87+
self._client.__exit__(*exc_details)

sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/version.py renamed to sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
VERSION = "0.5.0"
12+
VERSION = "1.0.0b1"
1313

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._subscription_client import SubscriptionClient
10+
__all__ = ['SubscriptionClient']
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14+
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from azure.core.credentials_async import AsyncTokenCredential
18+
19+
VERSION = "unknown"
20+
21+
class SubscriptionClientConfiguration(Configuration):
22+
"""Configuration for SubscriptionClient.
23+
24+
Note that all parameters used to create this instance are saved as instance
25+
attributes.
26+
27+
:param credential: Credential needed for the client to connect to Azure.
28+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
29+
"""
30+
31+
def __init__(
32+
self,
33+
credential: "AsyncTokenCredential",
34+
**kwargs: Any
35+
) -> None:
36+
if credential is None:
37+
raise ValueError("Parameter 'credential' must not be None.")
38+
super(SubscriptionClientConfiguration, self).__init__(**kwargs)
39+
40+
self.credential = credential
41+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
42+
kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION))
43+
self._configure(**kwargs)
44+
45+
def _configure(
46+
self,
47+
**kwargs: Any
48+
) -> None:
49+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
50+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
51+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
52+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
53+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
54+
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
55+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
56+
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
57+
self.authentication_policy = kwargs.get('authentication_policy')
58+
if self.credential and not self.authentication_policy:
59+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)