77 Commits

Author SHA1 Message Date
2ef33a042f fix(cli): do not remove persistent storage by default in ExApp unregister command (#381)
Do not remove ExApp docker volume by default, deprecate old option
`keep-data`, add new `rm-data` to remove ExApp data.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2024-09-06 21:09:54 +03:00
1eab9f6814 feat: remove ApiScopes (#373)
Ongoing optimization, unnecessary stuff removal to reduce the number of
requests during AppAPIAuth.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-09-04 20:37:02 +03:00
65003cd5d1 ExApp routes (public/user/admin) support (#327)
This PR introduces new (mandatory if you use the ExApp proxy) registration of the routes that are allowed to call on ExApp via AppAPI ExApp proxy.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-08-02 16:47:06 +03:00
eea14dc504 optimization: system flag and ex_app_users removal (#323)
The system flag and extra table for that `ex_app_users` is removed to
optimize database usage and simplify the system logic.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2024-07-11 17:08:52 +00:00
5503b80879 Add occ command for sending events truly async (#295)
This PR introduces our internal occ command for sending a request to
ExApp with notification about an event happened. The occ command is
needed to perform the HTTP request in a truly async maner not blocking
the original PHP process during request, that have to improve the user
experience.
The request is limited to 2s timeout, so that this occ command process
shouldn't live too long to not exceed the limits.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-05-22 19:23:00 +03:00
3d503b3403 drop ExApp scopes table, rewrite code of it (#285)
This is ongoing part of optimizations of reducing the number of
database/cache requests.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-05-07 10:50:51 +03:00
af00e1787f Test deploy adjustments (#280)
Test Deploy fixes, timeout logic adjustments, docs.
2024-04-30 13:59:54 +03:00
3bf5132211 feat: Test deploy feature (#279)
This PR introduces a "Test deploy" button for each Daemon configuration
to verify each step and identify the error.

Resolves: https://github.com/cloud-py-api/app_api/issues/174

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-04-29 13:36:32 +03:00
7391eeea65 initial support for Docker Healthcheck (#273)
Before this, we didn’t have a `healthcheck` at all, but instead there
was simply a check to see if the container was running.

Checking whether the container is running has been moved to Deploy stage
and now occurs at the end of the deployment process.
And between deployment and “init” there is now a correct health check.
Applications are not required to support healthcheck at all, so it is
only checked if `['State']['Health']['Status']` is present.

Without a timeout, the timeout must be set by the application itself, as
it is usually done for Docker containers healthcheck.

During a healthcheck, an application, for example, can now install some
of its own packages or do something other with its docker container.

It should not communicate with the Nextcloud itself at this
stage(healthcheck), because application is not considered enabled.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Andrey Borysenko <andrey18106x@gmail.com>
2024-04-17 11:41:04 +03:00
9fb115bca6 Admin options adjustments (different compute devices support) (#267)
Minor fixes, adjusted Admin settings UI and backend part with optional
compute device (NVIDIA/ADM/CPU) daemon configuration.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2024-04-09 16:06:42 +03:00
36c2db5835 removed "ex_apps_api_scopes" table (#262)
We hold pre-defined API Scopes in memory only.

Anyway we currently do not supporting defining API Scopes at runtime and
not sure that we will in future, so better to make it simpler and faster
for now.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-04-04 12:05:23 +03:00
508ecaa4aa added "all" and "showonly" flags to occ app:update (#256)
They do almost the same like the original flags from Server repo with
one difference:

`--showonly` flag can be specified only with `--all` flag.

We can not easy make `--showonly` work for specified appid, cause we
support updating ExApps with specifyng `json` or `xml` and not only by
`appid`.

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-03-28 11:24:24 +03:00
f7eefb801b performance: store API scopes as a list in the main table (#254)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-03-27 19:24:34 +03:00
1abe49909b made the "system" flag much cleaner (#237)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-02-21 16:52:19 +03:00
078e5eb862 reset "Error state" during Updating/Enabling of ExApp (#236)
This will fix situations when ExApp after update or enabling work
without errors, but state of previous error is still in DB and UI
displays an error when all is already ok.

Also now we set 'error'(empty) always be present in "status" to allow us
in future not check for it presence.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-02-21 13:02:41 +03:00
071b763624 feat(l10n): L10N support for ExApps (#227)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2024-02-20 20:41:05 +03:00
c7d1c3e8b8 "Deploy" removed, Register Rework (#233)
PR should not break anything, for old parts added a workarounds, that we
will remove in a month when all ExApps will publish their updates.

**Changes**:

* UI now use the same algorithm/code for ExApp `register` & `update` as
the CLI commands.
* Deprecated "deploy" command, now `register` commands performs deploy.

**Refactoring**:

* Removed internal `DispatchInit` command, as from CLI we already can do
it without spawning additional process.
* Removed hack(`status['active']`) when we have some half-enabled state
of ExApp when it is not enabled, but already can call APIs, now ExApp
enables before calling `/init`
* Made code more consistent in many place.

OTHER CHANGES FOR DEVS:

* For `--json-info` parameter in occ `register` command keys renamed:
"appid" -> "id", "system_app" -> "system"

_Old naming is still supported but will be removed in future, in such
way we make consistent parameters between `info.xml` and `--json-info`._

----

Related: #219 
_AppAPI will perform deploy & registration in a background and issue
should be fixed_

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Andrey Borysenko <andrey18106x@gmail.com>
2024-02-19 18:50:06 +03:00
6521901eb5 occ:app_api:app:deploy - remove -e option (#222)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-02-02 13:51:12 +03:00
7ad5541eae removed "optional API Scope" support (#220)
* added URL encoding for Docker Container Pull action
* added two logs with `info` level for PullImage action
* removed "optional API Scope" support
* added AppAPI options toggles in Admin settings
* added RestartPolicy option to created containers

CI fails unrelated:
https://github.com/pytest-dev/pytest-asyncio/issues/737

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Nextcloud bot <bot@nextcloud.com>
Co-authored-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Nextcloud bot <bot@nextcloud.com>
Co-authored-by: rakekniven <2069590+rakekniven@users.noreply.github.com>
2024-02-01 21:58:00 +03:00
003794670a Daemon Templates, Docker Socket Proxy, AppAPI 2.0 (#212) 2024-01-25 12:33:48 +00:00
4168cbbd60 ExApp status: do not encode & decode with hands (#211)
ExApp.php:
```php
$this->addType('status', 'string');
```
->
```php
$this->addType('status', 'json');
```

In DB we already have this field marked as json.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2024-01-15 12:41:08 +03:00
bab7bee306 getRegisteredDaemonConfigs: always return array (#197)
Changed loglevel to debug(we should stick in all Services to loglevel
`info` or `debug`).

It is used in 3 places, one place is already covered with log level, two
more are in UI and it will visible in UI if returned array is empty.
2024-01-05 13:39:34 +03:00
c91dc38731 remove double "daemonConfigService->unregisterDaemonConfig" call (#196)
Looks like it was a typo during initial fast development, I did not find
today any reason to perform a call

```php

$this->daemonConfigService->unregisterDaemonConfig($daemonConfig)

```

two times in a row.
2024-01-04 23:38:36 +03:00
f078ee9c7c occ app:register -> return error if specified invalid info-xml (#195)
If the `php occ app_api:app:register ... --info-xml` parameter is
specified, then we should return an error if the file is not available
for the specified parameter, rather than silently ignoring it.
2024-01-04 23:23:25 +03:00
fece759690 occ app_api:app:register error message (#172)
When someone accidentally register ExApp with `occ` without deploy it
shows incorrect error, that leads to bug misunderstanding.
2023-12-19 21:00:03 +03:00
bc454cae77 fix: remove last slash in url (#170)
Resolves: #169

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-12-19 15:24:48 +03:00
480d59c96e Adjustments of NVIDIA GPU support in Docker containers (#130)
Resolves: #117

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2023-11-27 19:10:12 +03:00
ec0324b0df Rework of App:Register (#128)
Fixes: #122


1. Made sending the "init" request in a separate process
2. If "init" request fails with STATUS_NOT_IMPLEMENTED or
STATUS_NOT_FOUND sets the progress to 100
3. Added `wait-finish` optional parameter to `app_api:app:register` occ
command.

What is missing:

- [x] Global option: how long the "/init" request can be proceed.
- [x] Docs update for this
- [x] Update nc_py_api CI for this
- [x] Added test for registering ExApp that does not have "/init"
endpoint.


This allows to implement ExApp without "/init" endpoint and made it
optional.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Co-authored-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-11-27 15:31:37 +03:00
9ce6fc33fa occ app_api:app:unregister rework (#127)
Fixes #121

- small actions clean up
- added basic but very useful tests for "occ app_api:app:unregister"

Changes in behaviour:

- container of app is always removed
- volume  with data is removed by default, but optionally can be kept
- app_api does not try to disable ExApp if it is already disabled
- "--silent" options now means "max silence as possible"
- added "--force" option to ignore errors if any.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2023-11-26 12:21:31 +03:00
83333b5e0a cleanup: Qualifier -> Imports (#125)
Fixes IDE warnings:

* Qualifier can be replaced with an import
* Argument matches the parameter's default value

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2023-11-25 10:59:07 +03:00
b0e06fe4a1 property declaration/assigment php8.0 style (#124)
* removed property declaration/assigment
* added "void" return type to subclasses of Command class.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
2023-11-24 15:11:37 +03:00
e409b7e0ce ExApp init, disable apps actions if daemon not accessible (#96)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-10-19 17:28:52 +03:00
8017dba784 UI implementation(appstore, daemons) (#77)
- [ ] polish
- [ ] update docs with screenshots

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2023-10-02 20:55:33 +03:00
1a91d3ebf8 added heartbeat check for manual-install register (#75)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-09-14 20:12:53 +03:00
8b3f129143 app_ecosystem_v2 to app_api renaming(1) (#68)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-09-11 12:42:34 +03:00
8e94d8a411 small general adjustments for AIO compatibility (#63)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-09-04 12:24:38 +03:00
efa55ea343 use ApiScopes names instead of numbers (#51)
- [ ] Update ExApps used in tests to provide textual scopes (ApiScope
names)

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-08-22 19:46:19 +03:00
ba9f61c556 DeployActions code fixes (#46) 2023-08-21 14:59:02 +03:00
36be89c48e Deploy actions updates (#43)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-08-16 13:17:17 +03:00
98944bd698 Refactoring and cleanup. Added OCS API enable/disable ExApp (#38)
Resolves: #37 

- [x] Cleanup routes
- [x] Fixed lint workflow
2023-08-09 23:33:26 +03:00
fbe08c79e7 Fix scopes mapping (wrong input array) (#32)
Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com>
2023-08-07 22:48:55 +03:00
08b72fe3cf Notifications adjustments. DeployActions. Docs updates (#25)
- [x] DeployActions interface
- [x] Notifications adjustments (receive dynamic parameters to build
known subjects)
- [ ] Write docs about FileActionsMenu, Notifications

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-08-02 14:07:07 +03:00
fef5e65d91 config command fixes, remove deprecated annotation reflector (#22)
Resolves: #21

Changes:

- [x] do not update sensitive flag each time config value updated
- [x] remove deprecated and unused `IControllerMethodReflector` in
`AppEcosystemAuthMiddleware`
2023-07-25 21:41:17 +03:00
0a6b653bfa Project updates (#19)
Changes:

- [x] Removed license comments from the beginning of files
- [x] Added LICENSE-README and AUTHORS
- [x] Added Notifications API draft
- [x] Updated Readme
- [x] Updated docs (authentication, development)
- [x] Added app icon license
- [x] Added issue templates
2023-07-24 23:13:04 +03:00
3ff978e660 Caching adjustments. Refactoring, use service layers with caching (#14)
Changes:

- [x] removed last_response_time and related functions
- [x] renamed last_response_time->last_check_time usage (getExApps) in
nc_py_api @bigcat88
- [x] added docker container healthcheck before heartbeat exApp in
deployment process @andrey18106
- [x] added php lint, cs, psalm, security cheks ci @andrey18106 
- [x] reviewed caches usage
- [x] reviewed exception handling and logging
- [x] added ci for tests with redis
- [x] php-cs fixes

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-07-22 14:05:17 +03:00
acdfce5ea7 Deploy logic adjustments. Refactoring. Manual install (#13)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-07-15 14:28:12 +03:00
47e9111211 Moved ssl settings to deploy config (#12)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-07-14 16:54:50 +03:00
e8ff4c60a6 Dev: docs draft (#11)
TODO:
- [ ] Move SSL config to DaemonConfig->deployConfig
2023-07-14 02:10:32 +03:00
0d64fb2e35 DB changes. Added unique name for daemon config to use it instead of ID (#10)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Alexander Piskun <bigcat88@icloud.com>
2023-07-13 21:10:21 +03:00
8cefdd2086 support of NC26(#9)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Co-authored-by: Andrey Borysenko <andrey18106x@gmail.com>
2023-07-13 19:09:57 +03:00