|
3 | 3 | import dataclasses |
4 | 4 |
|
5 | 5 | from ._misc import clear_from_params_empty # , require_capabilities |
6 | | -from ._session import AsyncNcSessionBasic, NcSessionBasic |
| 6 | +from ._session import AppConfig, AsyncNcSessionBasic, NcSessionBasic |
7 | 7 |
|
8 | 8 |
|
9 | 9 | @dataclasses.dataclass |
@@ -140,6 +140,13 @@ def update( |
140 | 140 | def unregister(self, webhook_id: int) -> bool: |
141 | 141 | return self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}") |
142 | 142 |
|
| 143 | + def unregister_all(self, appid: str = "") -> int: |
| 144 | + if not appid and isinstance(self._session.cfg, AppConfig): |
| 145 | + appid = self._session.cfg.app_name |
| 146 | + else: |
| 147 | + raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.") |
| 148 | + return self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}") |
| 149 | + |
143 | 150 |
|
144 | 151 | class _AsyncWebhooksAPI: |
145 | 152 | """The class provides the async application management API on the Nextcloud server.""" |
@@ -208,3 +215,10 @@ async def update( |
208 | 215 |
|
209 | 216 | async def unregister(self, webhook_id: int) -> bool: |
210 | 217 | return await self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}") |
| 218 | + |
| 219 | + async def unregister_all(self, appid: str = "") -> int: |
| 220 | + if not appid and isinstance(self._session.cfg, AppConfig): |
| 221 | + appid = self._session.cfg.app_name |
| 222 | + else: |
| 223 | + raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.") |
| 224 | + return await self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}") |
0 commit comments