nc-py-api 0.12.0__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/CHANGELOG.md +14 -1
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/PKG-INFO +16 -4
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_version.py +1 -1
- nc_py_api-0.13.0/nc_py_api/ex_app/events_listener.py +137 -0
- nc_py_api-0.13.0/nc_py_api/ex_app/occ_commands.py +153 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/files/__init__.py +2 -1
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/nextcloud.py +14 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/users.py +1 -1
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/pyproject.toml +1 -1
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/.gitignore +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/AUTHORS +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/LICENSE.txt +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/README.md +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/__init__.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_deffered_error.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_exceptions.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_misc.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_preferences.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_preferences_ex.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_session.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_talk_api.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/_theming.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/activity.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/apps.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/calendar.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/__init__.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/defs.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/integration_fastapi.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/misc.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/persist_transformers_cache.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/providers/__init__.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/providers/providers.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/providers/speech_to_text.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/providers/text_processing.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/providers/translations.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/__init__.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/files_actions.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/resources.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/settings.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/top_menu.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/ui/ui.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/ex_app/uvicorn_fastapi.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/files/_files.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/files/files.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/files/sharing.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/notes.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/notifications.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/options.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/talk.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/talk_bot.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/user_status.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/users_groups.py +0 -0
- {nc_py_api-0.12.0 → nc_py_api-0.13.0}/nc_py_api/weather_status.py +0 -0
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.13.0 - 2024-04-28]
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- NextcloudApp: `occ` commands registration API(AppAPI 2.5.0+). #247
|
|
10
|
+
- NextcloudApp: `Nodes` events listener registration API(AppAPI 2.5.0+). #249
|
|
11
|
+
|
|
12
|
+
## [0.12.1 - 2024-04-05]
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Incorrect `Display name` when creating user, which led to the parameter being ignored. #239 Thanks to @derekbuckley
|
|
17
|
+
|
|
5
18
|
## [0.12.0 - 2024-04-02]
|
|
6
19
|
|
|
7
20
|
Update with new features only for `NextcloudApp` class. #233
|
|
8
21
|
|
|
9
22
|
### Added
|
|
10
23
|
|
|
11
|
-
- `ex_app.get_computation_device` function for retrieving GPU type(only with AppAPI `2.
|
|
24
|
+
- `ex_app.get_computation_device` function for retrieving GPU type(only with AppAPI `2.5.0`+).
|
|
12
25
|
- `ex_app.integration_fastapi.fetch_models_task` are now public function, added `progress_init_start_value` param.
|
|
13
26
|
- Global authentication when used now sets `request.scope["username"]` for easy use.
|
|
14
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nc-py-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Nextcloud Python Framework
|
|
5
5
|
Project-URL: Changelog, https://github.com/cloud-py-api/nc_py_api/blob/main/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://cloud-py-api.github.io/nc_py_api/
|
|
@@ -38,13 +38,24 @@ Provides-Extra: app
|
|
|
38
38
|
Requires-Dist: uvicorn[standard]>=0.23.2; extra == 'app'
|
|
39
39
|
Provides-Extra: bench
|
|
40
40
|
Requires-Dist: matplotlib; extra == 'bench'
|
|
41
|
-
Requires-Dist: nc-py-api[app]; extra == 'bench'
|
|
42
41
|
Requires-Dist: numpy; extra == 'bench'
|
|
43
42
|
Requires-Dist: py-cpuinfo; extra == 'bench'
|
|
43
|
+
Requires-Dist: uvicorn[standard]>=0.23.2; extra == 'bench'
|
|
44
44
|
Provides-Extra: calendar
|
|
45
45
|
Requires-Dist: caldav==1.3.6; extra == 'calendar'
|
|
46
46
|
Provides-Extra: dev
|
|
47
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: caldav==1.3.6; extra == 'dev'
|
|
48
|
+
Requires-Dist: coverage; extra == 'dev'
|
|
49
|
+
Requires-Dist: huggingface-hub; extra == 'dev'
|
|
50
|
+
Requires-Dist: matplotlib; extra == 'dev'
|
|
51
|
+
Requires-Dist: numpy; extra == 'dev'
|
|
52
|
+
Requires-Dist: pillow; extra == 'dev'
|
|
53
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
54
|
+
Requires-Dist: py-cpuinfo; extra == 'dev'
|
|
55
|
+
Requires-Dist: pylint; extra == 'dev'
|
|
56
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
57
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
58
|
+
Requires-Dist: uvicorn[standard]>=0.23.2; extra == 'dev'
|
|
48
59
|
Provides-Extra: dev-min
|
|
49
60
|
Requires-Dist: coverage; extra == 'dev-min'
|
|
50
61
|
Requires-Dist: huggingface-hub; extra == 'dev-min'
|
|
@@ -55,12 +66,13 @@ Requires-Dist: pytest; extra == 'dev-min'
|
|
|
55
66
|
Requires-Dist: pytest-asyncio; extra == 'dev-min'
|
|
56
67
|
Provides-Extra: docs
|
|
57
68
|
Requires-Dist: autodoc-pydantic>=2.0.1; extra == 'docs'
|
|
58
|
-
Requires-Dist:
|
|
69
|
+
Requires-Dist: caldav==1.3.6; extra == 'docs'
|
|
59
70
|
Requires-Dist: sphinx-copybutton; extra == 'docs'
|
|
60
71
|
Requires-Dist: sphinx-inline-tabs; extra == 'docs'
|
|
61
72
|
Requires-Dist: sphinx-issues>=3.0.1; extra == 'docs'
|
|
62
73
|
Requires-Dist: sphinx-rtd-theme>=1; extra == 'docs'
|
|
63
74
|
Requires-Dist: sphinx>=6.2; extra == 'docs'
|
|
75
|
+
Requires-Dist: uvicorn[standard]>=0.23.2; extra == 'docs'
|
|
64
76
|
Description-Content-Type: text/markdown
|
|
65
77
|
|
|
66
78
|
<p align="center">
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Nextcloud API for registering Events listeners for ExApps."""
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from .._exceptions import NextcloudExceptionNotFound
|
|
6
|
+
from .._misc import require_capabilities
|
|
7
|
+
from .._session import AsyncNcSessionApp, NcSessionApp
|
|
8
|
+
|
|
9
|
+
_EP_SUFFIX: str = "events_listener"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclasses.dataclass
|
|
13
|
+
class EventsListener:
|
|
14
|
+
"""EventsListener description."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, raw_data: dict):
|
|
17
|
+
self._raw_data = raw_data
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def event_type(self) -> str:
|
|
21
|
+
"""Main type of event, e.g. ``node_event``."""
|
|
22
|
+
return self._raw_data["event_type"]
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def event_subtypes(self) -> str:
|
|
26
|
+
"""Subtypes for which fire event, e.g. ``NodeCreatedEvent``, ``NodeDeletedEvent``."""
|
|
27
|
+
return self._raw_data["event_subtypes"]
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def action_handler(self) -> str:
|
|
31
|
+
"""Relative ExApp url which will be called by Nextcloud."""
|
|
32
|
+
return self._raw_data["action_handler"]
|
|
33
|
+
|
|
34
|
+
def __repr__(self):
|
|
35
|
+
return f"<{self.__class__.__name__} event_type={self.event_type}, handler={self.action_handler}>"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class EventsListenerAPI:
|
|
39
|
+
"""API for registering Events listeners, avalaible as **nc.events_handler.<method>**."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, session: NcSessionApp):
|
|
42
|
+
self._session = session
|
|
43
|
+
|
|
44
|
+
def register(
|
|
45
|
+
self,
|
|
46
|
+
event_type: str,
|
|
47
|
+
callback_url: str,
|
|
48
|
+
event_subtypes: list[str] | None = None,
|
|
49
|
+
) -> None:
|
|
50
|
+
"""Registers or edits the events listener."""
|
|
51
|
+
if event_subtypes is None:
|
|
52
|
+
event_subtypes = []
|
|
53
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
54
|
+
params = {
|
|
55
|
+
"eventType": event_type,
|
|
56
|
+
"actionHandler": callback_url,
|
|
57
|
+
"eventSubtypes": event_subtypes,
|
|
58
|
+
}
|
|
59
|
+
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
60
|
+
|
|
61
|
+
def unregister(self, event_type: str, not_fail=True) -> None:
|
|
62
|
+
"""Removes the events listener."""
|
|
63
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
64
|
+
try:
|
|
65
|
+
self._session.ocs(
|
|
66
|
+
"DELETE",
|
|
67
|
+
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
68
|
+
params={"eventType": event_type},
|
|
69
|
+
)
|
|
70
|
+
except NextcloudExceptionNotFound as e:
|
|
71
|
+
if not not_fail:
|
|
72
|
+
raise e from None
|
|
73
|
+
|
|
74
|
+
def get_entry(self, event_type: str) -> EventsListener | None:
|
|
75
|
+
"""Get information about the event listener."""
|
|
76
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
77
|
+
try:
|
|
78
|
+
return EventsListener(
|
|
79
|
+
self._session.ocs(
|
|
80
|
+
"GET",
|
|
81
|
+
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
82
|
+
params={"eventType": event_type},
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
except NextcloudExceptionNotFound:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class AsyncEventsListenerAPI:
|
|
90
|
+
"""API for registering Events listeners, avalaible as **nc.events_handler.<method>**."""
|
|
91
|
+
|
|
92
|
+
def __init__(self, session: AsyncNcSessionApp):
|
|
93
|
+
self._session = session
|
|
94
|
+
|
|
95
|
+
async def register(
|
|
96
|
+
self,
|
|
97
|
+
event_type: str,
|
|
98
|
+
callback_url: str,
|
|
99
|
+
event_subtypes: list[str] | None = None,
|
|
100
|
+
) -> None:
|
|
101
|
+
"""Registers or edits the events listener."""
|
|
102
|
+
if event_subtypes is None:
|
|
103
|
+
event_subtypes = []
|
|
104
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
105
|
+
params = {
|
|
106
|
+
"eventType": event_type,
|
|
107
|
+
"actionHandler": callback_url,
|
|
108
|
+
"eventSubtypes": event_subtypes,
|
|
109
|
+
}
|
|
110
|
+
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
111
|
+
|
|
112
|
+
async def unregister(self, event_type: str, not_fail=True) -> None:
|
|
113
|
+
"""Removes the events listener."""
|
|
114
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
115
|
+
try:
|
|
116
|
+
await self._session.ocs(
|
|
117
|
+
"DELETE",
|
|
118
|
+
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
119
|
+
params={"eventType": event_type},
|
|
120
|
+
)
|
|
121
|
+
except NextcloudExceptionNotFound as e:
|
|
122
|
+
if not not_fail:
|
|
123
|
+
raise e from None
|
|
124
|
+
|
|
125
|
+
async def get_entry(self, event_type: str) -> EventsListener | None:
|
|
126
|
+
"""Get information about the event listener."""
|
|
127
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
128
|
+
try:
|
|
129
|
+
return EventsListener(
|
|
130
|
+
await self._session.ocs(
|
|
131
|
+
"GET",
|
|
132
|
+
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
133
|
+
params={"eventType": event_type},
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
except NextcloudExceptionNotFound:
|
|
137
|
+
return None
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Nextcloud API for registering OCC commands for ExApps."""
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from .._exceptions import NextcloudExceptionNotFound
|
|
6
|
+
from .._misc import clear_from_params_empty, require_capabilities
|
|
7
|
+
from .._session import AsyncNcSessionApp, NcSessionApp
|
|
8
|
+
|
|
9
|
+
_EP_SUFFIX: str = "occ_command"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclasses.dataclass
|
|
13
|
+
class OccCommand:
|
|
14
|
+
"""OccCommand description."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, raw_data: dict):
|
|
17
|
+
self._raw_data = raw_data
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def name(self) -> str:
|
|
21
|
+
"""Unique ID for the command."""
|
|
22
|
+
return self._raw_data["name"]
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def description(self) -> str:
|
|
26
|
+
"""Command description."""
|
|
27
|
+
return self._raw_data["description"]
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def hidden(self) -> bool:
|
|
31
|
+
"""Flag determining ss command hidden or not."""
|
|
32
|
+
return bool(self._raw_data["hidden"])
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def arguments(self) -> dict:
|
|
36
|
+
"""Look at PHP Symfony framework for details."""
|
|
37
|
+
return self._raw_data["arguments"]
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def options(self) -> str:
|
|
41
|
+
"""Look at PHP Symfony framework for details."""
|
|
42
|
+
return self._raw_data["options"]
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def usages(self) -> str:
|
|
46
|
+
"""Look at PHP Symfony framework for details."""
|
|
47
|
+
return self._raw_data["usages"]
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def action_handler(self) -> str:
|
|
51
|
+
"""Relative ExApp url which will be called by Nextcloud."""
|
|
52
|
+
return self._raw_data["execute_handler"]
|
|
53
|
+
|
|
54
|
+
def __repr__(self):
|
|
55
|
+
return f"<{self.__class__.__name__} name={self.name}, handler={self.action_handler}>"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class OccCommandsAPI:
|
|
59
|
+
"""API for registering OCC commands, avalaible as **nc.occ_command.<method>**."""
|
|
60
|
+
|
|
61
|
+
def __init__(self, session: NcSessionApp):
|
|
62
|
+
self._session = session
|
|
63
|
+
|
|
64
|
+
def register(
|
|
65
|
+
self,
|
|
66
|
+
name: str,
|
|
67
|
+
callback_url: str,
|
|
68
|
+
arguments: list | None = None,
|
|
69
|
+
options: list | None = None,
|
|
70
|
+
usages: list | None = None,
|
|
71
|
+
description: str = "",
|
|
72
|
+
hidden: bool = False,
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Registers or edit the OCC command."""
|
|
75
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
76
|
+
params = {
|
|
77
|
+
"name": name,
|
|
78
|
+
"description": description,
|
|
79
|
+
"arguments": arguments,
|
|
80
|
+
"hidden": int(hidden),
|
|
81
|
+
"options": options,
|
|
82
|
+
"usages": usages,
|
|
83
|
+
"execute_handler": callback_url,
|
|
84
|
+
}
|
|
85
|
+
clear_from_params_empty(["arguments", "options", "usages"], params)
|
|
86
|
+
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
87
|
+
|
|
88
|
+
def unregister(self, name: str, not_fail=True) -> None:
|
|
89
|
+
"""Removes the OCC command."""
|
|
90
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
91
|
+
try:
|
|
92
|
+
self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
93
|
+
except NextcloudExceptionNotFound as e:
|
|
94
|
+
if not not_fail:
|
|
95
|
+
raise e from None
|
|
96
|
+
|
|
97
|
+
def get_entry(self, name: str) -> OccCommand | None:
|
|
98
|
+
"""Get information of the OCC command."""
|
|
99
|
+
require_capabilities("app_api", self._session.capabilities)
|
|
100
|
+
try:
|
|
101
|
+
return OccCommand(self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name}))
|
|
102
|
+
except NextcloudExceptionNotFound:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class AsyncOccCommandsAPI:
|
|
107
|
+
"""Async API for registering OCC commands, avalaible as **nc.occ_command.<method>**."""
|
|
108
|
+
|
|
109
|
+
def __init__(self, session: AsyncNcSessionApp):
|
|
110
|
+
self._session = session
|
|
111
|
+
|
|
112
|
+
async def register(
|
|
113
|
+
self,
|
|
114
|
+
name: str,
|
|
115
|
+
callback_url: str,
|
|
116
|
+
arguments: list | None = None,
|
|
117
|
+
options: list | None = None,
|
|
118
|
+
usages: list | None = None,
|
|
119
|
+
description: str = "",
|
|
120
|
+
hidden: bool = False,
|
|
121
|
+
) -> None:
|
|
122
|
+
"""Registers or edit the OCC command."""
|
|
123
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
124
|
+
params = {
|
|
125
|
+
"name": name,
|
|
126
|
+
"description": description,
|
|
127
|
+
"arguments": arguments,
|
|
128
|
+
"hidden": int(hidden),
|
|
129
|
+
"options": options,
|
|
130
|
+
"usages": usages,
|
|
131
|
+
"execute_handler": callback_url,
|
|
132
|
+
}
|
|
133
|
+
clear_from_params_empty(["arguments", "options", "usages"], params)
|
|
134
|
+
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
135
|
+
|
|
136
|
+
async def unregister(self, name: str, not_fail=True) -> None:
|
|
137
|
+
"""Removes the OCC command."""
|
|
138
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
139
|
+
try:
|
|
140
|
+
await self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
141
|
+
except NextcloudExceptionNotFound as e:
|
|
142
|
+
if not not_fail:
|
|
143
|
+
raise e from None
|
|
144
|
+
|
|
145
|
+
async def get_entry(self, name: str) -> OccCommand | None:
|
|
146
|
+
"""Get information of the OCC command."""
|
|
147
|
+
require_capabilities("app_api", await self._session.capabilities)
|
|
148
|
+
try:
|
|
149
|
+
return OccCommand(
|
|
150
|
+
await self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
151
|
+
)
|
|
152
|
+
except NextcloudExceptionNotFound:
|
|
153
|
+
return None
|
|
@@ -282,12 +282,13 @@ class FilePermissions(enum.IntFlag):
|
|
|
282
282
|
"""Access to re-share object(s)"""
|
|
283
283
|
|
|
284
284
|
|
|
285
|
-
def permissions_to_str(permissions: int, is_dir: bool = False) -> str:
|
|
285
|
+
def permissions_to_str(permissions: int | str, is_dir: bool = False) -> str:
|
|
286
286
|
"""Converts integer permissions to string permissions.
|
|
287
287
|
|
|
288
288
|
:param permissions: concatenation of ``FilePermissions`` integer flags.
|
|
289
289
|
:param is_dir: Flag indicating is permissions related to the directory object or not.
|
|
290
290
|
"""
|
|
291
|
+
permissions = int(permissions) if not isinstance(permissions, int) else permissions
|
|
291
292
|
r = ""
|
|
292
293
|
if permissions & FilePermissions.PERMISSION_SHARE:
|
|
293
294
|
r += "R"
|
|
@@ -30,6 +30,8 @@ from .activity import _ActivityAPI, _AsyncActivityAPI
|
|
|
30
30
|
from .apps import _AppsAPI, _AsyncAppsAPI
|
|
31
31
|
from .calendar import _CalendarAPI
|
|
32
32
|
from .ex_app.defs import LogLvl
|
|
33
|
+
from .ex_app.events_listener import AsyncEventsListenerAPI, EventsListenerAPI
|
|
34
|
+
from .ex_app.occ_commands import AsyncOccCommandsAPI, OccCommandsAPI
|
|
33
35
|
from .ex_app.providers.providers import AsyncProvidersApi, ProvidersApi
|
|
34
36
|
from .ex_app.ui.ui import AsyncUiApi, UiApi
|
|
35
37
|
from .files.files import AsyncFilesAPI, FilesAPI
|
|
@@ -304,6 +306,10 @@ class NextcloudApp(_NextcloudBasic):
|
|
|
304
306
|
"""Nextcloud UI API for ExApps"""
|
|
305
307
|
providers: ProvidersApi
|
|
306
308
|
"""API for registering providers for Nextcloud"""
|
|
309
|
+
events_listener: EventsListenerAPI
|
|
310
|
+
"""API for registering Events listeners for ExApps"""
|
|
311
|
+
occ_commands: OccCommandsAPI
|
|
312
|
+
"""API for registering OCC command for ExApps"""
|
|
307
313
|
|
|
308
314
|
def __init__(self, **kwargs):
|
|
309
315
|
"""The parameters will be taken from the environment.
|
|
@@ -316,6 +322,8 @@ class NextcloudApp(_NextcloudBasic):
|
|
|
316
322
|
self.preferences_ex = PreferencesExAPI(self._session)
|
|
317
323
|
self.ui = UiApi(self._session)
|
|
318
324
|
self.providers = ProvidersApi(self._session)
|
|
325
|
+
self.events_listener = EventsListenerAPI(self._session)
|
|
326
|
+
self.occ_commands = OccCommandsAPI(self._session)
|
|
319
327
|
|
|
320
328
|
def log(self, log_lvl: LogLvl, content: str) -> None:
|
|
321
329
|
"""Writes log to the Nextcloud log file."""
|
|
@@ -421,6 +429,10 @@ class AsyncNextcloudApp(_AsyncNextcloudBasic):
|
|
|
421
429
|
"""Nextcloud UI API for ExApps"""
|
|
422
430
|
providers: AsyncProvidersApi
|
|
423
431
|
"""API for registering providers for Nextcloud"""
|
|
432
|
+
events_listener: AsyncEventsListenerAPI
|
|
433
|
+
"""API for registering Events listeners for ExApps"""
|
|
434
|
+
occ_commands: AsyncOccCommandsAPI
|
|
435
|
+
"""API for registering OCC command for ExApps"""
|
|
424
436
|
|
|
425
437
|
def __init__(self, **kwargs):
|
|
426
438
|
"""The parameters will be taken from the environment.
|
|
@@ -433,6 +445,8 @@ class AsyncNextcloudApp(_AsyncNextcloudBasic):
|
|
|
433
445
|
self.preferences_ex = AsyncPreferencesExAPI(self._session)
|
|
434
446
|
self.ui = AsyncUiApi(self._session)
|
|
435
447
|
self.providers = AsyncProvidersApi(self._session)
|
|
448
|
+
self.events_listener = AsyncEventsListenerAPI(self._session)
|
|
449
|
+
self.occ_commands = AsyncOccCommandsAPI(self._session)
|
|
436
450
|
|
|
437
451
|
async def log(self, log_lvl: LogLvl, content: str) -> None:
|
|
438
452
|
"""Writes log to the Nextcloud log file."""
|
|
@@ -136,7 +136,7 @@ design.max-attributes = 8
|
|
|
136
136
|
design.max-locals = 20
|
|
137
137
|
design.max-branches = 16
|
|
138
138
|
design.max-returns = 8
|
|
139
|
-
design.max-args =
|
|
139
|
+
design.max-args = 8
|
|
140
140
|
basic.good-names = [
|
|
141
141
|
"a", "b", "c", "d", "e", "f", "i", "j", "k", "r", "v",
|
|
142
142
|
"ex", "_", "fp", "im", "nc", "ui",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|