From b8cb9bf9004ebe0568329c5bd596886005af7a50 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 13 Nov 2025 09:49:50 +0100 Subject: [PATCH 1/3] feat(TaskProcessing): Add next_task_batch endpoint Signed-off-by: Marcel Klehr --- nc_py_api/ex_app/providers/task_processing.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/nc_py_api/ex_app/providers/task_processing.py b/nc_py_api/ex_app/providers/task_processing.py index cd7fb1c2..4b28b978 100644 --- a/nc_py_api/ex_app/providers/task_processing.py +++ b/nc_py_api/ex_app/providers/task_processing.py @@ -142,6 +142,21 @@ def next_task(self, provider_ids: list[str], task_types: list[str]) -> dict[str, return r return {} + def next_task_batch(self, provider_ids: list[str], task_types: list[str], number_of_tasks: int) -> dict[str, typing.Any]: + """ + Get the next n task processing tasks from Nextcloud. + Available starting with Nextcloud 33 + Returns: {tasks: [{task: Task, provider: string}], has_more: bool} + """ + with contextlib.suppress(NextcloudException): + if r := self._session.ocs( + "GET", + "/ocs/v2.php/taskprocessing/tasks_provider/next_batch", + json={"providerIds": provider_ids, "taskTypeIds": task_types, "numberOfTasks": number_of_tasks}, + ): + return r + return {"tasks": [], "has_more": False} + def set_progress(self, task_id: int, progress: float) -> dict[str, typing.Any]: """Report new progress value of the task to Nextcloud. Progress should be in range from 0.0 to 100.0.""" with contextlib.suppress(NextcloudException): @@ -220,6 +235,21 @@ async def next_task(self, provider_ids: list[str], task_types: list[str]) -> dic return r return {} + async def next_task_batch(self, provider_ids: list[str], task_types: list[str], number_of_tasks: int) -> dict[str, typing.Any]: + """ + Get the next n task processing tasks from Nextcloud. + Available starting with Nextcloud 33 + Returns: {tasks: [{task: Task, provider: string}], has_more: bool} + """ + with contextlib.suppress(NextcloudException): + if r := await self._session.ocs( + "GET", + "/ocs/v2.php/taskprocessing/tasks_provider/next_batch", + json={"providerIds": provider_ids, "taskTypeIds": task_types, "numberOfTasks": number_of_tasks}, + ): + return r + return {"tasks": [], "has_more": False} + async def set_progress(self, task_id: int, progress: float) -> dict[str, typing.Any]: """Report new progress value of the task to Nextcloud. Progress should be in range from 0.0 to 100.0.""" with contextlib.suppress(NextcloudException): From 48ac21617b27369085f0c9060003dd14d257d017 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:00:12 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- nc_py_api/ex_app/providers/task_processing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nc_py_api/ex_app/providers/task_processing.py b/nc_py_api/ex_app/providers/task_processing.py index 4b28b978..3d206cab 100644 --- a/nc_py_api/ex_app/providers/task_processing.py +++ b/nc_py_api/ex_app/providers/task_processing.py @@ -142,7 +142,9 @@ def next_task(self, provider_ids: list[str], task_types: list[str]) -> dict[str, return r return {} - def next_task_batch(self, provider_ids: list[str], task_types: list[str], number_of_tasks: int) -> dict[str, typing.Any]: + def next_task_batch( + self, provider_ids: list[str], task_types: list[str], number_of_tasks: int + ) -> dict[str, typing.Any]: """ Get the next n task processing tasks from Nextcloud. Available starting with Nextcloud 33 @@ -235,7 +237,9 @@ async def next_task(self, provider_ids: list[str], task_types: list[str]) -> dic return r return {} - async def next_task_batch(self, provider_ids: list[str], task_types: list[str], number_of_tasks: int) -> dict[str, typing.Any]: + async def next_task_batch( + self, provider_ids: list[str], task_types: list[str], number_of_tasks: int + ) -> dict[str, typing.Any]: """ Get the next n task processing tasks from Nextcloud. Available starting with Nextcloud 33 From 1955ffb1e0fbc45ffd596aead9dc6fac685cdca0 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 13 Nov 2025 13:00:57 +0100 Subject: [PATCH 3/3] fix: Fix lint issue Signed-off-by: Marcel Klehr --- nc_py_api/ex_app/providers/task_processing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nc_py_api/ex_app/providers/task_processing.py b/nc_py_api/ex_app/providers/task_processing.py index 3d206cab..8f5a54eb 100644 --- a/nc_py_api/ex_app/providers/task_processing.py +++ b/nc_py_api/ex_app/providers/task_processing.py @@ -145,8 +145,8 @@ def next_task(self, provider_ids: list[str], task_types: list[str]) -> dict[str, def next_task_batch( self, provider_ids: list[str], task_types: list[str], number_of_tasks: int ) -> dict[str, typing.Any]: - """ - Get the next n task processing tasks from Nextcloud. + """Get the next n task processing tasks from Nextcloud. + Available starting with Nextcloud 33 Returns: {tasks: [{task: Task, provider: string}], has_more: bool} """ @@ -240,8 +240,8 @@ async def next_task(self, provider_ids: list[str], task_types: list[str]) -> dic async def next_task_batch( self, provider_ids: list[str], task_types: list[str], number_of_tasks: int ) -> dict[str, typing.Any]: - """ - Get the next n task processing tasks from Nextcloud. + """Get the next n task processing tasks from Nextcloud. + Available starting with Nextcloud 33 Returns: {tasks: [{task: Task, provider: string}], has_more: bool} """