|
12 | 12 | from msrest.service_client import SDKClient |
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 |
|
21 | 19 |
|
22 | | -class AzureDigitalTwinsManagementClient(SDKClient): |
| 20 | + |
| 21 | +class AzureDigitalTwinsManagementClient(MultiApiClientMixin, SDKClient): |
23 | 22 | """Azure Digital Twins Client for managing DigitalTwinsInstance |
24 | 23 |
|
| 24 | + This ready contains multiple API versions, to help you deal with all Azure clouds |
| 25 | + (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. |
| 29 | + The api-version parameter sets the default API version if the operation |
| 30 | + group is not described in the profile. |
| 31 | +
|
25 | 32 | :ivar config: Configuration for client. |
26 | 33 | :vartype config: AzureDigitalTwinsManagementClientConfiguration |
27 | 34 |
|
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 | 35 | :param credentials: Credentials needed for the client to connect to Azure. |
36 | 36 | :type credentials: :mod:`A msrestazure Credentials |
37 | 37 | object<msrestazure.azure_active_directory>` |
38 | | - :param subscription_id: The subscription identifier. |
| 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. |
39 | 41 | :type subscription_id: str |
| 42 | + :param str api_version: API version to use if no profile is provided, or if |
| 43 | + missing in profile. |
40 | 44 | :param str base_url: Service URL |
| 45 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 46 | + :type profile: azure.profiles.KnownProfiles |
41 | 47 | """ |
42 | 48 |
|
43 | | - def __init__( |
44 | | - self, credentials, subscription_id, base_url=None): |
| 49 | + DEFAULT_API_VERSION = '2020-10-31' |
| 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 | + ) |
45 | 57 |
|
| 58 | + def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default): |
46 | 59 | 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) |
| 60 | + super(AzureDigitalTwinsManagementClient, self).__init__( |
| 61 | + credentials, |
| 62 | + self.config, |
| 63 | + api_version=api_version, |
| 64 | + profile=profile |
| 65 | + ) |
| 66 | + |
| 67 | + @classmethod |
| 68 | + def _models_dict(cls, api_version): |
| 69 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 70 | + |
| 71 | + @classmethod |
| 72 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 73 | + """Module depends on the API version: |
| 74 | +
|
| 75 | + * 2020-03-01-preview: :mod:`v2020_03_01_preview.models<azure.mgmt.digitaltwins.v2020_03_01_preview.models>` |
| 76 | + * 2020-10-31: :mod:`v2020_10_31.models<azure.mgmt.digitaltwins.v2020_10_31.models>` |
| 77 | + """ |
| 78 | + if api_version == '2020-03-01-preview': |
| 79 | + from .v2020_03_01_preview import models |
| 80 | + return models |
| 81 | + elif api_version == '2020-10-31': |
| 82 | + from .v2020_10_31 import models |
| 83 | + return models |
| 84 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 85 | + |
| 86 | + @property |
| 87 | + def digital_twins(self): |
| 88 | + """Instance depends on the API version: |
| 89 | +
|
| 90 | + * 2020-03-01-preview: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsOperations>` |
| 91 | + * 2020-10-31: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsOperations>` |
| 92 | + """ |
| 93 | + api_version = self._get_api_version('digital_twins') |
| 94 | + if api_version == '2020-03-01-preview': |
| 95 | + from .v2020_03_01_preview.operations import DigitalTwinsOperations as OperationClass |
| 96 | + elif api_version == '2020-10-31': |
| 97 | + from .v2020_10_31.operations import DigitalTwinsOperations as OperationClass |
| 98 | + else: |
| 99 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 100 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 101 | + |
| 102 | + @property |
| 103 | + def digital_twins_endpoint(self): |
| 104 | + """Instance depends on the API version: |
| 105 | +
|
| 106 | + * 2020-03-01-preview: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsEndpointOperations>` |
| 107 | + * 2020-10-31: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsEndpointOperations>` |
| 108 | + """ |
| 109 | + api_version = self._get_api_version('digital_twins_endpoint') |
| 110 | + if api_version == '2020-03-01-preview': |
| 111 | + from .v2020_03_01_preview.operations import DigitalTwinsEndpointOperations as OperationClass |
| 112 | + elif api_version == '2020-10-31': |
| 113 | + from .v2020_10_31.operations import DigitalTwinsEndpointOperations as OperationClass |
| 114 | + else: |
| 115 | + raise NotImplementedError("APIVersion {} is not available".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 operations(self): |
| 120 | + """Instance depends on the API version: |
| 121 | +
|
| 122 | + * 2020-03-01-preview: :class:`Operations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.Operations>` |
| 123 | + * 2020-10-31: :class:`Operations<azure.mgmt.digitaltwins.v2020_10_31.operations.Operations>` |
| 124 | + """ |
| 125 | + api_version = self._get_api_version('operations') |
| 126 | + if api_version == '2020-03-01-preview': |
| 127 | + from .v2020_03_01_preview.operations import Operations as OperationClass |
| 128 | + elif api_version == '2020-10-31': |
| 129 | + from .v2020_10_31.operations import Operations as OperationClass |
| 130 | + else: |
| 131 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 132 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
0 commit comments