Layers of Code
The code of DSO-API has the following layers:
The dso_api.dynamic_api
provides the dynamic API.
For this, it uses the datasets definitions that schematools.contrib.django
provides.
REST API Logic
The REST API code is based on Django REST Framework. There are 3 layers:
Generic REST Framework
Generic DSO compatibility
Application choices (like blending Amsterdam Schema into API policies).
The generic DSO compatibility layer is implemented in the rest_framework_dso
package,
so it could be moved out to a official PyPI package.
This implements most features like embedding or the ?_fields=...
parameter.
The specific logic to generate the API is implemented in the dso_api.dynamic_api
package.
This involves transforming an Amsterdam Schema / DynamicModel into the serializer layout,
applying policies such as authorization/time-travel filtering based on schema data.
The Schematools Package
The schematools
package fulfills a special role. It contains all fundamental parts
that can be shared with other applications. Specifically of interest are:
schematools.types
contains Python wrappers for the Amsterdam Schema file format.schematools.contrib.django
stores those schema definitions into Django models.
The schematools
package also provides a CLI: schema
with various useful command-line tools such as:
schema import geojson ...
schema import ndjson ...
schema introspect db ...
schema introspect geojson ...
More information can be found using schema --help
and checking
the README file.