Skip to content

Commit

Permalink
[#44] adding new method to move aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdash committed Mar 29, 2023
1 parent 069631e commit 6f036f1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions hsclient/hydroshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,31 @@ def aggregation_remove(self, aggregation: Aggregation) -> None:
aggregation._hs_session.post(path, status_code=200)
aggregation.refresh()

@refresh
def aggregation_move(self, aggregation: Aggregation, dst_path: str = "") -> None:
"""
Moves an aggregation from its current location to another folder in HydroShare.
:param aggregation: The aggregation object to move
:param dst_path: The target file path to move the aggregation to
:return: None
"""
path = urljoin(
aggregation._hsapi_path,
aggregation.metadata.type.value + "LogicalFile",
aggregation.main_file_path,
"functions",
"move-file-type",
dst_path,
)
response = aggregation._hs_session.post(path, status_code=200)
json_response = response.json()
task_id = json_response['id']
status = json_response['status']
if status in ("Not ready", "progress"):
while aggregation._hs_session.check_task(task_id) != 'true':
time.sleep(1)
aggregation.refresh()

@refresh
def aggregation_delete(self, aggregation: Aggregation) -> None:
"""
Expand Down

0 comments on commit 6f036f1

Please sign in to comment.