From: Michael Tremer Date: Sun, 15 Jun 2025 13:38:39 +0000 (+0000) Subject: api: Start a new test API using FastAPI X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1ffa3b29f08f46a57955d58ed40645c3815f63a;p=pbs.git api: Start a new test API using FastAPI Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 2f04929b..d139bc3f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,6 +120,13 @@ EXTRA_DIST += \ CLEANFILES += \ src/buildservice/constants.py +api_PYTHON = \ + src/api/__init__.py \ + src/api/app.py \ + src/api/builds.py + +apidir = $(pkgpythondir)/api + web_PYTHON = \ src/web/__init__.py \ src/web/auth.py \ @@ -393,6 +400,7 @@ static_fontsdir = $(staticdir)/fonts # ------------------------------------------------------------------------------ systemdsystemunit_DATA = \ + src/systemd/pakfire-api.service \ src/systemd/pakfire-web.service CLEANFILES += \ @@ -402,6 +410,7 @@ INSTALL_DIRS += \ $(systemdsystemunitdir) EXTRA_DIST += \ + src/systemd/pakfire-api.service.in \ src/systemd/pakfire-web.service.in dist_database_DATA = \ diff --git a/src/api/__init__.py b/src/api/__init__.py new file mode 100644 index 00000000..e8d2bddc --- /dev/null +++ b/src/api/__init__.py @@ -0,0 +1,24 @@ +############################################################################### +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2025 Pakfire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +# Import the app +from .app import app + +from . import builds diff --git a/src/api/app.py b/src/api/app.py new file mode 100644 index 00000000..ad273304 --- /dev/null +++ b/src/api/app.py @@ -0,0 +1,29 @@ +############################################################################### +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2025 Pakfire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +import fastapi + +app = fastapi.FastAPI( + title = "Pakfire Build Service API", + version = "0.0.1", + + # Enable debug mode + debug = True, +) diff --git a/src/api/builds.py b/src/api/builds.py new file mode 100644 index 00000000..f519329b --- /dev/null +++ b/src/api/builds.py @@ -0,0 +1,25 @@ +############################################################################### +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2025 Pakfire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +from .app import app + +@app.get("/builds/{build_id}") +async def get(build_id: str): + return { "GOT" : "HERE" } diff --git a/src/systemd/pakfire-api.service.in b/src/systemd/pakfire-api.service.in new file mode 100644 index 00000000..7969b0f2 --- /dev/null +++ b/src/systemd/pakfire-api.service.in @@ -0,0 +1,10 @@ +[Unit] +Description=Pakfire API +After=network.target + +[Service] +ExecStart=/usr/bin/uvicorn pbs.api:app --port=9001 +User=_pakfire + +[Install] +WantedBy=multi-user.target