11from enum import Enum
22from .future import FMFuture
33
4+
45class FMInstanceCreator (object ):
5- def __init__ (self , client , label , instance_settings_template_id , virtual_network_id , image_id ):
6+ def __init__ (
7+ self , client , label , instance_settings_template_id , virtual_network_id , image_id
8+ ):
69 """
710 Helper to create a DSS Instance
811
@@ -30,7 +33,9 @@ def with_dss_node_type(self, dss_node_type):
3033 :rtype: :class:`dataikuapi.fm.instances.FMInstanceCreator`
3134 """
3235 if dss_node_type not in ["design" , "automation" , "deployer" ]:
33- raise ValueError ("Only \" design\" , \" automation\" or \" deployer\" dss_node_type are supported" )
36+ raise ValueError (
37+ 'Only "design", "automation" or "deployer" dss_node_type are supported'
38+ )
3439 self .data ["dssNodeType" ] = dss_node_type
3540 return self
3641
@@ -44,7 +49,15 @@ def with_cloud_instance_type(self, cloud_instance_type):
4449 self .data ["cloudInstanceType" ] = cloud_instance_type
4550 return self
4651
47- def with_data_volume_options (self , data_volume_type = None , data_volume_size = None , data_volume_size_max = None , data_volume_IOPS = None , data_volume_encryption = None , data_volume_encryption_key = None ):
52+ def with_data_volume_options (
53+ self ,
54+ data_volume_type = None ,
55+ data_volume_size = None ,
56+ data_volume_size_max = None ,
57+ data_volume_IOPS = None ,
58+ data_volume_encryption = None ,
59+ data_volume_encryption_key = None ,
60+ ):
4861 """
4962 Set the options of the data volume to use with the DSS Instance
5063
@@ -57,7 +70,9 @@ def with_data_volume_options(self, data_volume_type=None, data_volume_size=None,
5770 :rtype: :class:`dataikuapi.fm.instances.FMInstanceCreator`
5871 """
5972 if type (data_volume_encryption ) is not FMInstanceEncryptionMode :
60- raise TypeError ("data_volume encryption needs to be of type FMInstanceEncryptionMode" )
73+ raise TypeError (
74+ "data_volume encryption needs to be of type FMInstanceEncryptionMode"
75+ )
6176
6277 self .data ["dataVolumeType" ] = data_volume_type
6378 self .data ["dataVolumeSizeGB" ] = data_volume_size
@@ -89,7 +104,12 @@ def with_fm_tags(self, fm_tags):
89104
90105
91106class FMAWSInstanceCreator (FMInstanceCreator ):
92- def with_aws_root_volume_options (self , aws_root_volume_size = None , aws_root_volume_type = None , aws_root_volume_IOPS = None ):
107+ def with_aws_root_volume_options (
108+ self ,
109+ aws_root_volume_size = None ,
110+ aws_root_volume_type = None ,
111+ aws_root_volume_IOPS = None ,
112+ ):
93113 """
94114 Set the options of the root volume of the DSS Instance
95115
@@ -110,7 +130,9 @@ def create(self):
110130 :return: Created DSS Instance
111131 :rtype: :class:`dataikuapi.fm.instances.FMAWSInstance`
112132 """
113- instance = self .client ._perform_tenant_json ("POST" , "/instances" , body = self .data )
133+ instance = self .client ._perform_tenant_json (
134+ "POST" , "/instances" , body = self .data
135+ )
114136 return FMAWSInstance (self .client , instance )
115137
116138
@@ -122,7 +144,9 @@ def create(self):
122144 :return: Created DSS Instance
123145 :rtype: :class:`dataikuapi.fm.instances.FMAzureInstance`
124146 """
125- instance = self .client ._perform_tenant_json ("POST" , "/instances" , body = self .data )
147+ instance = self .client ._perform_tenant_json (
148+ "POST" , "/instances" , body = self .data
149+ )
126150 return FMAzureInstance (self .client , instance )
127151
128152
@@ -131,10 +155,11 @@ class FMInstance(object):
131155 A handle to interact with a DSS instance.
132156 Do not create this directly, use :meth:`FMClient.get_instance` or :meth: `FMClient.new_instance_creator`
133157 """
158+
134159 def __init__ (self , client , instance_data ):
135- self .client = client
160+ self .client = client
136161 self .instance_data = instance_data
137- self .id = instance_data ['id' ]
162+ self .id = instance_data ["id" ]
138163
139164 def reprovision (self ):
140165 """
@@ -143,7 +168,9 @@ def reprovision(self):
143168 :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the reprovision process
144169 :rtype: :class:`~dataikuapi.fm.future.FMFuture`
145170 """
146- future = self .client ._perform_tenant_json ("GET" , "/instances/%s/actions/reprovision" % self .id )
171+ future = self .client ._perform_tenant_json (
172+ "GET" , "/instances/%s/actions/reprovision" % self .id
173+ )
147174 return FMFuture .from_resp (self .client , future )
148175
149176 def deprovision (self ):
@@ -153,7 +180,9 @@ def deprovision(self):
153180 :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the deprovision process
154181 :rtype: :class:`~dataikuapi.fm.future.FMFuture`
155182 """
156- future = self .client ._perform_tenant_json ("GET" , "/instances/%s/actions/deprovision" % self .id )
183+ future = self .client ._perform_tenant_json (
184+ "GET" , "/instances/%s/actions/deprovision" % self .id
185+ )
157186 return FMFuture .from_resp (self .client , future )
158187
159188 def restart_dss (self ):
@@ -163,21 +192,29 @@ def restart_dss(self):
163192 :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the restart process
164193 :rtype: :class:`~dataikuapi.fm.future.FMFuture`
165194 """
166- future = self .client ._perform_tenant_json ("GET" , "/instances/%s/actions/restart-dss" % self .id )
195+ future = self .client ._perform_tenant_json (
196+ "GET" , "/instances/%s/actions/restart-dss" % self .id
197+ )
167198 return FMFuture .from_resp (self .client , future )
168199
169200 def save (self ):
170201 """
171202 Update the Instance.
172203 """
173- self .client ._perform_tenant_empty ("PUT" , "/instances/%s" % self .id , body = self .instance_data )
174- self .instance_data = self .client ._perform_tenant_json ("GET" , "/instances/%s" % self .id )
204+ self .client ._perform_tenant_empty (
205+ "PUT" , "/instances/%s" % self .id , body = self .instance_data
206+ )
207+ self .instance_data = self .client ._perform_tenant_json (
208+ "GET" , "/instances/%s" % self .id
209+ )
175210
176211 def get_status (self ):
177212 """
178213 Get the physical DSS instance's status
179214 """
180- status = self .client ._perform_tenant_json ("GET" , "/instances/%s/status" % self .id )
215+ status = self .client ._perform_tenant_json (
216+ "GET" , "/instances/%s/status" % self .id
217+ )
181218 return FMInstanceStatus (status )
182219
183220 def delete (self ):
@@ -187,7 +224,9 @@ def delete(self):
187224 :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the deletion process
188225 :rtype: :class:`~dataikuapi.fm.future.FMFuture`
189226 """
190- future = self .client ._perform_tenant_json ("GET" , "/instances/%s/actions/delete" % self .id )
227+ future = self .client ._perform_tenant_json (
228+ "GET" , "/instances/%s/actions/delete" % self .id
229+ )
191230 return FMFuture .from_resp (self .client , future )
192231
193232 def set_automated_snapshots (self , enable , period , keep = 0 ):
@@ -198,9 +237,9 @@ def set_automated_snapshots(self, enable, period, keep=0):
198237 :param int period: The time period between 2 snapshot in hours
199238 :param int keep: Optional, the number of snapshot to keep. Use 0 to keep all snapshots. Defaults to 0.
200239 """
201- self .instance_data [' enableAutomatedSnapshot' ] = enable
202- self .instance_data [' automatedSnapshotPeriod' ] = period
203- self .instance_data [' automatedSnapshotRetention' ] = keep
240+ self .instance_data [" enableAutomatedSnapshot" ] = enable
241+ self .instance_data [" automatedSnapshotPeriod" ] = period
242+ self .instance_data [" automatedSnapshotRetention" ] = keep
204243 self .save ()
205244
206245 def set_custom_certificate (self , pem_data ):
@@ -211,7 +250,7 @@ def set_custom_certificate(self, pem_data):
211250
212251 param: str pem_data: The SSL certificate
213252 """
214- self .instance_data [' sslCertificatePEM' ] = pem_data
253+ self .instance_data [" sslCertificatePEM" ] = pem_data
215254 self .save ()
216255
217256
@@ -223,8 +262,8 @@ def set_elastic_ip(self, enable, elasticip_allocation_id):
223262 :param boolan enable: Enable the elastic ip allocation
224263 :param str elaticip_allocation_id: AWS ElasticIP allocation ID
225264 """
226- self .instance_data [' awsAssignElasticIP' ] = enable
227- self .instance_data [' awsElasticIPAllocationId' ] = elasticip_allocation_id
265+ self .instance_data [" awsAssignElasticIP" ] = enable
266+ self .instance_data [" awsElasticIPAllocationId" ] = elasticip_allocation_id
228267 self .save ()
229268
230269
@@ -236,8 +275,8 @@ def set_elastic_ip(self, enable, public_ip_id):
236275 :param boolan enable: Enable the elastic ip allocation
237276 :param str public_ip_id: Azure Public IP ID
238277 """
239- self .instance_data [' azureAssignElasticIP' ] = enable
240- self .instance_data [' azurePublicIPId' ] = public_ip_id
278+ self .instance_data [" azureAssignElasticIP" ] = enable
279+ self .instance_data [" azurePublicIPId" ] = public_ip_id
241280 self .save ()
242281
243282
@@ -252,6 +291,7 @@ class FMInstanceStatus(dict):
252291 """A class holding read-only information about an Instance.
253292 This class should not be created directly. Instead, use :meth:`FMInstance.get_info`
254293 """
294+
255295 def __init__ (self , data ):
256296 """Do not call this directly, use :meth:`FMInstance.get_status`"""
257297 super (FMInstanceStatus , self ).__init__ (data )
0 commit comments