Skip to content

Commit

Permalink
Add method Client.restoreData
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed Nov 1, 2024
1 parent e389d11 commit 4902585
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/src/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ manages the interaction with an ICAT service as a client.

.. automethod:: deleteData

.. automethod:: restoreData

.. _ICAT SOAP Manual: https://repo.icatproject.org/site/icat/server/4.10.0/soap.html
35 changes: 35 additions & 0 deletions src/icat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,5 +1000,40 @@ def deleteData(self, objs):
objs = DataSelection(objs)
self.ids.delete(objs)

def restoreData(self, objs):
"""Request IDS to restore data.
Check the status of the data, request a restore if needed and
wait for the restore to complete.
:param objs: either a dict having some of the keys
`investigationIds`, `datasetIds`, and `datafileIds`
with a list of object ids as value respectively, or a list
of entity objects, or a data selection.
:type objs: :class:`dict`, :class:`list` of
:class:`icat.entity.Entity`, or
:class:`icat.ids.DataSelection`
.. versionadded:: 1.6.0
"""
if not self.ids:
raise RuntimeError("no IDS.")
if not isinstance(objs, DataSelection):
objs = DataSelection(objs)
while True:
self.autoRefresh()
status = self.ids.getStatus(objs)
if status == "ONLINE":
break
elif status == "RESTORING":
pass
elif status == "ARCHIVED":
self.ids.restore(objs)
else:
# Should never happen
raise IDSResponseError("unexpected response from "
"IDS getStatus() call: %s" % status)
time.sleep(30)


atexit.register(Client.cleanupall)

0 comments on commit 4902585

Please sign in to comment.