Skip to content

Commit 9670ff2

Browse files
committed
feat(TaskProcessing): Add next_task_batch endpoint
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent d2eb66a commit 9670ff2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

nc_py_api/ex_app/providers/task_processing.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ def next_task(self, provider_ids: list[str], task_types: list[str]) -> dict[str,
142142
return r
143143
return {}
144144

145+
def next_task_batch(self, provider_ids: list[str], task_types: list[str], number_of_tasks: int) -> dict[str, typing.Any]:
146+
"""
147+
Get the next n task processing tasks from Nextcloud.
148+
Available starting with Nextcloud 33
149+
Returns: {tasks: [{task: Task, provider: string}], has_more: bool}
150+
"""
151+
with contextlib.suppress(NextcloudException):
152+
if r := self._session.ocs(
153+
"GET",
154+
"/ocs/v2.php/taskprocessing/tasks_provider/next_batch",
155+
json={"providerIds": provider_ids, "taskTypeIds": task_types, "numberOfTasks": number_of_tasks},
156+
):
157+
return r
158+
return {"tasks": [], "has_more": False}
159+
145160
def set_progress(self, task_id: int, progress: float) -> dict[str, typing.Any]:
146161
"""Report new progress value of the task to Nextcloud. Progress should be in range from 0.0 to 100.0."""
147162
with contextlib.suppress(NextcloudException):

0 commit comments

Comments
 (0)