Skip to content

Commit 16429c1

Browse files
committed
added "webhooks.unregister_all"
Signed-off-by: Alexander Piskun <[email protected]>
1 parent 0750270 commit 16429c1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.18.0 - 2024-10-09]
6+
7+
### Added
8+
9+
- New `webhooks.unregister_all` method.
10+
511
## [0.17.1 - 2024-09-06]
612

713
### Added

nc_py_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.17.1"
3+
__version__ = "0.18.0.dev0"

nc_py_api/webhooks.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dataclasses
44

55
from ._misc import clear_from_params_empty # , require_capabilities
6-
from ._session import AsyncNcSessionBasic, NcSessionBasic
6+
from ._session import AppConfig, AsyncNcSessionBasic, NcSessionBasic
77

88

99
@dataclasses.dataclass
@@ -140,6 +140,13 @@ def update(
140140
def unregister(self, webhook_id: int) -> bool:
141141
return self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")
142142

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+
143150

144151
class _AsyncWebhooksAPI:
145152
"""The class provides the async application management API on the Nextcloud server."""
@@ -208,3 +215,10 @@ async def update(
208215

209216
async def unregister(self, webhook_id: int) -> bool:
210217
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

Comments
 (0)