From 42f1eae74085e8c706686558aa76da0ee97c2871 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:34:47 +0300 Subject: [PATCH] Add documentation for the create resource endpoint --- HUB_API.md | 40 ++++++++++++++++++++++++++++++++++++++++ qgis-app/api/urls.py | 2 +- qgis-app/api/views.py | 1 - 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 HUB_API.md diff --git a/HUB_API.md b/HUB_API.md new file mode 100644 index 00000000..f2e2eecd --- /dev/null +++ b/HUB_API.md @@ -0,0 +1,40 @@ +API URL Configuration +# QGIS Django API Documentation + +The `urlpatterns` list routes URLs to views. For more information please see: +[https://docs.djangoproject.com/en/3.2/topics/http/urls/](https://docs.djangoproject.com/en/3.2/topics/http/urls/) + +## Endpoints + +### Resources +- **URL:** `/resources/` +- **Method:** `GET` +- **View:** `ResourceAPIList.as_view()` +- **Name:** `resource-list` +- **Description:** Retrieves a list of all resources. + +### Resource by UUID +- **URL:** `/resource//` +- **Method:** `GET` +- **View:** `ResourceAPIDownload.as_view()` +- **Name:** `resource-download` +- **Description:** Downloads a specific resource identified by UUID. + +### Create Resource +- **URL:** `/resource/create` +- **Method:** `POST` +- **View:** `ResourceCreateView.as_view()` +- **Name:** `resource-create` +- **Description:** Creates a new resource. +- **Request example with cURL:** + ```sh + curl --location 'http://localhost:62202/api/v1/resource/create' \ + --header 'Authorization: Bearer ' \ + --form 'file=@"path/to/the/file.zip"' \ + --form 'thumbnail_full=@"path/to/the/thumbnail.png"' \ + --form 'name="My model"' \ + --form 'description="Little description"' \ + --form 'tags="notag"' \ + --form 'resource_type="model"' + ``` + diff --git a/qgis-app/api/urls.py b/qgis-app/api/urls.py index 87345ad2..0554ef44 100644 --- a/qgis-app/api/urls.py +++ b/qgis-app/api/urls.py @@ -15,7 +15,7 @@ "resource//", ResourceAPIDownload.as_view(), name="resource-download" ), path( - "resource/create", ResourceCreateView.as_view(), name="geopackage-create" + "resource/create", ResourceCreateView.as_view(), name="resource-create" ), url( r"^tokens/$", diff --git a/qgis-app/api/views.py b/qgis-app/api/views.py index 54c18225..e0683232 100644 --- a/qgis-app/api/views.py +++ b/qgis-app/api/views.py @@ -355,7 +355,6 @@ class ResourceCreateView(APIView): parser_classes = [MultiPartParser, FormParser] def post(self, request, *args, **kwargs): - print(request.data.get("resource_type")) if request.data.get("resource_type").lower() == "geopackage": serializer = GeopackageSerializer(data=request.data) elif request.data.get("resource_type").lower() == "3dmodel":