Skip to content

Update cancel_task to add clearUniqueId option #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scaleapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,23 @@ def get_task(self, task_id: str) -> Task:
endpoint = f"task/{task_id}"
return Task(self.api.get_request(endpoint), self)

def cancel_task(self, task_id: str) -> Task:
def cancel_task(self, task_id: str, clear_unique_id=False) -> Task:
"""Cancels a task and returns the associated task.
Raises a ScaleException if it has already been canceled.

Args:
task_id (str):
Task id
clear_unique_id (boolean):
Option to clear unique id when the task is deleted

Returns:
Task
"""
endpoint = f"task/{task_id}/cancel"
if clear_unique_id:
endpoint = f"task/{task_id}/cancel?clear_unique_id=true"
else:
endpoint = f"task/{task_id}/cancel"
return Task(self.api.post_request(endpoint), self)

def tasks(self, **kwargs) -> Tasklist:
Expand Down