|
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 DataBoxManagementClientConfiguration |
16 | | -from .operations import Operations |
17 | | -from .operations import JobsOperations |
18 | | -from .operations import ServiceOperations |
19 | | -from . import models |
| 18 | +from ._operations_mixin import DataBoxManagementClientOperationsMixin |
20 | 19 |
|
21 | 20 |
|
22 | | -class DataBoxManagementClient(SDKClient): |
| 21 | +class DataBoxManagementClient(DataBoxManagementClientOperationsMixin, MultiApiClientMixin, SDKClient): |
23 | 22 | """DataBoxManagementClient |
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: DataBoxManagementClientConfiguration |
27 | 34 |
|
28 | | - :ivar operations: Operations operations |
29 | | - :vartype operations: azure.mgmt.databox.operations.Operations |
30 | | - :ivar jobs: Jobs operations |
31 | | - :vartype jobs: azure.mgmt.databox.operations.JobsOperations |
32 | | - :ivar service: Service operations |
33 | | - :vartype service: azure.mgmt.databox.operations.ServiceOperations |
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 Id |
| 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 = '2021-05-01' |
| 50 | + _PROFILE_TAG = "azure.mgmt.databox.DataBoxManagementClient" |
| 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 = DataBoxManagementClientConfiguration(credentials, subscription_id, base_url) |
47 | | - super(DataBoxManagementClient, 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 = '2019-09-01' |
51 | | - self._serialize = Serializer(client_models) |
52 | | - self._deserialize = Deserializer(client_models) |
53 | | - |
54 | | - self.operations = Operations( |
55 | | - self._client, self.config, self._serialize, self._deserialize) |
56 | | - self.jobs = JobsOperations( |
57 | | - self._client, self.config, self._serialize, self._deserialize) |
58 | | - self.service = ServiceOperations( |
59 | | - self._client, self.config, self._serialize, self._deserialize) |
| 60 | + super(DataBoxManagementClient, 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 | + * 2018-01-01: :mod:`v2018_01_01.models<azure.mgmt.databox.v2018_01_01.models>` |
| 76 | + * 2019-09-01: :mod:`v2019_09_01.models<azure.mgmt.databox.v2019_09_01.models>` |
| 77 | + * 2020-04-01: :mod:`v2020_04_01.models<azure.mgmt.databox.v2020_04_01.models>` |
| 78 | + * 2020-11-01: :mod:`v2020_11_01.models<azure.mgmt.databox.v2020_11_01.models>` |
| 79 | + * 2021-03-01: :mod:`v2021_03_01.models<azure.mgmt.databox.v2021_03_01.models>` |
| 80 | + * 2021-05-01: :mod:`v2021_05_01.models<azure.mgmt.databox.v2021_05_01.models>` |
| 81 | + """ |
| 82 | + if api_version == '2018-01-01': |
| 83 | + from .v2018_01_01 import models |
| 84 | + return models |
| 85 | + elif api_version == '2019-09-01': |
| 86 | + from .v2019_09_01 import models |
| 87 | + return models |
| 88 | + elif api_version == '2020-04-01': |
| 89 | + from .v2020_04_01 import models |
| 90 | + return models |
| 91 | + elif api_version == '2020-11-01': |
| 92 | + from .v2020_11_01 import models |
| 93 | + return models |
| 94 | + elif api_version == '2021-03-01': |
| 95 | + from .v2021_03_01 import models |
| 96 | + return models |
| 97 | + elif api_version == '2021-05-01': |
| 98 | + from .v2021_05_01 import models |
| 99 | + return models |
| 100 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 101 | + |
| 102 | + @property |
| 103 | + def jobs(self): |
| 104 | + """Instance depends on the API version: |
| 105 | +
|
| 106 | + * 2018-01-01: :class:`JobsOperations<azure.mgmt.databox.v2018_01_01.operations.JobsOperations>` |
| 107 | + * 2019-09-01: :class:`JobsOperations<azure.mgmt.databox.v2019_09_01.operations.JobsOperations>` |
| 108 | + * 2020-04-01: :class:`JobsOperations<azure.mgmt.databox.v2020_04_01.operations.JobsOperations>` |
| 109 | + * 2020-11-01: :class:`JobsOperations<azure.mgmt.databox.v2020_11_01.operations.JobsOperations>` |
| 110 | + * 2021-03-01: :class:`JobsOperations<azure.mgmt.databox.v2021_03_01.operations.JobsOperations>` |
| 111 | + * 2021-05-01: :class:`JobsOperations<azure.mgmt.databox.v2021_05_01.operations.JobsOperations>` |
| 112 | + """ |
| 113 | + api_version = self._get_api_version('jobs') |
| 114 | + if api_version == '2018-01-01': |
| 115 | + from .v2018_01_01.operations import JobsOperations as OperationClass |
| 116 | + elif api_version == '2019-09-01': |
| 117 | + from .v2019_09_01.operations import JobsOperations as OperationClass |
| 118 | + elif api_version == '2020-04-01': |
| 119 | + from .v2020_04_01.operations import JobsOperations as OperationClass |
| 120 | + elif api_version == '2020-11-01': |
| 121 | + from .v2020_11_01.operations import JobsOperations as OperationClass |
| 122 | + elif api_version == '2021-03-01': |
| 123 | + from .v2021_03_01.operations import JobsOperations as OperationClass |
| 124 | + elif api_version == '2021-05-01': |
| 125 | + from .v2021_05_01.operations import JobsOperations as OperationClass |
| 126 | + else: |
| 127 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 128 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 129 | + |
| 130 | + @property |
| 131 | + def operations(self): |
| 132 | + """Instance depends on the API version: |
| 133 | +
|
| 134 | + * 2018-01-01: :class:`Operations<azure.mgmt.databox.v2018_01_01.operations.Operations>` |
| 135 | + * 2019-09-01: :class:`Operations<azure.mgmt.databox.v2019_09_01.operations.Operations>` |
| 136 | + * 2020-04-01: :class:`Operations<azure.mgmt.databox.v2020_04_01.operations.Operations>` |
| 137 | + * 2020-11-01: :class:`Operations<azure.mgmt.databox.v2020_11_01.operations.Operations>` |
| 138 | + * 2021-03-01: :class:`Operations<azure.mgmt.databox.v2021_03_01.operations.Operations>` |
| 139 | + * 2021-05-01: :class:`Operations<azure.mgmt.databox.v2021_05_01.operations.Operations>` |
| 140 | + """ |
| 141 | + api_version = self._get_api_version('operations') |
| 142 | + if api_version == '2018-01-01': |
| 143 | + from .v2018_01_01.operations import Operations as OperationClass |
| 144 | + elif api_version == '2019-09-01': |
| 145 | + from .v2019_09_01.operations import Operations as OperationClass |
| 146 | + elif api_version == '2020-04-01': |
| 147 | + from .v2020_04_01.operations import Operations as OperationClass |
| 148 | + elif api_version == '2020-11-01': |
| 149 | + from .v2020_11_01.operations import Operations as OperationClass |
| 150 | + elif api_version == '2021-03-01': |
| 151 | + from .v2021_03_01.operations import Operations as OperationClass |
| 152 | + elif api_version == '2021-05-01': |
| 153 | + from .v2021_05_01.operations import Operations as OperationClass |
| 154 | + else: |
| 155 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 156 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 157 | + |
| 158 | + @property |
| 159 | + def service(self): |
| 160 | + """Instance depends on the API version: |
| 161 | +
|
| 162 | + * 2018-01-01: :class:`ServiceOperations<azure.mgmt.databox.v2018_01_01.operations.ServiceOperations>` |
| 163 | + * 2019-09-01: :class:`ServiceOperations<azure.mgmt.databox.v2019_09_01.operations.ServiceOperations>` |
| 164 | + * 2020-04-01: :class:`ServiceOperations<azure.mgmt.databox.v2020_04_01.operations.ServiceOperations>` |
| 165 | + * 2020-11-01: :class:`ServiceOperations<azure.mgmt.databox.v2020_11_01.operations.ServiceOperations>` |
| 166 | + * 2021-03-01: :class:`ServiceOperations<azure.mgmt.databox.v2021_03_01.operations.ServiceOperations>` |
| 167 | + * 2021-05-01: :class:`ServiceOperations<azure.mgmt.databox.v2021_05_01.operations.ServiceOperations>` |
| 168 | + """ |
| 169 | + api_version = self._get_api_version('service') |
| 170 | + if api_version == '2018-01-01': |
| 171 | + from .v2018_01_01.operations import ServiceOperations as OperationClass |
| 172 | + elif api_version == '2019-09-01': |
| 173 | + from .v2019_09_01.operations import ServiceOperations as OperationClass |
| 174 | + elif api_version == '2020-04-01': |
| 175 | + from .v2020_04_01.operations import ServiceOperations as OperationClass |
| 176 | + elif api_version == '2020-11-01': |
| 177 | + from .v2020_11_01.operations import ServiceOperations as OperationClass |
| 178 | + elif api_version == '2021-03-01': |
| 179 | + from .v2021_03_01.operations import ServiceOperations as OperationClass |
| 180 | + elif api_version == '2021-05-01': |
| 181 | + from .v2021_05_01.operations import ServiceOperations as OperationClass |
| 182 | + else: |
| 183 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 184 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
0 commit comments