]> git.ipfire.org Git - pbs.git/commitdiff
API: Start some event websocket thing
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Jun 2025 09:42:28 +0000 (09:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Jun 2025 09:42:28 +0000 (09:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/api/__init__.py
src/api/events.py [new file with mode: 0644]

index 588bd0ed26600b5f659ee7eca53e6937ab226596..7a216f5fb55934c05284e995e1de44b18239a5ee 100644 (file)
@@ -124,6 +124,7 @@ api_PYTHON = \
        src/api/auth.py \
        src/api/builders.py \
        src/api/builds.py \
+       src/api/events.py \
        src/api/uploads.py
 
 apidir = $(pkgpythondir)/api
index 24625a266a416fc16b1779e5e465a2034f5488a1..c0cb3caa6115d5c447b9283add60077b70cb4f7f 100644 (file)
@@ -54,6 +54,7 @@ apiv1 = fastapi.APIRouter(
 from . import auth
 from . import builders
 from . import builds
+from . import events
 from . import uploads
 
 # Add the APIv1 to the app
diff --git a/src/api/events.py b/src/api/events.py
new file mode 100644 (file)
index 0000000..c0f945e
--- /dev/null
@@ -0,0 +1,43 @@
+###############################################################################
+#                                                                             #
+# 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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import fastapi
+
+from . import apiv1
+from . import backend
+
+# Create a new router for all events endpoints
+router = fastapi.APIRouter(
+       prefix="/events",
+       tags=["Events"],
+)
+
+@router.websocket("")
+async def stream(websocket: fastapi.WebSocket):
+       # Accept the connection
+       await websocket.accept()
+
+       # XXX Do something for now...
+       while True:
+               data = await websocket.receive_text()
+
+
+# Add everything to the APIv1
+apiv1.include_router(router)