Skip to content

Commit 22cbea9

Browse files
feat(TaskProcessing): Allow defining custom task types (#270)
Counter part for nextcloud/app_api#324 --------- Signed-off-by: provokateurin <[email protected]>
1 parent 000819d commit 22cbea9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ jobs:
847847
PHP_CLI_SERVER_WORKERS=2 php -S localhost:8080 &
848848
849849
- name: Enable Notes
850-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
850+
if: ${{ !startsWith(matrix.nextcloud, 'stable27') && !startsWith(matrix.nextcloud, 'master') }}
851851
run: ./occ app:enable notes
852852

853853
- name: Enable Files Locking

nc_py_api/ex_app/providers/task_processing.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import typing
66

77
from ..._exceptions import NextcloudException, NextcloudExceptionNotFound
8-
from ..._misc import require_capabilities
8+
from ..._misc import clear_from_params_empty, require_capabilities
99
from ..._session import AsyncNcSessionApp, NcSessionApp
1010

1111
_EP_SUFFIX: str = "ai_provider/task_processing"
@@ -43,14 +43,18 @@ class _TaskProcessingProviderAPI:
4343
def __init__(self, session: NcSessionApp):
4444
self._session = session
4545

46-
def register(self, name: str, display_name: str, task_type: str) -> None:
46+
def register(
47+
self, name: str, display_name: str, task_type: str, custom_task_type: dict[str, typing.Any] | None = None
48+
) -> None:
4749
"""Registers or edit the TaskProcessing provider."""
4850
require_capabilities("app_api", self._session.capabilities)
4951
params = {
5052
"name": name,
5153
"displayName": display_name,
5254
"taskType": task_type,
55+
"customTaskType": custom_task_type,
5356
}
57+
clear_from_params_empty(["customTaskType"], params)
5458
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
5559

5660
def unregister(self, name: str, not_fail=True) -> None:
@@ -118,14 +122,18 @@ class _AsyncTaskProcessingProviderAPI:
118122
def __init__(self, session: AsyncNcSessionApp):
119123
self._session = session
120124

121-
async def register(self, name: str, display_name: str, task_type: str) -> None:
125+
async def register(
126+
self, name: str, display_name: str, task_type: str, custom_task_type: dict[str, typing.Any] | None = None
127+
) -> None:
122128
"""Registers or edit the TaskProcessing provider."""
123129
require_capabilities("app_api", await self._session.capabilities)
124130
params = {
125131
"name": name,
126132
"displayName": display_name,
127133
"taskType": task_type,
134+
"customTaskType": custom_task_type,
128135
}
136+
clear_from_params_empty(["customTaskType"], params)
129137
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
130138

131139
async def unregister(self, name: str, not_fail=True) -> None:

0 commit comments

Comments
 (0)