From: Michael Tremer Date: Sun, 15 Jun 2025 15:21:50 +0000 (+0000) Subject: API: Add method to fetch basic information about an upload X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e301be4384946f2931f1780e05ef892189a4d918;p=pbs.git API: Add method to fetch basic information about an upload Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index bc99be56..9b715146 100644 --- a/Makefile.am +++ b/Makefile.am @@ -122,7 +122,8 @@ CLEANFILES += \ api_PYTHON = \ src/api/__init__.py \ - src/api/builds.py + src/api/builds.py \ + src/api/uploads.py apidir = $(pkgpythondir)/api diff --git a/src/api/__init__.py b/src/api/__init__.py index c98c56ff..c5dfacce 100644 --- a/src/api/__init__.py +++ b/src/api/__init__.py @@ -47,3 +47,4 @@ app.add_middleware( # Load all further modules from . import builds +from . import uploads diff --git a/src/api/uploads.py b/src/api/uploads.py new file mode 100644 index 00000000..f1408528 --- /dev/null +++ b/src/api/uploads.py @@ -0,0 +1,37 @@ +############################################################################### +# # +# 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 +import uuid + +from . import app +from . import backend + +from .. import uploads + +@app.get("/uploads/{id}") +async def get(id: uuid.UUID) -> uploads.Upload: + upload = await backend.uploads.get_by_uuid(id) + + # Raise 404 if the upload could not be found + if not upload: + raise fastapi.HTTPException(404, "Upload not found") + + return upload