|
9 | 9 | # regenerated. |
10 | 10 | # -------------------------------------------------------------------------- |
11 | 11 |
|
12 | | -from msrest.service_client import SDKClient |
| 12 | +from azure.mgmt.core import ARMPipelineClient |
13 | 13 | from msrest import Serializer, Deserializer |
14 | 14 |
|
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
15 | 17 | from ._configuration import AzureDigitalTwinsManagementClientConfiguration |
16 | | -from .operations import DigitalTwinsOperations |
17 | | -from .operations import DigitalTwinsEndpointOperations |
18 | | -from .operations import Operations |
19 | | -from . import models |
20 | 18 |
|
| 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 |
21 | 25 |
|
22 | | -class AzureDigitalTwinsManagementClient(SDKClient): |
23 | | - """Azure Digital Twins Client for managing DigitalTwinsInstance |
| 26 | +class AzureDigitalTwinsManagementClient(MultiApiClientMixin, _SDKClient): |
| 27 | + """Azure Digital Twins Client for managing DigitalTwinsInstance. |
24 | 28 |
|
25 | | - :ivar config: Configuration for client. |
26 | | - :vartype config: AzureDigitalTwinsManagementClientConfiguration |
| 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. |
27 | 36 |
|
28 | | - :ivar digital_twins: DigitalTwins operations |
29 | | - :vartype digital_twins: azure.mgmt.digitaltwins.operations.DigitalTwinsOperations |
30 | | - :ivar digital_twins_endpoint: DigitalTwinsEndpoint operations |
31 | | - :vartype digital_twins_endpoint: azure.mgmt.digitaltwins.operations.DigitalTwinsEndpointOperations |
32 | | - :ivar operations: Operations operations |
33 | | - :vartype operations: azure.mgmt.digitaltwins.operations.Operations |
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>` |
| 37 | + :param credential: Credential needed for the client to connect to Azure. |
| 38 | + :type credential: ~azure.core.credentials.TokenCredential |
38 | 39 | :param subscription_id: The subscription identifier. |
39 | 40 | :type subscription_id: str |
| 41 | + :param str api_version: API version to use if no profile is provided, or if |
| 42 | + missing in profile. |
40 | 43 | :param str base_url: Service URL |
| 44 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 45 | + :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. |
41 | 47 | """ |
42 | 48 |
|
| 49 | + DEFAULT_API_VERSION = '2020-12-01' |
| 50 | + _PROFILE_TAG = "azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient" |
| 51 | + LATEST_PROFILE = ProfileDefinition({ |
| 52 | + _PROFILE_TAG: { |
| 53 | + None: DEFAULT_API_VERSION, |
| 54 | + }}, |
| 55 | + _PROFILE_TAG + " latest" |
| 56 | + ) |
| 57 | + |
43 | 58 | def __init__( |
44 | | - self, credentials, subscription_id, base_url=None): |
45 | | - |
46 | | - self.config = AzureDigitalTwinsManagementClientConfiguration(credentials, subscription_id, base_url) |
47 | | - super(AzureDigitalTwinsManagementClient, self).__init__(self.config.credentials, self.config) |
48 | | - |
49 | | - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
50 | | - self.api_version = '2020-03-01-preview' |
51 | | - self._serialize = Serializer(client_models) |
52 | | - self._deserialize = Deserializer(client_models) |
53 | | - |
54 | | - self.digital_twins = DigitalTwinsOperations( |
55 | | - self._client, self.config, self._serialize, self._deserialize) |
56 | | - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( |
57 | | - self._client, self.config, self._serialize, self._deserialize) |
58 | | - self.operations = Operations( |
59 | | - self._client, self.config, self._serialize, self._deserialize) |
| 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 = AzureDigitalTwinsManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 70 | + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 71 | + super(AzureDigitalTwinsManagementClient, self).__init__( |
| 72 | + api_version=api_version, |
| 73 | + profile=profile |
| 74 | + ) |
| 75 | + |
| 76 | + @classmethod |
| 77 | + def _models_dict(cls, api_version): |
| 78 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 79 | + |
| 80 | + @classmethod |
| 81 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 82 | + """Module depends on the API version: |
| 83 | +
|
| 84 | + * 2020-03-01-preview: :mod:`v2020_03_01_preview.models<azure.mgmt.digitaltwins.v2020_03_01_preview.models>` |
| 85 | + * 2020-10-31: :mod:`v2020_10_31.models<azure.mgmt.digitaltwins.v2020_10_31.models>` |
| 86 | + * 2020-12-01: :mod:`v2020_12_01.models<azure.mgmt.digitaltwins.v2020_12_01.models>` |
| 87 | + """ |
| 88 | + if api_version == '2020-03-01-preview': |
| 89 | + from .v2020_03_01_preview import models |
| 90 | + return models |
| 91 | + elif api_version == '2020-10-31': |
| 92 | + from .v2020_10_31 import models |
| 93 | + return models |
| 94 | + elif api_version == '2020-12-01': |
| 95 | + from .v2020_12_01 import models |
| 96 | + return models |
| 97 | + raise ValueError("API version {} is not available".format(api_version)) |
| 98 | + |
| 99 | + @property |
| 100 | + def digital_twins(self): |
| 101 | + """Instance depends on the API version: |
| 102 | +
|
| 103 | + * 2020-03-01-preview: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsOperations>` |
| 104 | + * 2020-10-31: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsOperations>` |
| 105 | + * 2020-12-01: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsOperations>` |
| 106 | + """ |
| 107 | + api_version = self._get_api_version('digital_twins') |
| 108 | + if api_version == '2020-03-01-preview': |
| 109 | + from .v2020_03_01_preview.operations import DigitalTwinsOperations as OperationClass |
| 110 | + elif api_version == '2020-10-31': |
| 111 | + from .v2020_10_31.operations import DigitalTwinsOperations as OperationClass |
| 112 | + elif api_version == '2020-12-01': |
| 113 | + from .v2020_12_01.operations import DigitalTwinsOperations as OperationClass |
| 114 | + else: |
| 115 | + raise ValueError("API version {} does not have operation group 'digital_twins'".format(api_version)) |
| 116 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 117 | + |
| 118 | + @property |
| 119 | + def digital_twins_endpoint(self): |
| 120 | + """Instance depends on the API version: |
| 121 | +
|
| 122 | + * 2020-03-01-preview: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsEndpointOperations>` |
| 123 | + * 2020-10-31: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsEndpointOperations>` |
| 124 | + * 2020-12-01: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsEndpointOperations>` |
| 125 | + """ |
| 126 | + api_version = self._get_api_version('digital_twins_endpoint') |
| 127 | + if api_version == '2020-03-01-preview': |
| 128 | + from .v2020_03_01_preview.operations import DigitalTwinsEndpointOperations as OperationClass |
| 129 | + elif api_version == '2020-10-31': |
| 130 | + from .v2020_10_31.operations import DigitalTwinsEndpointOperations as OperationClass |
| 131 | + elif api_version == '2020-12-01': |
| 132 | + from .v2020_12_01.operations import DigitalTwinsEndpointOperations as OperationClass |
| 133 | + else: |
| 134 | + raise ValueError("API version {} does not have operation group 'digital_twins_endpoint'".format(api_version)) |
| 135 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 136 | + |
| 137 | + @property |
| 138 | + def operations(self): |
| 139 | + """Instance depends on the API version: |
| 140 | +
|
| 141 | + * 2020-03-01-preview: :class:`Operations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.Operations>` |
| 142 | + * 2020-10-31: :class:`Operations<azure.mgmt.digitaltwins.v2020_10_31.operations.Operations>` |
| 143 | + * 2020-12-01: :class:`Operations<azure.mgmt.digitaltwins.v2020_12_01.operations.Operations>` |
| 144 | + """ |
| 145 | + api_version = self._get_api_version('operations') |
| 146 | + if api_version == '2020-03-01-preview': |
| 147 | + from .v2020_03_01_preview.operations import Operations as OperationClass |
| 148 | + elif api_version == '2020-10-31': |
| 149 | + from .v2020_10_31.operations import Operations as OperationClass |
| 150 | + elif api_version == '2020-12-01': |
| 151 | + from .v2020_12_01.operations import Operations as OperationClass |
| 152 | + else: |
| 153 | + raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) |
| 154 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 155 | + |
| 156 | + @property |
| 157 | + def private_endpoint_connections(self): |
| 158 | + """Instance depends on the API version: |
| 159 | +
|
| 160 | + * 2020-12-01: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateEndpointConnectionsOperations>` |
| 161 | + """ |
| 162 | + api_version = self._get_api_version('private_endpoint_connections') |
| 163 | + if api_version == '2020-12-01': |
| 164 | + from .v2020_12_01.operations import PrivateEndpointConnectionsOperations as OperationClass |
| 165 | + else: |
| 166 | + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) |
| 167 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 168 | + |
| 169 | + @property |
| 170 | + def private_link_resources(self): |
| 171 | + """Instance depends on the API version: |
| 172 | +
|
| 173 | + * 2020-12-01: :class:`PrivateLinkResourcesOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateLinkResourcesOperations>` |
| 174 | + """ |
| 175 | + api_version = self._get_api_version('private_link_resources') |
| 176 | + if api_version == '2020-12-01': |
| 177 | + from .v2020_12_01.operations import PrivateLinkResourcesOperations as OperationClass |
| 178 | + else: |
| 179 | + raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) |
| 180 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 181 | + |
| 182 | + def close(self): |
| 183 | + self._client.close() |
| 184 | + def __enter__(self): |
| 185 | + self._client.__enter__() |
| 186 | + return self |
| 187 | + def __exit__(self, *exc_details): |
| 188 | + self._client.__exit__(*exc_details) |
0 commit comments