9
9
# regenerated.
10
10
# --------------------------------------------------------------------------
11
11
12
- from msrest .service_client import ServiceClient
12
+ from msrest .service_client import SDKClient
13
13
from msrest import Serializer , Deserializer
14
14
from msrestazure import AzureConfiguration
15
+
16
+ from azure .profiles import KnownProfiles , ProfileDefinition
17
+ from azure .profiles .multiapiclient import MultiApiClientMixin
15
18
from .version import VERSION
16
- from .operations .record_sets_operations import RecordSetsOperations
17
- from .operations .zones_operations import ZonesOperations
18
- from . import models
19
19
20
20
21
21
class DnsManagementClientConfiguration (AzureConfiguration ):
@@ -26,8 +26,7 @@ class DnsManagementClientConfiguration(AzureConfiguration):
26
26
:param credentials: Credentials needed for the client to connect to Azure.
27
27
:type credentials: :mod:`A msrestazure Credentials
28
28
object<msrestazure.azure_active_directory>`
29
- :param subscription_id: Specifies the Azure subscription ID, which
30
- uniquely identifies the Microsoft Azure subscription.
29
+ :param subscription_id: The Microsoft Azure subscription ID.
31
30
:type subscription_id: str
32
31
:param str base_url: Service URL
33
32
"""
@@ -51,38 +50,99 @@ def __init__(
51
50
self .subscription_id = subscription_id
52
51
53
52
54
- class DnsManagementClient (object ):
53
+ class DnsManagementClient (MultiApiClientMixin , SDKClient ):
55
54
"""The DNS Management Client.
56
55
56
+ This ready contains multiple API versions, to help you deal with all Azure clouds
57
+ (Azure Stack, Azure Government, Azure China, etc.).
58
+ By default, uses latest API version available on public Azure.
59
+ For production, you should stick a particular api-version and/or profile.
60
+ The profile sets a mapping between the operation group and an API version.
61
+ The api-version parameter sets the default API version if the operation
62
+ group is not described in the profile.
63
+
57
64
:ivar config: Configuration for client.
58
65
:vartype config: DnsManagementClientConfiguration
59
66
60
- :ivar record_sets: RecordSets operations
61
- :vartype record_sets: azure.mgmt.dns.operations.RecordSetsOperations
62
- :ivar zones: Zones operations
63
- :vartype zones: azure.mgmt.dns.operations.ZonesOperations
64
-
65
67
:param credentials: Credentials needed for the client to connect to Azure.
66
68
:type credentials: :mod:`A msrestazure Credentials
67
69
object<msrestazure.azure_active_directory>`
68
- :param subscription_id: Specifies the Azure subscription ID, which
69
- uniquely identifies the Microsoft Azure subscription.
70
+ :param subscription_id: The Microsoft Azure subscription ID.
70
71
:type subscription_id: str
72
+ :param str api_version: API version to use if no profile is provided, or if
73
+ missing in profile.
71
74
:param str base_url: Service URL
75
+ :param profile: A profile definition, from KnownProfiles to dict.
76
+ :type profile: azure.profiles.KnownProfiles
72
77
"""
73
78
74
- def __init__ (
75
- self , credentials , subscription_id , base_url = None ):
79
+ DEFAULT_API_VERSION = '2018-03-01-preview'
80
+ _PROFILE_TAG = "azure.mgmt.dns.DnsManagementClient"
81
+ LATEST_PROFILE = ProfileDefinition ({
82
+ _PROFILE_TAG : {
83
+ None : DEFAULT_API_VERSION
84
+ }},
85
+ _PROFILE_TAG + " latest"
86
+ )
76
87
88
+ def __init__ (self , credentials , subscription_id , api_version = None , base_url = None , profile = KnownProfiles .default ):
77
89
self .config = DnsManagementClientConfiguration (credentials , subscription_id , base_url )
78
- self ._client = ServiceClient (self .config .credentials , self .config )
79
-
80
- client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
81
- self .api_version = '2018-03-01-preview'
82
- self ._serialize = Serializer (client_models )
83
- self ._deserialize = Deserializer (client_models )
84
-
85
- self .record_sets = RecordSetsOperations (
86
- self ._client , self .config , self ._serialize , self ._deserialize )
87
- self .zones = ZonesOperations (
88
- self ._client , self .config , self ._serialize , self ._deserialize )
90
+ super (DnsManagementClient , self ).__init__ (
91
+ credentials ,
92
+ self .config ,
93
+ api_version = api_version ,
94
+ profile = profile
95
+ )
96
+
97
+ ############ Generated from here ############
98
+
99
+ @classmethod
100
+ def _models_dict (cls , api_version ):
101
+ return {k : v for k , v in cls .models (api_version ).__dict__ .items () if isinstance (v , type )}
102
+
103
+ @classmethod
104
+ def models (cls , api_version = DEFAULT_API_VERSION ):
105
+ """Module depends on the API version:
106
+
107
+ * 2016-04-01: :mod:`v2016_04_01.models<azure.mgmt.dns.v2016_04_01.models>`
108
+ * 2018-03-01-preview: :mod:`v2018_03_01_preview.models<azure.mgmt.dns.v2018_03_01_preview.models>`
109
+ """
110
+ if api_version == '2016-04-01' :
111
+ from .v2016_04_01 import models
112
+ return models
113
+ elif api_version == '2018-03-01-preview' :
114
+ from .v2018_03_01_preview import models
115
+ return models
116
+ raise NotImplementedError ("APIVersion {} is not available" .format (api_version ))
117
+
118
+ @property
119
+ def record_sets (self ):
120
+ """Instance depends on the API version:
121
+
122
+ * 2016-04-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations>`
123
+ * 2018-03-01-preview: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations>`
124
+ """
125
+ api_version = self ._get_api_version ('record_sets' )
126
+ if api_version == '2016-04-01' :
127
+ from .v2016_04_01 .operations import RecordSetsOperations as OperationClass
128
+ elif api_version == '2018-03-01-preview' :
129
+ from .v2018_03_01_preview .operations import RecordSetsOperations 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 )))
133
+
134
+ @property
135
+ def zones (self ):
136
+ """Instance depends on the API version:
137
+
138
+ * 2016-04-01: :class:`ZonesOperations<azure.mgmt.dns.v2016_04_01.operations.ZonesOperations>`
139
+ * 2018-03-01-preview: :class:`ZonesOperations<azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations>`
140
+ """
141
+ api_version = self ._get_api_version ('zones' )
142
+ if api_version == '2016-04-01' :
143
+ from .v2016_04_01 .operations import ZonesOperations as OperationClass
144
+ elif api_version == '2018-03-01-preview' :
145
+ from .v2018_03_01_preview .operations import ZonesOperations as OperationClass
146
+ else :
147
+ raise NotImplementedError ("APIVersion {} is not available" .format (api_version ))
148
+ return OperationClass (self ._client , self .config , Serializer (self ._models_dict (api_version )), Deserializer (self ._models_dict (api_version )))
0 commit comments