Skip to content

Commit

Permalink
added "webhooks.unregister_all"
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 committed Oct 9, 2024
1 parent 0750270 commit 16429c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [0.18.0 - 2024-10-09]

### Added

- New `webhooks.unregister_all` method.

## [0.17.1 - 2024-09-06]

### Added
Expand Down
2 changes: 1 addition & 1 deletion nc_py_api/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of nc_py_api."""

__version__ = "0.17.1"
__version__ = "0.18.0.dev0"
16 changes: 15 additions & 1 deletion nc_py_api/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses

from ._misc import clear_from_params_empty # , require_capabilities
from ._session import AsyncNcSessionBasic, NcSessionBasic
from ._session import AppConfig, AsyncNcSessionBasic, NcSessionBasic


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

def unregister_all(self, appid: str = "") -> int:
if not appid and isinstance(self._session.cfg, AppConfig):
appid = self._session.cfg.app_name
else:
raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.")
return self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}")


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

async def unregister(self, webhook_id: int) -> bool:
return await self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")

async def unregister_all(self, appid: str = "") -> int:
if not appid and isinstance(self._session.cfg, AppConfig):
appid = self._session.cfg.app_name
else:
raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.")
return await self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}")

0 comments on commit 16429c1

Please sign in to comment.