Skip to content

API Documentation

Stefano edited this page Jul 12, 2019 · 2 revisions

Available API

Authentication
  • POST /api/v1/appmgr/tokenservice To create a new token
    • Use this function to create a new token. A username and password have to be passed as basic HTTP Authentication. For the moment, these credential are hardcoded (admin, admin_123) and the token is not checked by other functions.
  • DELETE /API/v1/appmgr/tokenservice/<token> To delete a valid token
    • Delete the token passed in the URL from the valid tokens. This function needs x-token-id field in the header to be executed
Devices
  • POST /api/v1/appmgr/devices To add a new device
    • Add a device to infrastructure. It requires a json data in the body with the following schema: { "port":8880, "ipAddress":"1.1.1.1", "username":"admin", "password":"test_psw"}
  • GET /api/v1/appmgr/devices?limit=100&offset=0&searchByTags=ciccio&searchByAnyMatch=123.12.1.2 To get devices from the database (all parameters are optionals)
    • Returns all the devices inserted. The output JSON is {"data": [{device1}, {device2} ...]}
Tags
  • POST /api/v1/appmgr/tags - To add a new tag to tag library
    • Create a new tag. It is not assigned to any device. It requires to pass data as JSON: {"name": "tagname"}
  • GET /api/v1/appmgr/tags - To get all tags from tag library
    • Returns all tags created in the system, with their ids
  • POST /api/v1/appmgr/tags/<tagid>/devices - To add a tag to selected devices (devices are provided as json data)
    • Tag a device with a specific tag. The tag is passed in URL, the device instead in the body as JSON array: {"devices":[deviceids]}}
Local Applications
  • POST /api/v1/appmgr/localapps/upload - To add an application from a file
    • Use this function to upload an application. It must have a package.yaml file formatted as required for the IOX Application. This API accepts the following headers: x-publish-on-upload
  • PUT /api/v1/appmgr/localapps/<appid>:<appversion> - To update the application metadata, e.g. published status
    • Update an application (i.e. publish it, change description...). The original API requires to have all the field returned by the GET API, this API accepts also only the changed field. The <appversion> can be omitted, in that case its value becomes 1.
  • DELETE /api/v1/appmgr/apps/<appid> - To delete the application (it have to be uninstalled from every device)
    • Delete an application passing its <appid> in the URL. This API accepts the following headers: x-unpublish-on-delete. If x-unpublish-on-delete is not specified, its values is false.
  • GET /api/v1/appmgr/localapps/ - Get all the app (published and unpublished)
MyApps (deployments)
  • POST /api/v1/appmgr/myapps - Before you can install an unpublished app on a device by using the API, you must create a myapp endpoint for the app. This API requires the following data: {"name":appname,"sourceAppName":"c36d727c-e9c5-46ed-bc7e-cbdd5cf49786:1.0","version":"1.0","appSourceType":"LOCAL_APPSTORE"} (in this simulator only LOCAL_APPSTORE type is supported)
  • DELETE /api/v1/appmgr/myapps/<myappid> - Delete the myapp endpoint. If the myapp is installed on some device, an error is returned.
  • GET /api/v1/appmgr/myapps?searchByName=name - Returns a JSON object that contains the myappId given the myappName (Not yet implemented)
MyApps actions
  • POST /api/v1/appmgr/myapps/<myappid>/action - Use this API to modify the state of the <myappid> myapp. For example, in order to deploy the app, you have to use the following JSON in the request data field:
{
 "deploy": {
   "config": {
     
   },
   "metricsPollingFrequency": "3600000",
   "startApp": true,
   "devices": [
     {
       "deviceId": "DEVICE_TO_INSTALL",
       "resourceAsk": {
         "resources": {
           "profile": "c1.tiny",
           "cpu": 100,
           "memory": 32,
           "network": [
             {
               "interface-name": "eth0",
               "network-name": "iox-bridge0"
             }
           ]
         }
       }
     }
   ]
 }
}

or, in order to start (respectivily, stop) myapp, you have to use the following Json object in the data field:

{"start":{}}
Alerts
  • GET /api/v1/appmgr/alerts - provides the alerts about the infrastructure and applications status