-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reworked app-scopes definition (#83)
CI will fail, waiting for AppEcosystem update Signed-off-by: Alexander Piskun <[email protected]>
- Loading branch information
Showing
21 changed files
with
213 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.11.4-slim-bookworm | ||
|
||
COPY requirements.txt / | ||
ADD /src/ /app/ | ||
|
||
RUN \ | ||
python3 -m pip install -r requirements.txt && rm -rf ~/.cache && rm requirements.txt | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["python3", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: help | ||
help: | ||
@echo "Welcome to app_python_skeleton example. Please use \`make <target>\` where <target> is one of" | ||
@echo " " | ||
@echo " Next commands are only for dev environment with nextcloud-docker-dev!" | ||
@echo " They should run from the host you are developing on(with activated venv) and not in the container with Nextcloud!" | ||
@echo " " | ||
@echo " build-push build image and upload to ghcr.io" | ||
@echo " " | ||
@echo " deploy deploy example to registered 'docker_dev'" | ||
@echo " " | ||
@echo " run28 install app_python_skeleton for Nextcloud 28" | ||
@echo " run27 install app_python_skeleton for Nextcloud 27" | ||
@echo " " | ||
@echo " For development of this example use PyCharm run configurations. Development is always set for last Nextcloud." | ||
@echo " First run 'app_python_skeleton' and then 'make manual_register', after that you can use/debug/develop it and easy test." | ||
@echo " " | ||
@echo " manual_register perform registration of running 'app_python_skeleton' into 'manual_install' deploy daemon." | ||
|
||
.PHONY: build-push | ||
build-push: | ||
docker login ghcr.io | ||
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/py_app_v2-skeleton:latest . | ||
|
||
.PHONY: deploy | ||
deploy: | ||
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:deploy app_python_skeleton docker_dev \ | ||
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml | ||
|
||
.PHONY: run28 | ||
run28: | ||
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister app_python_skeleton --silent || true | ||
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton docker_dev -e --force-scopes | ||
|
||
.PHONY: run27 | ||
run27: | ||
docker exec master-stable27-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister app_python_skeleton --silent || true | ||
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton docker_dev -e --force-scopes | ||
|
||
.PHONY: manual_register | ||
manual_register: | ||
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton manual_install --json-info \ | ||
"{\"appid\":\"app_python_skeleton\",\"name\":\"App Python Skeleton\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"host\":\"host.docker.internal\",\"port\":9029,\"scopes\":{\"required\":[],\"optional\":[]},\"protocol\":\"http\",\"system_app\":0}" \ | ||
-e --force-scopes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0"?> | ||
<info> | ||
<id>app_python_skeleton</id> | ||
<name>App Python Skeleton</name> | ||
<summary>Nextcloud Python Application Skeleton</summary> | ||
<description> | ||
<![CDATA[Example of the Nextcloud application written in python]]> | ||
</description> | ||
<version>1.0.0</version> | ||
<licence>MIT</licence> | ||
<author mail="[email protected]" homepage="https://github.com/andrey18106">Andrey Borysenko</author> | ||
<author mail="[email protected]" homepage="https://github.com/bigcat88">Alexander Piskun</author> | ||
<namespace>PyAppV2_skeleton</namespace> | ||
<category>tools</category> | ||
<website>https://github.com/cloud-py-api/nc_py_api</website> | ||
<bugs>https://github.com/cloud-py-api/nc_py_api/issues</bugs> | ||
<repository type="git">https://github.com/cloud-py-api/nc_py_api</repository> | ||
<dependencies> | ||
<nextcloud min-version="27" max-version="28"/> | ||
</dependencies> | ||
<ex-app> | ||
<docker-install> | ||
<registry>ghcr.io</registry> | ||
<image>cloud-py-api/py_app_v2-skeleton</image> | ||
<image-tag>latest</image-tag> | ||
</docker-install> | ||
<scopes> | ||
<required> | ||
</required> | ||
<optional> | ||
</optional> | ||
</scopes> | ||
<protocol>http</protocol> | ||
<system>0</system> | ||
</ex-app> | ||
</info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nc_py_api[app] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Simplest example. | ||
""" | ||
|
||
from fastapi import FastAPI | ||
|
||
from nc_py_api import NextcloudApp | ||
from nc_py_api.ex_app import LogLvl, run_app | ||
|
||
APP = FastAPI() | ||
|
||
|
||
def enabled_handler(enabled: bool, nc: NextcloudApp) -> str: | ||
# This will be called each time application is `enabled` or `disabled` | ||
# All scopes that application required already granted before this step. | ||
# NOTE: `user` is unavailable on this step, so all NC API calls that require it will fail as unauthorized. | ||
print(f"enabled={enabled}") | ||
if enabled: | ||
nc.log(LogLvl.WARNING, f"Hello from {nc.app_cfg.app_name} :)") | ||
else: | ||
nc.log(LogLvl.WARNING, f"Bye bye from {nc.app_cfg.app_name} :(") | ||
# In case of an error, a non-empty short string should be returned, which will be shown to the NC administrator. | ||
return "" | ||
|
||
|
||
if __name__ == "__main__": | ||
run_app(APP, enabled_handler, "main:APP", log_level="trace") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
FROM python:3.11.4-bookworm | ||
|
||
COPY requirements.txt / | ||
ADD main.py /app/ | ||
ADD /src/ /app/ | ||
|
||
RUN \ | ||
apt-get update && \ | ||
apt-get install -y \ | ||
ffmpeg libsm6 libxext6 gifsicle | ||
|
||
RUN \ | ||
python3 -m pip install -r requirements.txt | ||
python3 -m pip install -r requirements.txt && rm -rf ~/.cache && rm requirements.txt | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["python3", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,12 @@ | |
<version>1.0.0</version> | ||
<licence>MIT</licence> | ||
<author mail="[email protected]" homepage="https://github.com/andrey18106">Andrey Borysenko</author> | ||
<author mail="[email protected]" homepage="https://github.com/bigcat88">Alexander Piskun</author> | ||
<namespace>ToGifExample</namespace> | ||
<category>tools</category> | ||
<website>https://github.com/cloud-py-api/nc_py_apy</website> | ||
<bugs>https://github.com/cloud-py-api/nc_py_apy/issues</bugs> | ||
<repository type="git">https://github.com/cloud-py-api/nc_py_apy</repository> | ||
<website>https://github.com/cloud-py-api/nc_py_api</website> | ||
<bugs>https://github.com/cloud-py-api/nc_py_api/issues</bugs> | ||
<repository type="git">https://github.com/cloud-py-api/nc_py_api</repository> | ||
<dependencies> | ||
<nextcloud min-version="27" max-version="28"/> | ||
</dependencies> | ||
|
@@ -23,6 +24,14 @@ | |
<image>cloud-py-api/to_gif</image> | ||
<image-tag>latest</image-tag> | ||
</docker-install> | ||
<scopes> | ||
<required> | ||
<value>2</value> | ||
</required> | ||
<optional> | ||
<value>32</value> | ||
</optional> | ||
</scopes> | ||
<protocol>http</protocol> | ||
<system>0</system> | ||
</ex-app> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
"""All possible ExApp stuff for NextcloudApp that can be used.""" | ||
from .defs import ApiScope, LogLvl | ||
from .integration_fastapi import ( | ||
enable_heartbeat, | ||
nc_app, | ||
set_enabled_handler, | ||
set_scopes, | ||
) | ||
from .integration_fastapi import nc_app | ||
from .ui.files import UiActionFileInfo, UiFileActionHandlerInfo | ||
from .uvicorn_fastapi import run_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.