Skip to content

Commit 2a03e2a

Browse files
Add the /conformance, /api and /health endpoints
The landing surface gains GET /conformance (the OGC API – Moving Features and Common conformance classes), GET /api (an OpenAPI 3.0 service description of the served paths), and GET /health (a database-free liveness probe), matching the endpoints the Go tier exposes.
1 parent 37761aa commit 2a03e2a

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

server.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,26 @@ def do_GET(self):
150150
self.get_collection_id(collection_id, connection, cursor)
151151
return
152152

153+
# /health
154+
elif self.path == '/health':
155+
send_json_response(self, 200, {"status": "ok"})
156+
return
157+
158+
# /conformance
159+
elif self.path == '/conformance':
160+
self.do_conformance()
161+
return
162+
163+
# /api (OpenAPI service description)
164+
elif self.path == '/api':
165+
self.do_api()
166+
return
167+
153168
# / (home)
154169
elif self.path == '/':
155170
self.do_home()
156171
return
157-
172+
158173
def do_POST(self):
159174
# ==================================================== TEMPORAL PROPERTIES ========================================================
160175
# /collections/{collectionId}/items/{mFeatureId}/tproperties
@@ -240,6 +255,47 @@ def do_home(self):
240255
self.wfile.write(
241256
bytes("<html><head></head><p>Request: This is the base route of the pyApi</p>body></body></html>", "utf-8"))
242257

258+
def do_conformance(self):
259+
send_json_response(self, 200, {"conformsTo": [
260+
"http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/common",
261+
"http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/mf-collection",
262+
"http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/movingfeatures",
263+
"http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core",
264+
"http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections",
265+
]})
266+
267+
def do_api(self):
268+
def op(summary):
269+
return {"summary": summary, "responses": {"200": {"description": "OK"}}}
270+
271+
send_json_response(self, 200, {
272+
"openapi": "3.0.3",
273+
"info": {"title": "MobilityAPI", "version": "1.0.0",
274+
"description": "OGC API – Moving Features over MobilityDB (PyMEOS)"},
275+
"paths": {
276+
"/": {"get": op("Landing page")},
277+
"/api": {"get": op("API definition")},
278+
"/conformance": {"get": op("Conformance declaration")},
279+
"/collections": {"get": op("Collections"), "post": op("Register a collection")},
280+
"/collections/{collectionId}": {"get": op("Collection metadata"),
281+
"put": op("Replace collection"),
282+
"delete": op("Delete collection")},
283+
"/collections/{collectionId}/items": {"get": op("Moving features"),
284+
"post": op("Insert a moving feature")},
285+
"/collections/{collectionId}/items/{mFeatureId}": {"get": op("A moving feature"),
286+
"delete": op("Delete feature")},
287+
"/collections/{collectionId}/items/{mFeatureId}/tgsequence": {"get": op("Temporal geometry (MF-JSON)"),
288+
"post": op("Append a sub-trajectory")},
289+
"/collections/{collectionId}/items/{mFeatureId}/tgsequence/{tGeometryId}/{query}":
290+
{"get": op("Derived query: distance | velocity (acceleration → 501)")},
291+
"/collections/{collectionId}/items/{mFeatureId}/tproperties": {"get": op("Temporal properties"),
292+
"post": op("Add temporal properties")},
293+
"/collections/{collectionId}/items/{mFeatureId}/tproperties/{tPropertyName}":
294+
{"get": op("A temporal property"), "post": op("Append values"), "delete": op("Delete property")},
295+
"/collections/{collectionId}/bulk": {"post": op("Bulk ingest (extension): GeoJSON / GeoParquet fleet feed")},
296+
},
297+
})
298+
243299

244300
# ________________________________Class Moving Feature Collection_______________________________
245301
## Resource Collections

0 commit comments

Comments
 (0)