|
5 | 5 | import typing |
6 | 6 |
|
7 | 7 | from ..._exceptions import NextcloudException, NextcloudExceptionNotFound |
8 | | -from ..._misc import require_capabilities |
| 8 | +from ..._misc import clear_from_params_empty, require_capabilities |
9 | 9 | from ..._session import AsyncNcSessionApp, NcSessionApp |
10 | 10 |
|
11 | 11 | _EP_SUFFIX: str = "ai_provider/task_processing" |
@@ -43,14 +43,18 @@ class _TaskProcessingProviderAPI: |
43 | 43 | def __init__(self, session: NcSessionApp): |
44 | 44 | self._session = session |
45 | 45 |
|
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: |
47 | 49 | """Registers or edit the TaskProcessing provider.""" |
48 | 50 | require_capabilities("app_api", self._session.capabilities) |
49 | 51 | params = { |
50 | 52 | "name": name, |
51 | 53 | "displayName": display_name, |
52 | 54 | "taskType": task_type, |
| 55 | + "customTaskType": custom_task_type, |
53 | 56 | } |
| 57 | + clear_from_params_empty(["customTaskType"], params) |
54 | 58 | self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params) |
55 | 59 |
|
56 | 60 | def unregister(self, name: str, not_fail=True) -> None: |
@@ -118,14 +122,18 @@ class _AsyncTaskProcessingProviderAPI: |
118 | 122 | def __init__(self, session: AsyncNcSessionApp): |
119 | 123 | self._session = session |
120 | 124 |
|
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: |
122 | 128 | """Registers or edit the TaskProcessing provider.""" |
123 | 129 | require_capabilities("app_api", await self._session.capabilities) |
124 | 130 | params = { |
125 | 131 | "name": name, |
126 | 132 | "displayName": display_name, |
127 | 133 | "taskType": task_type, |
| 134 | + "customTaskType": custom_task_type, |
128 | 135 | } |
| 136 | + clear_from_params_empty(["customTaskType"], params) |
129 | 137 | await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params) |
130 | 138 |
|
131 | 139 | async def unregister(self, name: str, not_fail=True) -> None: |
|
0 commit comments