Skip to content

Commit

Permalink
Add documentation for the create resource endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Sep 19, 2024
1 parent 42a5db2 commit 42f1eae
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
40 changes: 40 additions & 0 deletions HUB_API.md
Original file line number Diff line number Diff line change
@@ -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/<uuid:uuid>/`
- **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 <my_token>' \
--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"'
```

2 changes: 1 addition & 1 deletion qgis-app/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"resource/<uuid:uuid>/", 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/$",
Expand Down
1 change: 0 additions & 1 deletion qgis-app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 42f1eae

Please sign in to comment.