Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added enabled_state property for NextcloudApp #268

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
15 changes: 15 additions & 0 deletions nc_py_api/nextcloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Nextcloud class providing access to all API endpoints."""

import contextlib
import typing
from abc import ABC

Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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"):
Expand Down