Closed giohappy closed 3 years ago
@afabiani I report here what I wrote inside the issue for Almaviva. I wouldn't adopt dynamic-rest. Even if understand the felxibility they provide they're toof ar from standard REST API structures. I would rather consider a nested structure, where nested endpoints provide additional response for a given resource (e.g. users/1/layers to obtain the layers for user 1, etc.).
@afabiani for the creation of the OpenAPI spec I would consider drf-yasg to automate the creation and keep the it aligned/inlined with the code.
/remind me to send a document with Work Packages for the REST API tender from Thunen the 21st September, 2020
@giohappy set a reminder for Sep 21st 2020
:wave: @giohappy, send a document with Work Packages for the REST API tender from Thunen the
GeoNode API v2 - Technical Proposal
We would like to create and document full CRUD REST APIs for GeoNode.
Pre-requisites and assumptions
django-guardian
"api/v2
" namespaceTechnical Proposal
Code prototype here: https://github.com/GeoNode/geonode/tree/rest_api_v2_proof_of_concept
The module
geonode.api
introduces a newrouter = routers.DynamicRouter()
The module
geonode.base.api
provides the defaultResourceBase
serializers and paginator other than basic serializer for base GeoNode types.Whenever we would need to extend the APIs on a new module, we can follow the approach below (example for
Layers
):<app_label>.api
<app_label>.urls
with the REST endpoint extension name (e.g.url(r'^', include('geonode.layers.api.urls'))
)<app_label>.api.urls
by inheriting therouter = routers.DynamicRouter()
from thegeonode.api
module, e.g.:Whenever we need to serialize a new instance of
geonode.base.ResourceBase
we could easily extend theResourceBaseSerializer
e.g.:Notice that we don't need to serialize again all the
ResourceBase
fields. They will be inherited from theResourceBaseSerializer
Outcome:
A&A
Currently we defined a sample custom permission class
geonode.base.api.permissions.IsOwnerOrReadOnly
which assigns read/write permissions to admin or owners of the resource.Similarly, we could extend or define further permissions classes baing able to assign permissions to the resources accordingly to a specific workflow logic.
Documentation
Official API documentation will be maintained through Swagger.io
Whenever the YAML will be fully defined, it can be easily attached to official GeoNode docs through the sphinxcontrib-openapi module extension.