|
1 | 1 | # coding=utf-8 |
2 | 2 | # -------------------------------------------------------------------------- |
3 | 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 | | -# |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
7 | 5 | # 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. |
10 | 7 | # -------------------------------------------------------------------------- |
11 | 8 |
|
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 |
14 | 19 |
|
15 | 20 | from ._configuration import SubscriptionClientConfiguration |
16 | 21 | from .operations import SubscriptionsOperations |
17 | | -from .operations import SubscriptionOperationOperations |
18 | | -from .operations import SubscriptionFactoryOperations |
| 22 | +from .operations import TenantsOperations |
19 | 23 | from .operations import SubscriptionOperations |
20 | 24 | from .operations import Operations |
21 | | -from .operations import TenantsOperations |
| 25 | +from .operations import AliasOperations |
22 | 26 | from . import models |
23 | 27 |
|
24 | 28 |
|
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. |
30 | 31 |
|
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 |
39 | 38 | :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 |
47 | 44 | :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. |
48 | 46 | """ |
49 | 47 |
|
50 | 48 | 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) |
55 | 59 |
|
56 | 60 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
57 | 61 | self._serialize = Serializer(client_models) |
| 62 | + self._serialize.client_side_validation = False |
58 | 63 | self._deserialize = Deserializer(client_models) |
59 | 64 |
|
60 | 65 | 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) |
70 | 67 | 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) |
0 commit comments