This is an example on how to configure the ODS. Further documentation on the REST API can be found here:
- implementation of the REST api
- Postman collection
The placeholder {{ods_base_url}}
is represented as http://localhost:8080/ods/api/v1
in the default configuration.
As an example, the ODS is configured and used for PegelOnline as data source:
In this step the data source is configured. This contains the meta data of the source, like the origin, author, terms of use, etc. Additionally, the schema of the data source is provided, including which data is mandatory and which are optional.
By configuring a filter chain, simple steps towards the final data are executed. This includes specifying which adapter is used (protocol + format to retrieve the data). The DbInsertionFilter is responsible for persisting the data in the final format, the NotificationFilter triggers notifications. Additionally, some configuration of the filter chain can be given, like when it should be executed.
This represents a querying mechanism that operates on the stored data. It relies on the capabilities of the underlying CouchDB and uses an map-reduce-like syntax.
Fetching the data from the configured data view is a simple HTTP call. The format of the data depends on the prior steps.
HTTP PUT
on destination {{ods_base_url}}/datasources/pegelonline
Headers
Header | Value |
---|---|
Content-Type | application/json |
Authorization | Basic YWRtaW46N2tweWd2YXF0M3FwM25lMnY4YnpxYzJkcmdq |
Body
{
"domainIdKey": "/gaugeId",
"schema":
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"uuid": {
"type": "string"
},
"number": {
"type": "string"
},
"shortname": {
"type": "string"
},
"longname": {
"type": "string"
},
"km": {
"type": "number"
},
"agency": {
"type": "string"
},
"longitude": {
"type": "number"
},
"latitude": {
"type": "number"
},
"water": {
"type": "object",
"properties": {
"shortname": {
"type": "string"
},
"longname": {
"type": "string"
}
}
},
"timeseries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"shortname": {
"type": "string"
},
"longname": {
"type": "string"
},
"unit": {
"type": "string"
},
"equidistance": {
"type": "integer"
},
"currentMeasurement": {
"type": "object",
"properties": {
"timestamp": {
"type": "string"
},
"value": {
"type": "number"
},
"trend": {
"type": "integer"
},
"stateMnwMhw": {
"type": "string"
},
"stateNswHsw": {
"type": "string"
}
}
},
"gaugeZero": {
"type": "object",
"properties": {
"unit": {
"type": "string"
},
"value": {
"type": "integer"
},
"validFrom": {
"type": "string"
}
}
},
"characteristicValues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"shortname": {
"type": "string"
},
"longname": {
"type": "string"
},
"unit": {
"type": "string"
},
"value": {
"type": "integer"
},
"validFrom": {
"type": "string"
},
"timespanStart": {
"type": "string"
},
"timespanEnd": {
"type": "string"
},
"occurrences": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"metaData": {
"name": "de-pegelonline",
"title": "pegelonline",
"author": "Wasser- und Schifffahrtsverwaltung des Bundes (WSV)",
"authorEmail": "https://www.pegelonline.wsv.de/adminmail",
"notes": "PEGELONLINE stellt kostenfrei tagesaktuelle Rohwerte verschiedener gewässerkundlicher Parameter (z.B. Wasserstand) der Binnen- und Küstenpegel der Wasserstraßen des Bundes bis maximal 30 Tage rückwirkend zur Ansicht und zum Download bereit.",
"url": "https://www.pegelonline.wsv.de",
"termsOfUse": "http://www.pegelonline.wsv.de/gast/nutzungsbedingungen"
}
}
HTTP PUT
on destination {{ods_base_url}}/datasources/pegelonline/filterChains/mainFilter
Headers
Header | Value |
---|---|
Content-Type | application/json |
Authorization | Basic YWRtaW46N2tweWd2YXF0M3FwM25lMnY4YnpxYzJkcmdq |
Body
{
"processors" : [
{
"name" : "JsonSourceAdapter",
"arguments" : {
"sourceUrl" : "http://pegelonline.wsv.de/webservices/rest-api/v2/stations.json?includeTimeseries=true&includeCurrentMeasurement=true&includeCharacteristicValues=true"
}
},
{
"name" : "PegelOnlineMerger",
"arguments" : { }
},
{
"name" : "DbInsertionFilter",
"arguments" : {
"updateData" : true
}
},
{
"name" : "NotificationFilter",
"arguments" : { }
}
],
"executionInterval" : {
"period" : 60,
"unit" : "MINUTES"
}
}
HTTP PUT
on destination {{ods_base_url}}/datasources/pegelonline/views/someView
Headers
Header | Value |
---|---|
Content-Type | application/json |
Authorization | Basic YWRtaW46N2tweWd2YXF0M3FwM25lMnY4YnpxYzJkcmdq |
Body
{
"mapFunction": "function(doc) { emit(doc.viewId, doc); }"
}
HTTP GET
on destination {{ods_base_url}}/datasources/pegelonline/views/someView?execute=true
Headers
Header | Value |
---|---|
Content-Type | application/json |
Authorization | Basic YWRtaW46N2tweWd2YXF0M3FwM25lMnY4YnpxYzJkcmdq |