diff --git a/CHANGELOG.md b/CHANGELOG.md index fae782e6..7c15b5c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,14 @@ All notable changes to this project will be documented in this file. -## [0.14.0 - 2024-05-31] +## [0.14.0 - 2024-07-0X] ### Added - `LoginFlowV2` implementation by @blvdek #255 -- NextcloudApp: `nc.ui.files_dropdown_menu.register_ex` to register new version of FileActions(AppAPI 2.6.0+) #252 - `files.get_tags` function to get all tags assigned to the file or directory. #260 +- NextcloudApp: `nc.ui.files_dropdown_menu.register_ex` to register new version of FileActions(AppAPI 2.6.0+) #252 +- NextcloudApp: `enabled_state` property to check if current ExApp is disabled or enabled. ## [0.13.0 - 2024-04-28] diff --git a/nc_py_api/nextcloud.py b/nc_py_api/nextcloud.py index f33b91a8..889b7c51 100644 --- a/nc_py_api/nextcloud.py +++ b/nc_py_api/nextcloud.py @@ -1,5 +1,6 @@ """Nextcloud class providing access to all API endpoints.""" +import contextlib import typing from abc import ABC @@ -333,6 +334,13 @@ def __init__(self, **kwargs): self.events_listener = EventsListenerAPI(self._session) self.occ_commands = OccCommandsAPI(self._session) + @property + def enabled_state(self) -> bool: + """Returns ``True`` if ExApp is enabled, ``False`` otherwise.""" + with contextlib.suppress(Exception): + return bool(self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state")) + return False + def log(self, log_lvl: LogLvl, content: str) -> None: """Writes log to the Nextcloud log file.""" if self.check_capabilities("app_api"): @@ -456,6 +464,13 @@ def __init__(self, **kwargs): self.events_listener = AsyncEventsListenerAPI(self._session) self.occ_commands = AsyncOccCommandsAPI(self._session) + @property + async def enabled_state(self) -> bool: + """Returns ``True`` if ExApp is enabled, ``False`` otherwise.""" + with contextlib.suppress(Exception): + return bool(await self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state")) + return False + async def log(self, log_lvl: LogLvl, content: str) -> None: """Writes log to the Nextcloud log file.""" if await self.check_capabilities("app_api"):