@@ -237,6 +237,44 @@ def delete(self):
237237 )
238238 return FMFuture .from_resp (self .client , future )
239239
240+ def get_initial_password (self ):
241+ """
242+ Get the initial DSS admin password.
243+
244+ Can only be called once
245+
246+ :return: a password for the 'admin' user.
247+ """
248+ return self .client ._perform_tenant_json (
249+ "GET" , "/instances/%s/actions/get-initial-password" % self .id
250+ )
251+
252+ def reset_user_password (self , username , password ):
253+ """
254+ Reset the password for a user on the DSS instance
255+
256+ :param string username: login
257+ :param string password: new password
258+ :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the password reset process
259+ :rtype: :class:`~dataikuapi.fm.future.FMFuture`
260+ """
261+ future = self .client ._perform_tenant_json (
262+ "GET" , "/instances/%s/actions/reset-user-password" % self .id , params = { 'userName' :username , 'password' :password }
263+ )
264+ return FMFuture .from_resp (self .client , future )
265+
266+ def replay_setup_actions (self ):
267+ """
268+ Replay the setup actions on the DSS instance
269+
270+ :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the replay process
271+ :rtype: :class:`~dataikuapi.fm.future.FMFuture`
272+ """
273+ future = self .client ._perform_tenant_json (
274+ "GET" , "/instances/%s/actions/replay-setup-actions" % self .id
275+ )
276+ return FMFuture .from_resp (self .client , future )
277+
240278 def set_automated_snapshots (self , enable , period , keep = 0 ):
241279 """
242280 Set the automated snapshots policy for this instance
@@ -262,6 +300,43 @@ def set_custom_certificate(self, pem_data):
262300 return self
263301
264302
303+ ########################################################
304+ # Snapshots
305+ ########################################################
306+
307+ def list_snapshots (self ):
308+ """
309+ List all snapshots of this instance
310+
311+ :return: list of snapshots
312+ :rtype: list of :class:`dataikuapi.fm.instances.FMSnapshot`
313+ """
314+ snapshots = self .client ._perform_tenant_json ("GET" , "/instances/%s/snapshots" % self .id )
315+ return [FMSnapshot (self .client , self .id , x ["id" ], x ) for x in snapshots ]
316+
317+ def get_snapshot (self , snapshot_id ):
318+ """
319+ Get a snapshot of this instance
320+
321+ :param str snapshot_id: identifier of the snapshot
322+
323+ :return: Snapshot
324+ :rtype: :class:`dataikuapi.fm.instances.FMSnapshot`
325+ """
326+ return FMSnapshot (self .client , self .id , snapshot_id )
327+
328+ def snapshot (self , reason_for_snapshot = None ):
329+ """
330+ Create a snapshot of the DSS instance
331+
332+ :return: Snapshot
333+ :rtype: :class:`dataikuapi.fm.instances.FMSnapshot`
334+ """
335+ snapshot = self .client ._perform_tenant_json (
336+ "POST" , "/instances/%s/snapshots" % self .id , params = { "reasonForSnapshot" :reason_for_snapshot }
337+ )
338+ return FMSnapshot (self .client , self .id , snapshot ["id" ], snapshot )
339+
265340class FMAWSInstance (FMInstance ):
266341 def set_elastic_ip (self , enable , elasticip_allocation_id ):
267342 """
@@ -303,3 +378,53 @@ class FMInstanceStatus(dict):
303378 def __init__ (self , data ):
304379 """Do not call this directly, use :meth:`FMInstance.get_status`"""
305380 super (FMInstanceStatus , self ).__init__ (data )
381+
382+
383+ class FMSnapshot (object ):
384+ """
385+ A handle to interact with a snapshot of a DSS instance.
386+ Do not create this directly, use :meth:`FMInstance.snapshot`
387+ """
388+
389+ def __init__ (self , client , instance_id , snapshot_id , snapshot_data = None ):
390+ self .client = client
391+ self .instance_id = instance_id
392+ self .snapshot_id = snapshot_id
393+ self .snapshot_data = snapshot_data
394+
395+ def get_info (self ):
396+ """
397+ Get the information about this snapshot
398+
399+ :return: a dict
400+ """
401+ if self .snapshot_data is None :
402+ self .snapshot_data = self .client ._perform_tenant_json (
403+ "GET" , "/instances/%s/snapshots/%s" % (self .instance_id , self .snapshot_id )
404+ )
405+ return self .snapshot_data
406+
407+ def reprovision (self ):
408+ """
409+ Reprovision the physical DSS instance from this snapshot
410+
411+ :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the reprovision process
412+ :rtype: :class:`~dataikuapi.fm.future.FMFuture`
413+ """
414+ future = self .client ._perform_tenant_json (
415+ "POST" , "/instances/%s/snapshots/%s/reprovision" % (self .instance_id , self .snapshot_id )
416+ )
417+ return FMFuture .from_resp (self .client , future )
418+
419+ def delete (self ):
420+ """
421+ Delete the snapshot
422+
423+ :return: A :class:`~dataikuapi.fm.future.FMFuture` representing the deletion process
424+ :rtype: :class:`~dataikuapi.fm.future.FMFuture`
425+ """
426+ future = self .client ._perform_tenant_json (
427+ "DELETE" , "/instances/%s/snapshots/%s" % (self .instance_id , self .snapshot_id )
428+ )
429+ return FMFuture .from_resp (self .client , future )
430+
0 commit comments