|
1 | 1 | """Nextcloud class providing access to all API endpoints."""
|
2 | 2 |
|
| 3 | +import contextlib |
3 | 4 | import typing
|
4 | 5 | from abc import ABC
|
5 | 6 |
|
@@ -333,6 +334,13 @@ def __init__(self, **kwargs):
|
333 | 334 | self.events_listener = EventsListenerAPI(self._session)
|
334 | 335 | self.occ_commands = OccCommandsAPI(self._session)
|
335 | 336 |
|
| 337 | + @property |
| 338 | + def enabled_state(self) -> bool: |
| 339 | + """Returns ``True`` if ExApp is enabled, ``False`` otherwise.""" |
| 340 | + with contextlib.suppress(Exception): |
| 341 | + return bool(self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state")) |
| 342 | + return False |
| 343 | + |
336 | 344 | def log(self, log_lvl: LogLvl, content: str) -> None:
|
337 | 345 | """Writes log to the Nextcloud log file."""
|
338 | 346 | if self.check_capabilities("app_api"):
|
@@ -456,6 +464,13 @@ def __init__(self, **kwargs):
|
456 | 464 | self.events_listener = AsyncEventsListenerAPI(self._session)
|
457 | 465 | self.occ_commands = AsyncOccCommandsAPI(self._session)
|
458 | 466 |
|
| 467 | + @property |
| 468 | + async def enabled_state(self) -> bool: |
| 469 | + """Returns ``True`` if ExApp is enabled, ``False`` otherwise.""" |
| 470 | + with contextlib.suppress(Exception): |
| 471 | + return bool(await self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state")) |
| 472 | + return False |
| 473 | + |
459 | 474 | async def log(self, log_lvl: LogLvl, content: str) -> None:
|
460 | 475 | """Writes log to the Nextcloud log file."""
|
461 | 476 | if await self.check_capabilities("app_api"):
|
|
0 commit comments