nc-py-api 0.16.0__tar.gz → 0.17.1__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.16.0 → nc_py_api-0.17.1}/CHANGELOG.md +20 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/PKG-INFO +15 -16
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/README.md +14 -15
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_version.py +1 -1
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/apps.py +0 -13
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/__init__.py +1 -0
- nc_py_api-0.17.1/nc_py_api/ex_app/logging.py +46 -0
- nc_py_api-0.17.1/nc_py_api/ex_app/providers/providers.py +24 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/nextcloud.py +24 -12
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/talk_bot.py +5 -0
- nc_py_api-0.16.0/nc_py_api/ex_app/providers/providers.py +0 -45
- nc_py_api-0.16.0/nc_py_api/ex_app/providers/speech_to_text.py +0 -128
- nc_py_api-0.16.0/nc_py_api/ex_app/providers/text_processing.py +0 -135
- nc_py_api-0.16.0/nc_py_api/ex_app/providers/translations.py +0 -165
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/.gitignore +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/AUTHORS +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/LICENSE.txt +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/__init__.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_deffered_error.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_exceptions.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_misc.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_preferences.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_preferences_ex.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_session.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_talk_api.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/_theming.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/activity.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/calendar.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/defs.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/events_listener.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/integration_fastapi.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/misc.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/occ_commands.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/persist_transformers_cache.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/providers/__init__.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/providers/task_processing.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/__init__.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/files_actions.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/resources.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/settings.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/top_menu.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/ui/ui.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/ex_app/uvicorn_fastapi.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/files/__init__.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/files/_files.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/files/files.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/files/files_async.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/files/sharing.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/loginflow_v2.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/notes.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/notifications.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/options.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/talk.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/user_status.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/users.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/users_groups.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/weather_status.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/nc_py_api/webhooks.py +0 -0
- {nc_py_api-0.16.0 → nc_py_api-0.17.1}/pyproject.toml +0 -0
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.17.1 - 2024-09-06]
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- NextcloudApp: `setup_nextcloud_logging` function to support transparently sending logs to Nextcloud. #294
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- NextcloudApp: `nc.log` now suppresses all exceptions to safe call it anywhere(for example in exception handlers). #293
|
|
14
|
+
|
|
15
|
+
## [0.17.0 - 2024-09-05]
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `message_type` property to TalkBotMessage. #292
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- NextcloudApp: `TextProcessing`, `Speech2Text` and `Translation` AI Providers API was removed. #289
|
|
24
|
+
|
|
5
25
|
## [0.16.0 - 2024-08-12]
|
|
6
26
|
|
|
7
27
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nc-py-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.1
|
|
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/
|
|
@@ -101,23 +101,22 @@ Python library that provides a robust and well-documented API that allows develo
|
|
|
101
101
|
* **Sync + Async**: Provides both sync and async APIs.
|
|
102
102
|
|
|
103
103
|
### Capabilities
|
|
104
|
-
| **_Capability_**
|
|
105
|
-
|
|
106
|
-
| Calendar
|
|
107
|
-
| File System & Tags
|
|
108
|
-
| Nextcloud Talk
|
|
109
|
-
| Notifications
|
|
110
|
-
| Shares
|
|
111
|
-
| Users & Groups
|
|
112
|
-
| User & Weather status
|
|
113
|
-
| Other APIs
|
|
114
|
-
| Talk Bot API*
|
|
115
|
-
| Settings UI API*
|
|
116
|
-
|
|
|
104
|
+
| **_Capability_** | Nextcloud 27 | Nextcloud 28 | Nextcloud 29 | Nextcloud 30 |
|
|
105
|
+
|------------------------------|:------------:|:------------:|:------------:|:------------:|
|
|
106
|
+
| Calendar | ✅ | ✅ | ✅ | ✅ |
|
|
107
|
+
| File System & Tags | ✅ | ✅ | ✅ | ✅ |
|
|
108
|
+
| Nextcloud Talk | ✅ | ✅ | ✅ | ✅ |
|
|
109
|
+
| Notifications | ✅ | ✅ | ✅ | ✅ |
|
|
110
|
+
| Shares | ✅ | ✅ | ✅ | ✅ |
|
|
111
|
+
| Users & Groups | ✅ | ✅ | ✅ | ✅ |
|
|
112
|
+
| User & Weather status | ✅ | ✅ | ✅ | ✅ |
|
|
113
|
+
| Other APIs** | ✅ | ✅ | ✅ | ✅ |
|
|
114
|
+
| Talk Bot API* | ✅ | ✅ | ✅ | ✅ |
|
|
115
|
+
| Settings UI API* | N/A | N/A | ✅ | ✅ |
|
|
116
|
+
| TaskProcessing Provider API* | N/A | N/A | N/A | ✅ |
|
|
117
117
|
|
|
118
118
|
*_available only for **NextcloudApp**_<br>
|
|
119
|
-
**
|
|
120
|
-
***_Activity, Notes_
|
|
119
|
+
**_Activity, Notes_
|
|
121
120
|
|
|
122
121
|
### Differences between the Nextcloud and NextcloudApp classes
|
|
123
122
|
|
|
@@ -24,23 +24,22 @@ Python library that provides a robust and well-documented API that allows develo
|
|
|
24
24
|
* **Sync + Async**: Provides both sync and async APIs.
|
|
25
25
|
|
|
26
26
|
### Capabilities
|
|
27
|
-
| **_Capability_**
|
|
28
|
-
|
|
29
|
-
| Calendar
|
|
30
|
-
| File System & Tags
|
|
31
|
-
| Nextcloud Talk
|
|
32
|
-
| Notifications
|
|
33
|
-
| Shares
|
|
34
|
-
| Users & Groups
|
|
35
|
-
| User & Weather status
|
|
36
|
-
| Other APIs
|
|
37
|
-
| Talk Bot API*
|
|
38
|
-
| Settings UI API*
|
|
39
|
-
|
|
|
27
|
+
| **_Capability_** | Nextcloud 27 | Nextcloud 28 | Nextcloud 29 | Nextcloud 30 |
|
|
28
|
+
|------------------------------|:------------:|:------------:|:------------:|:------------:|
|
|
29
|
+
| Calendar | ✅ | ✅ | ✅ | ✅ |
|
|
30
|
+
| File System & Tags | ✅ | ✅ | ✅ | ✅ |
|
|
31
|
+
| Nextcloud Talk | ✅ | ✅ | ✅ | ✅ |
|
|
32
|
+
| Notifications | ✅ | ✅ | ✅ | ✅ |
|
|
33
|
+
| Shares | ✅ | ✅ | ✅ | ✅ |
|
|
34
|
+
| Users & Groups | ✅ | ✅ | ✅ | ✅ |
|
|
35
|
+
| User & Weather status | ✅ | ✅ | ✅ | ✅ |
|
|
36
|
+
| Other APIs** | ✅ | ✅ | ✅ | ✅ |
|
|
37
|
+
| Talk Bot API* | ✅ | ✅ | ✅ | ✅ |
|
|
38
|
+
| Settings UI API* | N/A | N/A | ✅ | ✅ |
|
|
39
|
+
| TaskProcessing Provider API* | N/A | N/A | N/A | ✅ |
|
|
40
40
|
|
|
41
41
|
*_available only for **NextcloudApp**_<br>
|
|
42
|
-
**
|
|
43
|
-
***_Activity, Notes_
|
|
42
|
+
**_Activity, Notes_
|
|
44
43
|
|
|
45
44
|
### Differences between the Nextcloud and NextcloudApp classes
|
|
46
45
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Nextcloud API for working with applications."""
|
|
2
2
|
|
|
3
3
|
import dataclasses
|
|
4
|
-
import datetime
|
|
5
4
|
|
|
6
5
|
from ._misc import require_capabilities
|
|
7
6
|
from ._session import AsyncNcSessionBasic, NcSessionBasic
|
|
@@ -34,18 +33,6 @@ class ExAppInfo:
|
|
|
34
33
|
"""Flag indicating if the application enabled."""
|
|
35
34
|
return bool(self._raw_data["enabled"])
|
|
36
35
|
|
|
37
|
-
@property
|
|
38
|
-
def last_check_time(self) -> datetime.datetime:
|
|
39
|
-
"""Time of the last successful application check."""
|
|
40
|
-
return datetime.datetime.utcfromtimestamp(int(self._raw_data["last_check_time"])).replace(
|
|
41
|
-
tzinfo=datetime.timezone.utc
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def system(self) -> bool:
|
|
46
|
-
"""**DEPRECATED** Flag indicating if the application is a system application."""
|
|
47
|
-
return True
|
|
48
|
-
|
|
49
36
|
def __repr__(self):
|
|
50
37
|
return f"<{self.__class__.__name__} id={self.app_id}, ver={self.version}>"
|
|
51
38
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Transparent logging support to store logs in the nextcloud.log."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import threading
|
|
5
|
+
|
|
6
|
+
from ..nextcloud import NextcloudApp
|
|
7
|
+
from .defs import LogLvl
|
|
8
|
+
|
|
9
|
+
LOGLVL_MAP = {
|
|
10
|
+
logging.NOTSET: LogLvl.DEBUG,
|
|
11
|
+
logging.DEBUG: LogLvl.DEBUG,
|
|
12
|
+
logging.INFO: LogLvl.INFO,
|
|
13
|
+
logging.WARNING: LogLvl.WARNING,
|
|
14
|
+
logging.ERROR: LogLvl.ERROR,
|
|
15
|
+
logging.CRITICAL: LogLvl.FATAL,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
THREAD_LOCAL = threading.local()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class _NextcloudLogsHandler(logging.Handler):
|
|
22
|
+
def __init__(self):
|
|
23
|
+
super().__init__()
|
|
24
|
+
|
|
25
|
+
def emit(self, record):
|
|
26
|
+
if THREAD_LOCAL.__dict__.get("nc_py_api.loghandler", False):
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
THREAD_LOCAL.__dict__["nc_py_api.loghandler"] = True
|
|
31
|
+
log_entry = self.format(record)
|
|
32
|
+
log_level = record.levelno
|
|
33
|
+
NextcloudApp().log(LOGLVL_MAP.get(log_level, LogLvl.FATAL), log_entry, fast_send=True)
|
|
34
|
+
except Exception: # noqa pylint: disable=broad-exception-caught
|
|
35
|
+
self.handleError(record)
|
|
36
|
+
finally:
|
|
37
|
+
THREAD_LOCAL.__dict__["nc_py_api.loghandler"] = False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def setup_nextcloud_logging(logger_name: str | None = None, logging_level: int = logging.DEBUG):
|
|
41
|
+
"""Function to easily send all or selected log entries to Nextcloud."""
|
|
42
|
+
logger = logging.getLogger(logger_name)
|
|
43
|
+
nextcloud_handler = _NextcloudLogsHandler()
|
|
44
|
+
nextcloud_handler.setLevel(logging_level)
|
|
45
|
+
logger.addHandler(nextcloud_handler)
|
|
46
|
+
return nextcloud_handler
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Nextcloud API for AI Providers."""
|
|
2
|
+
|
|
3
|
+
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
4
|
+
from .task_processing import _AsyncTaskProcessingProviderAPI, _TaskProcessingProviderAPI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ProvidersApi:
|
|
8
|
+
"""Class that encapsulates all AI Providers functionality."""
|
|
9
|
+
|
|
10
|
+
task_processing: _TaskProcessingProviderAPI
|
|
11
|
+
"""TaskProcessing Provider API."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, session: NcSessionApp):
|
|
14
|
+
self.task_processing = _TaskProcessingProviderAPI(session)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AsyncProvidersApi:
|
|
18
|
+
"""Class that encapsulates all AI Providers functionality."""
|
|
19
|
+
|
|
20
|
+
task_processing: _AsyncTaskProcessingProviderAPI
|
|
21
|
+
"""TaskProcessing Provider API."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, session: AsyncNcSessionApp):
|
|
24
|
+
self.task_processing = _AsyncTaskProcessingProviderAPI(session)
|
|
@@ -348,13 +348,18 @@ class NextcloudApp(_NextcloudBasic):
|
|
|
348
348
|
return bool(self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state"))
|
|
349
349
|
return False
|
|
350
350
|
|
|
351
|
-
def log(self, log_lvl: LogLvl, content: str) -> None:
|
|
351
|
+
def log(self, log_lvl: LogLvl, content: str, fast_send: bool = False) -> None:
|
|
352
352
|
"""Writes log to the Nextcloud log file."""
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
353
|
+
int_log_lvl = int(log_lvl)
|
|
354
|
+
if int_log_lvl < 0 or int_log_lvl > 4:
|
|
355
|
+
raise ValueError("Invalid `log_lvl` value")
|
|
356
|
+
if not fast_send:
|
|
357
|
+
if self.check_capabilities("app_api"):
|
|
358
|
+
return
|
|
359
|
+
if int_log_lvl < self.capabilities["app_api"].get("loglevel", 0):
|
|
360
|
+
return
|
|
361
|
+
with contextlib.suppress(Exception):
|
|
362
|
+
self._session.ocs("POST", f"{self._session.ae_url}/log", json={"level": int_log_lvl, "message": content})
|
|
358
363
|
|
|
359
364
|
def users_list(self) -> list[str]:
|
|
360
365
|
"""Returns list of users on the Nextcloud instance."""
|
|
@@ -478,13 +483,20 @@ class AsyncNextcloudApp(_AsyncNextcloudBasic):
|
|
|
478
483
|
return bool(await self._session.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state"))
|
|
479
484
|
return False
|
|
480
485
|
|
|
481
|
-
async def log(self, log_lvl: LogLvl, content: str) -> None:
|
|
486
|
+
async def log(self, log_lvl: LogLvl, content: str, fast_send: bool = False) -> None:
|
|
482
487
|
"""Writes log to the Nextcloud log file."""
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
+
int_log_lvl = int(log_lvl)
|
|
489
|
+
if int_log_lvl < 0 or int_log_lvl > 4:
|
|
490
|
+
raise ValueError("Invalid `log_lvl` value")
|
|
491
|
+
if not fast_send:
|
|
492
|
+
if await self.check_capabilities("app_api"):
|
|
493
|
+
return
|
|
494
|
+
if int_log_lvl < (await self.capabilities)["app_api"].get("loglevel", 0):
|
|
495
|
+
return
|
|
496
|
+
with contextlib.suppress(Exception):
|
|
497
|
+
await self._session.ocs(
|
|
498
|
+
"POST", f"{self._session.ae_url}/log", json={"level": int_log_lvl, "message": content}
|
|
499
|
+
)
|
|
488
500
|
|
|
489
501
|
async def users_list(self) -> list[str]:
|
|
490
502
|
"""Returns list of users on the Nextcloud instance."""
|
|
@@ -29,6 +29,11 @@ class TalkBotMessage:
|
|
|
29
29
|
def __init__(self, raw_data: dict):
|
|
30
30
|
self._raw_data = raw_data
|
|
31
31
|
|
|
32
|
+
@property
|
|
33
|
+
def message_type(self) -> str:
|
|
34
|
+
"""The type of message like Join, Leave, Create, Activity, etc."""
|
|
35
|
+
return self._raw_data["type"]
|
|
36
|
+
|
|
32
37
|
@property
|
|
33
38
|
def actor_id(self) -> str:
|
|
34
39
|
"""One of the attendee types followed by the ``/`` character and a unique identifier within the given type.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""Nextcloud API for AI Providers."""
|
|
2
|
-
|
|
3
|
-
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
4
|
-
from .speech_to_text import _AsyncSpeechToTextProviderAPI, _SpeechToTextProviderAPI
|
|
5
|
-
from .task_processing import _AsyncTaskProcessingProviderAPI, _TaskProcessingProviderAPI
|
|
6
|
-
from .text_processing import _AsyncTextProcessingProviderAPI, _TextProcessingProviderAPI
|
|
7
|
-
from .translations import _AsyncTranslationsProviderAPI, _TranslationsProviderAPI
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ProvidersApi:
|
|
11
|
-
"""Class that encapsulates all AI Providers functionality."""
|
|
12
|
-
|
|
13
|
-
speech_to_text: _SpeechToTextProviderAPI
|
|
14
|
-
"""SpeechToText Provider API."""
|
|
15
|
-
text_processing: _TextProcessingProviderAPI
|
|
16
|
-
"""TextProcessing Provider API."""
|
|
17
|
-
translations: _TranslationsProviderAPI
|
|
18
|
-
"""Translations Provider API."""
|
|
19
|
-
task_processing: _TaskProcessingProviderAPI
|
|
20
|
-
"""TaskProcessing Provider API."""
|
|
21
|
-
|
|
22
|
-
def __init__(self, session: NcSessionApp):
|
|
23
|
-
self.speech_to_text = _SpeechToTextProviderAPI(session)
|
|
24
|
-
self.text_processing = _TextProcessingProviderAPI(session)
|
|
25
|
-
self.translations = _TranslationsProviderAPI(session)
|
|
26
|
-
self.task_processing = _TaskProcessingProviderAPI(session)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class AsyncProvidersApi:
|
|
30
|
-
"""Class that encapsulates all AI Providers functionality."""
|
|
31
|
-
|
|
32
|
-
speech_to_text: _AsyncSpeechToTextProviderAPI
|
|
33
|
-
"""SpeechToText Provider API."""
|
|
34
|
-
text_processing: _AsyncTextProcessingProviderAPI
|
|
35
|
-
"""TextProcessing Provider API."""
|
|
36
|
-
translations: _AsyncTranslationsProviderAPI
|
|
37
|
-
"""Translations Provider API."""
|
|
38
|
-
task_processing: _AsyncTaskProcessingProviderAPI
|
|
39
|
-
"""TaskProcessing Provider API."""
|
|
40
|
-
|
|
41
|
-
def __init__(self, session: AsyncNcSessionApp):
|
|
42
|
-
self.speech_to_text = _AsyncSpeechToTextProviderAPI(session)
|
|
43
|
-
self.text_processing = _AsyncTextProcessingProviderAPI(session)
|
|
44
|
-
self.translations = _AsyncTranslationsProviderAPI(session)
|
|
45
|
-
self.task_processing = _AsyncTaskProcessingProviderAPI(session)
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"""Nextcloud API for declaring SpeechToText provider."""
|
|
2
|
-
|
|
3
|
-
import contextlib
|
|
4
|
-
import dataclasses
|
|
5
|
-
|
|
6
|
-
from ..._exceptions import NextcloudException, NextcloudExceptionNotFound
|
|
7
|
-
from ..._misc import require_capabilities
|
|
8
|
-
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
9
|
-
|
|
10
|
-
_EP_SUFFIX: str = "ai_provider/speech_to_text"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@dataclasses.dataclass
|
|
14
|
-
class SpeechToTextProvider:
|
|
15
|
-
"""Speech2Text provider description."""
|
|
16
|
-
|
|
17
|
-
def __init__(self, raw_data: dict):
|
|
18
|
-
self._raw_data = raw_data
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def name(self) -> str:
|
|
22
|
-
"""Unique ID for the provider."""
|
|
23
|
-
return self._raw_data["name"]
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def display_name(self) -> str:
|
|
27
|
-
"""Providers display name."""
|
|
28
|
-
return self._raw_data["display_name"]
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def action_handler(self) -> str:
|
|
32
|
-
"""Relative ExApp url which will be called by Nextcloud."""
|
|
33
|
-
return self._raw_data["action_handler"]
|
|
34
|
-
|
|
35
|
-
def __repr__(self):
|
|
36
|
-
return f"<{self.__class__.__name__} name={self.name}, handler={self.action_handler}>"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class _SpeechToTextProviderAPI:
|
|
40
|
-
"""API for Speech2Text providers, avalaible as **nc.providers.text_processing.<method>**."""
|
|
41
|
-
|
|
42
|
-
def __init__(self, session: NcSessionApp):
|
|
43
|
-
self._session = session
|
|
44
|
-
|
|
45
|
-
def register(self, name: str, display_name: str, callback_url: str) -> None:
|
|
46
|
-
"""Registers or edit the SpeechToText provider."""
|
|
47
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
48
|
-
params = {
|
|
49
|
-
"name": name,
|
|
50
|
-
"displayName": display_name,
|
|
51
|
-
"actionHandler": callback_url,
|
|
52
|
-
}
|
|
53
|
-
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
54
|
-
|
|
55
|
-
def unregister(self, name: str, not_fail=True) -> None:
|
|
56
|
-
"""Removes SpeechToText provider."""
|
|
57
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
58
|
-
try:
|
|
59
|
-
self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
60
|
-
except NextcloudExceptionNotFound as e:
|
|
61
|
-
if not not_fail:
|
|
62
|
-
raise e from None
|
|
63
|
-
|
|
64
|
-
def get_entry(self, name: str) -> SpeechToTextProvider | None:
|
|
65
|
-
"""Get information of the SpeechToText."""
|
|
66
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
67
|
-
try:
|
|
68
|
-
return SpeechToTextProvider(
|
|
69
|
-
self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
70
|
-
)
|
|
71
|
-
except NextcloudExceptionNotFound:
|
|
72
|
-
return None
|
|
73
|
-
|
|
74
|
-
def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
75
|
-
"""Report results of speech to text task to Nextcloud."""
|
|
76
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
77
|
-
with contextlib.suppress(NextcloudException):
|
|
78
|
-
self._session.ocs(
|
|
79
|
-
"PUT",
|
|
80
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
81
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class _AsyncSpeechToTextProviderAPI:
|
|
86
|
-
"""Async API for Speech2Text providers."""
|
|
87
|
-
|
|
88
|
-
def __init__(self, session: AsyncNcSessionApp):
|
|
89
|
-
self._session = session
|
|
90
|
-
|
|
91
|
-
async def register(self, name: str, display_name: str, callback_url: str) -> None:
|
|
92
|
-
"""Registers or edit the SpeechToText provider."""
|
|
93
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
94
|
-
params = {
|
|
95
|
-
"name": name,
|
|
96
|
-
"displayName": display_name,
|
|
97
|
-
"actionHandler": callback_url,
|
|
98
|
-
}
|
|
99
|
-
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
100
|
-
|
|
101
|
-
async def unregister(self, name: str, not_fail=True) -> None:
|
|
102
|
-
"""Removes SpeechToText provider."""
|
|
103
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
104
|
-
try:
|
|
105
|
-
await self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
106
|
-
except NextcloudExceptionNotFound as e:
|
|
107
|
-
if not not_fail:
|
|
108
|
-
raise e from None
|
|
109
|
-
|
|
110
|
-
async def get_entry(self, name: str) -> SpeechToTextProvider | None:
|
|
111
|
-
"""Get information of the SpeechToText."""
|
|
112
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
113
|
-
try:
|
|
114
|
-
return SpeechToTextProvider(
|
|
115
|
-
await self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
116
|
-
)
|
|
117
|
-
except NextcloudExceptionNotFound:
|
|
118
|
-
return None
|
|
119
|
-
|
|
120
|
-
async def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
121
|
-
"""Report results of speech to text task to Nextcloud."""
|
|
122
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
123
|
-
with contextlib.suppress(NextcloudException):
|
|
124
|
-
await self._session.ocs(
|
|
125
|
-
"PUT",
|
|
126
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
127
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
128
|
-
)
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"""Nextcloud API for declaring TextProcessing provider."""
|
|
2
|
-
|
|
3
|
-
import contextlib
|
|
4
|
-
import dataclasses
|
|
5
|
-
|
|
6
|
-
from ..._exceptions import NextcloudException, NextcloudExceptionNotFound
|
|
7
|
-
from ..._misc import require_capabilities
|
|
8
|
-
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
9
|
-
|
|
10
|
-
_EP_SUFFIX: str = "ai_provider/text_processing"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@dataclasses.dataclass
|
|
14
|
-
class TextProcessingProvider:
|
|
15
|
-
"""TextProcessing provider description."""
|
|
16
|
-
|
|
17
|
-
def __init__(self, raw_data: dict):
|
|
18
|
-
self._raw_data = raw_data
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def name(self) -> str:
|
|
22
|
-
"""Unique ID for the provider."""
|
|
23
|
-
return self._raw_data["name"]
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def display_name(self) -> str:
|
|
27
|
-
"""Providers display name."""
|
|
28
|
-
return self._raw_data["display_name"]
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def action_handler(self) -> str:
|
|
32
|
-
"""Relative ExApp url which will be called by Nextcloud."""
|
|
33
|
-
return self._raw_data["action_handler"]
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def task_type(self) -> str:
|
|
37
|
-
"""The TaskType provided by this provider."""
|
|
38
|
-
return self._raw_data["task_type"]
|
|
39
|
-
|
|
40
|
-
def __repr__(self):
|
|
41
|
-
return f"<{self.__class__.__name__} name={self.name}, type={self.task_type}, handler={self.action_handler}>"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class _TextProcessingProviderAPI:
|
|
45
|
-
"""API for TextProcessing providers, avalaible as **nc.providers.speech_to_text.<method>**."""
|
|
46
|
-
|
|
47
|
-
def __init__(self, session: NcSessionApp):
|
|
48
|
-
self._session = session
|
|
49
|
-
|
|
50
|
-
def register(self, name: str, display_name: str, callback_url: str, task_type: str) -> None:
|
|
51
|
-
"""Registers or edit the TextProcessing provider."""
|
|
52
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
53
|
-
params = {
|
|
54
|
-
"name": name,
|
|
55
|
-
"displayName": display_name,
|
|
56
|
-
"actionHandler": callback_url,
|
|
57
|
-
"taskType": task_type,
|
|
58
|
-
}
|
|
59
|
-
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
60
|
-
|
|
61
|
-
def unregister(self, name: str, not_fail=True) -> None:
|
|
62
|
-
"""Removes TextProcessing provider."""
|
|
63
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
64
|
-
try:
|
|
65
|
-
self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
66
|
-
except NextcloudExceptionNotFound as e:
|
|
67
|
-
if not not_fail:
|
|
68
|
-
raise e from None
|
|
69
|
-
|
|
70
|
-
def get_entry(self, name: str) -> TextProcessingProvider | None:
|
|
71
|
-
"""Get information of the TextProcessing."""
|
|
72
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
73
|
-
try:
|
|
74
|
-
return TextProcessingProvider(
|
|
75
|
-
self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
76
|
-
)
|
|
77
|
-
except NextcloudExceptionNotFound:
|
|
78
|
-
return None
|
|
79
|
-
|
|
80
|
-
def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
81
|
-
"""Report results of the text processing to Nextcloud."""
|
|
82
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
83
|
-
with contextlib.suppress(NextcloudException):
|
|
84
|
-
self._session.ocs(
|
|
85
|
-
"PUT",
|
|
86
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
87
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class _AsyncTextProcessingProviderAPI:
|
|
92
|
-
"""Async API for TextProcessing providers."""
|
|
93
|
-
|
|
94
|
-
def __init__(self, session: AsyncNcSessionApp):
|
|
95
|
-
self._session = session
|
|
96
|
-
|
|
97
|
-
async def register(self, name: str, display_name: str, callback_url: str, task_type: str) -> None:
|
|
98
|
-
"""Registers or edit the TextProcessing provider."""
|
|
99
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
100
|
-
params = {
|
|
101
|
-
"name": name,
|
|
102
|
-
"displayName": display_name,
|
|
103
|
-
"actionHandler": callback_url,
|
|
104
|
-
"taskType": task_type,
|
|
105
|
-
}
|
|
106
|
-
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
107
|
-
|
|
108
|
-
async def unregister(self, name: str, not_fail=True) -> None:
|
|
109
|
-
"""Removes TextProcessing provider."""
|
|
110
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
111
|
-
try:
|
|
112
|
-
await self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
113
|
-
except NextcloudExceptionNotFound as e:
|
|
114
|
-
if not not_fail:
|
|
115
|
-
raise e from None
|
|
116
|
-
|
|
117
|
-
async def get_entry(self, name: str) -> TextProcessingProvider | None:
|
|
118
|
-
"""Get information of the TextProcessing."""
|
|
119
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
120
|
-
try:
|
|
121
|
-
return TextProcessingProvider(
|
|
122
|
-
await self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
123
|
-
)
|
|
124
|
-
except NextcloudExceptionNotFound:
|
|
125
|
-
return None
|
|
126
|
-
|
|
127
|
-
async def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
128
|
-
"""Report results of the text processing to Nextcloud."""
|
|
129
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
130
|
-
with contextlib.suppress(NextcloudException):
|
|
131
|
-
await self._session.ocs(
|
|
132
|
-
"PUT",
|
|
133
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
134
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
135
|
-
)
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"""Nextcloud API for declaring Translations provider."""
|
|
2
|
-
|
|
3
|
-
import contextlib
|
|
4
|
-
import dataclasses
|
|
5
|
-
|
|
6
|
-
from ..._exceptions import NextcloudException, NextcloudExceptionNotFound
|
|
7
|
-
from ..._misc import require_capabilities
|
|
8
|
-
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
9
|
-
|
|
10
|
-
_EP_SUFFIX: str = "ai_provider/translation"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@dataclasses.dataclass
|
|
14
|
-
class TranslationsProvider:
|
|
15
|
-
"""Translations provider description."""
|
|
16
|
-
|
|
17
|
-
def __init__(self, raw_data: dict):
|
|
18
|
-
self._raw_data = raw_data
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def name(self) -> str:
|
|
22
|
-
"""Unique ID for the provider."""
|
|
23
|
-
return self._raw_data["name"]
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def display_name(self) -> str:
|
|
27
|
-
"""Providers display name."""
|
|
28
|
-
return self._raw_data["display_name"]
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def from_languages(self) -> dict[str, str]:
|
|
32
|
-
"""Input languages supported by provider."""
|
|
33
|
-
return self._raw_data["from_languages"]
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def to_languages(self) -> dict[str, str]:
|
|
37
|
-
"""Output languages supported by provider."""
|
|
38
|
-
return self._raw_data["to_languages"]
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def action_handler(self) -> str:
|
|
42
|
-
"""Relative ExApp url which will be called by Nextcloud."""
|
|
43
|
-
return self._raw_data["action_handler"]
|
|
44
|
-
|
|
45
|
-
@property
|
|
46
|
-
def action_handler_detect_lang(self) -> str:
|
|
47
|
-
"""Relative ExApp url which will be called by Nextcloud to detect language."""
|
|
48
|
-
return self._raw_data.get("action_detect_lang", "")
|
|
49
|
-
|
|
50
|
-
def __repr__(self):
|
|
51
|
-
return f"<{self.__class__.__name__} name={self.name}, handler={self.action_handler}>"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class _TranslationsProviderAPI:
|
|
55
|
-
"""API for Translations providers, avalaible as **nc.providers.translations.<method>**."""
|
|
56
|
-
|
|
57
|
-
def __init__(self, session: NcSessionApp):
|
|
58
|
-
self._session = session
|
|
59
|
-
|
|
60
|
-
def register(
|
|
61
|
-
self,
|
|
62
|
-
name: str,
|
|
63
|
-
display_name: str,
|
|
64
|
-
callback_url: str,
|
|
65
|
-
from_languages: dict[str, str],
|
|
66
|
-
to_languages: dict[str, str],
|
|
67
|
-
detect_lang_callback_url: str = "",
|
|
68
|
-
) -> None:
|
|
69
|
-
"""Registers or edit the Translations provider."""
|
|
70
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
71
|
-
params = {
|
|
72
|
-
"name": name,
|
|
73
|
-
"displayName": display_name,
|
|
74
|
-
"fromLanguages": from_languages,
|
|
75
|
-
"toLanguages": to_languages,
|
|
76
|
-
"actionHandler": callback_url,
|
|
77
|
-
"actionDetectLang": detect_lang_callback_url,
|
|
78
|
-
}
|
|
79
|
-
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
80
|
-
|
|
81
|
-
def unregister(self, name: str, not_fail=True) -> None:
|
|
82
|
-
"""Removes Translations provider."""
|
|
83
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
84
|
-
try:
|
|
85
|
-
self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
86
|
-
except NextcloudExceptionNotFound as e:
|
|
87
|
-
if not not_fail:
|
|
88
|
-
raise e from None
|
|
89
|
-
|
|
90
|
-
def get_entry(self, name: str) -> TranslationsProvider | None:
|
|
91
|
-
"""Get information of the TranslationsProvider."""
|
|
92
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
93
|
-
try:
|
|
94
|
-
return TranslationsProvider(
|
|
95
|
-
self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
96
|
-
)
|
|
97
|
-
except NextcloudExceptionNotFound:
|
|
98
|
-
return None
|
|
99
|
-
|
|
100
|
-
def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
101
|
-
"""Report results of translation task to Nextcloud."""
|
|
102
|
-
require_capabilities("app_api", self._session.capabilities)
|
|
103
|
-
with contextlib.suppress(NextcloudException):
|
|
104
|
-
self._session.ocs(
|
|
105
|
-
"PUT",
|
|
106
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
107
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class _AsyncTranslationsProviderAPI:
|
|
112
|
-
"""Async API for Translations providers."""
|
|
113
|
-
|
|
114
|
-
def __init__(self, session: AsyncNcSessionApp):
|
|
115
|
-
self._session = session
|
|
116
|
-
|
|
117
|
-
async def register(
|
|
118
|
-
self,
|
|
119
|
-
name: str,
|
|
120
|
-
display_name: str,
|
|
121
|
-
callback_url: str,
|
|
122
|
-
from_languages: dict[str, str],
|
|
123
|
-
to_languages: dict[str, str],
|
|
124
|
-
detect_lang_callback_url: str = "",
|
|
125
|
-
) -> None:
|
|
126
|
-
"""Registers or edit the Translations provider."""
|
|
127
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
128
|
-
params = {
|
|
129
|
-
"name": name,
|
|
130
|
-
"displayName": display_name,
|
|
131
|
-
"fromLanguages": from_languages,
|
|
132
|
-
"toLanguages": to_languages,
|
|
133
|
-
"actionHandler": callback_url,
|
|
134
|
-
"actionDetectLang": detect_lang_callback_url,
|
|
135
|
-
}
|
|
136
|
-
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
137
|
-
|
|
138
|
-
async def unregister(self, name: str, not_fail=True) -> None:
|
|
139
|
-
"""Removes Translations provider."""
|
|
140
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
141
|
-
try:
|
|
142
|
-
await self._session.ocs("DELETE", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
143
|
-
except NextcloudExceptionNotFound as e:
|
|
144
|
-
if not not_fail:
|
|
145
|
-
raise e from None
|
|
146
|
-
|
|
147
|
-
async def get_entry(self, name: str) -> TranslationsProvider | None:
|
|
148
|
-
"""Get information of the TranslationsProvider."""
|
|
149
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
150
|
-
try:
|
|
151
|
-
return TranslationsProvider(
|
|
152
|
-
await self._session.ocs("GET", f"{self._session.ae_url}/{_EP_SUFFIX}", params={"name": name})
|
|
153
|
-
)
|
|
154
|
-
except NextcloudExceptionNotFound:
|
|
155
|
-
return None
|
|
156
|
-
|
|
157
|
-
async def report_result(self, task_id: int, result: str = "", error: str = "") -> None:
|
|
158
|
-
"""Report results of translation task to Nextcloud."""
|
|
159
|
-
require_capabilities("app_api", await self._session.capabilities)
|
|
160
|
-
with contextlib.suppress(NextcloudException):
|
|
161
|
-
await self._session.ocs(
|
|
162
|
-
"PUT",
|
|
163
|
-
f"{self._session.ae_url}/{_EP_SUFFIX}",
|
|
164
|
-
json={"taskId": task_id, "result": result, "error": error},
|
|
165
|
-
)
|
|
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
|
|
File without changes
|