This addon, designed for any KMF offers a generic way to interact with model (read/write) using a classic but efficient REST API. This addon is implemented as a server that can be embedded in any Java project (JS version to come in NodeJS soon).
The goal of such Rest Server is to offers a standard way to interact with model for devices that cann't run for technical reasons KMF API. For instance, Arduino or ESP 8266 based devices (AVR processor) can't for memory reason load the fll KMF stack. However, they are powerful enough to load an HTTP stack and theirfore they can through such connection push data to a model. Such usage make particular sense because Arduino like devices host usually sensors, they should be considered as edges in IoT networks.
The following picture give a short overview about the target architecture. In a nutshell, HTTP Path are mapped to KMF Queries to retreive or select KMF Objects, and the payload follows the JSON format for get and put operations.
In particular this REST offers the ability to manipulated model according to time and universes of KMF.
It interesting to notice that every REST HTTP get and put request start by two long attribute /0/10
the first one is the universe ID (virtually a working space) the second is simply a timestamp to reflect the time of the measurement. The KMF semamtic will return the closest well know time in case of GET and will update the current time for the
No particular dependency to compile, tested on Java 8.
mvn clean install
Simply add the plugin to your Maven project.
<dependency>
<groupId>org.kevoree.modeling.plugin</groupId>
<artifactId>rest</artifactId>
<version>4.27.0</version>
</dependency>
Then in you main or any kind of place of your Java platform, wrap the model into a Rest Gateway server and start it.
RestGateway gateway = RestGateway.expose(cloudModel, 8050);
gateway.start();
Replace the 8050 by the expected port where you want to expose your HTTP server.
TODO
This plugin leverage the great Undertow library in order to implement the HTTP server.