Skip to content
Pulkit Bhuwalka edited this page May 26, 2014 · 1 revision

About

This describes how to use the server to add models and associate them with devices.

Storing/Modifying models

A model is uniquely identified by its name and version. Every uploaded model should have both the fields. They also have 2 other fields active and archive. For a model with a particular name, you can have multiple you can only have one model marked as active. This field decides the model the client chooses to use at runtime. The archive field can be used for models that can be deprecated and are not needed now. Once a model is marked as archived, it won't be downloaded by the client.

Uploading a model to the server
curl -F "file=@src/main/resources/barometer-model.model" 'localhost:9979/maori-server/model?name=barometer&version=v2'

This API simply uploads a model to the server. It won't get downloaded to the client unless it is associated with a device. By default all models are in an active state.

Associate an already uploaded model with a device
curl -X POST 'localhost:9979/maori-server/model/device/associate?name=barometer&version=v2&deviceId=d1'

One model can be linked to multiple devices.

Activate/Deactivate a model [Unsupported at the moment]
curl -X PUT 'localhost:9979/maori-server/model/activate?name=barometer&version=v2&active=true'
Archive/Unarchive a model [Unsupported at the moment]
curl -X PUT 'localhost:9979/maori-server/model/activate?name=barometer&version=v2&archive=true'

Retrieving Models

Downloading a model
curl -X GET 'localhost:9979/maori-server/model?name=barometer&version=v1'

Returns the binary serialized model in Base64 encoded format.

curl -X GET 'localhost:9979/maori-server/model/info?deviceID=dev1'

Returns a JSON string representing all the models stored for a particular device.

{
    result: [
        { name: "barometer", version: "version1", active="true" },
        { name: "barometer", version: "version2", active="false" },
        { name: "accelerometer", version: "version1", active="true" },
    ]
}