Difference between revisions of "Rifidi App API"

From RifidiWiki

Jump to: navigation, search
(Command Example)
(set group properties command example)
Line 297: Line 297:
 
Response success (in this case, if property already exists in properties file in file system, it is updated; otherwise it is added at the end of properties file. And if properties file does not exist in file system, it is created, according to structure and naming conventions):
 
Response success (in this case, if property already exists in properties file in file system, it is updated; otherwise it is added at the end of properties file. And if properties file does not exist in file system, it is created, according to structure and naming conventions):
  
http://localhost:8111/setAppProperties/7/LLRP_3_stableSetTime=7.0;anotherProp=val1
+
http://localhost:8111/setGroupProperties/7/threadSleepTime=800;mqttQos=3
  
 
<pre>
 
<pre>
Line 308: Line 308:
 
Response fail (if there is a bad formed property=value pair):
 
Response fail (if there is a bad formed property=value pair):
  
http://localhost:8111/setAppProperties/7/LLRP_3_stableSetTime;anotherProp=val1
+
http://localhost:8111/setGroupProperties/7/threadSleepTime=800;mqttQos
  
 
<pre>
 
<pre>
Line 314: Line 314:
 
<response>
 
<response>
 
   <message>Fail</message>
 
   <message>Fail</message>
   <description>Property with no recognizable value: LLRP_3_stableSetTime</description>
+
   <description>Property with no recognizable value: mqttQos</description>
 
</response>
 
</response>
 
</pre>
 
</pre>
Line 320: Line 320:
 
Response fail (if there is no application given the id):
 
Response fail (if there is no application given the id):
  
http://localhost:8111/setAppProperties/87/LLRP_3_stableSetTime=4.0;anotherProp=val1
+
http://localhost:8111/setGroupProperties/71/threadSleepTime=800;mqttQos=3
  
 
<pre>
 
<pre>
Line 326: Line 326:
 
<response>
 
<response>
 
   <message>Fail</message>
 
   <message>Fail</message>
   <description>Application with id 87 does not exist.</description>
+
   <description>Application with id 71 does not exist.</description>
 
</response>
 
</response>
 
</pre>
 
</pre>

Revision as of 21:12, 5 November 2014

Introduction

Starting in Rifidi 3.1, Rifidi Apps can now be manged via rest

Note: In order for the properties to take effect the associated Rifidi App will need to be stopped and started. This allows for more fine grain control of when properties should take effect (as opposed to having the apps restart dynamically as properties change while a app is running)

The operations available are:

  • Get/Stop/Start App
  • Get/Set Application and Group Properties
  • Get/Add Delete Readzones
  • Get/Set Readzone Properties

Command Example

Note: localhost can be substituted with IP address/Host name of Rifidi Edge Server. Port can be changed in Rifidi configuration

apps command example

  • apps - returns a list of available applications

Request (via HTTP Post/Get) "apps" command like this:

http://localhost:8111/apps

Response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <apps>
      <app>
         <id>AppService:ReadZones</id>
         <number>0</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:SensorStatus</id>
         <number>1</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>RifidiManagement:RifidiManagementApp</id>
         <number>2</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:UniqueTagInterval</id>
         <number>3</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:StableSet</id>
         <number>4</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:LimitStableSet</id>
         <number>5</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:UniqueTagBatchInterval</id>
         <number>6</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>AppService:RSSI</id>
         <number>7</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>Diagnostic:GPIO</id>
         <number>8</number>
         <status>STOPPED</status>
      </app>
      <app>
         <id>Diagnostic:Serial</id>
         <number>9</number>
         <status>STOPPED</status>
      </app>
      <app>
         <id>Diagnostic:Tags</id>
         <number>10</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>Diagnostic:TagGenerator</id>
         <number>11</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>Monitoring:ReadZones</id>
         <number>12</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>Monitoring:Tags</id>
         <number>13</number>
         <status>STARTED</status>
      </app>
      <app>
         <id>Monitoring:SensorStatus</id>
         <number>14</number>
         <status>STARTED</status>
      </app>
   </apps>
</response>

stopapp command example

  • stopapp/{appID} - stops a Rifidi Application

Request (via HTTP Post/Get) "stopapp" command like this:

http://localhost:8111/stopapp/2

Response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Success</message>
</response>

startapp command example

  • startapp/{appID} - starts a Rifidi Application

Request (via HTTP Post/Get) "startapp" command like this:

http://localhost:8111/startapp/2

Response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Success</message>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>

Response fail (if there is no application given the id):

http://localhost:8111/getAppProperties/85

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application with id 85 does not exist.</description>
</response>

set application properties command example

  • setAppProperties/{appID}/{properties} - sets a list of properties for an application

Request (via HTTP Post/Get) "setAppProperties" command like this:

Response success (in this case, if property already exists in properties file in file system, it is updated; otherwise it is added at the end of properties file. And if properties file does not exist in file system, it is created, according to structure and naming conventions):

http://localhost:8111/setAppProperties/7/LLRP_3_stableSetTime=7.0;anotherProp=val1

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Success</message>
</response>

Response fail (if there is a bad formed property=value pair):

http://localhost:8111/setAppProperties/7/LLRP_3_stableSetTime;anotherProp=val1

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Property with no recognizable value: LLRP_3_stableSetTime</description>
</response>

Response fail (if there is no application given the id):

http://localhost:8111/setAppProperties/87/LLRP_3_stableSetTime=4.0;anotherProp=val1

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application with id 87 does not exist.</description>
</response>

get group properties command example

  • getGroupProperties/{appID} - returns a list of properties for a group

Request (via HTTP Post/Get) "getGroupProperties" command like this:

Response success:

http://localhost:8111/getGroupProperties/7

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>mqttClientId</key>
         <value>stablesetstationApp</value>
      </entry>
      <entry>
         <key>threadSleepTime</key>
         <value>500</value>
      </entry>
      <entry>
         <key>mqttQos</key>
         <value>2</value>
      </entry>
      <entry>
         <key>mqttBroker</key>
         <value>tcp://localhost:1883</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getGroupProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Group properties file not found for groupName: AppService</description>
</response>

Response fail (if there is no application given the id):

http://localhost:8111/getGroupProperties/85

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application with id 85 does not exist.</description>
</response>

set group properties command example

  • setGroupProperties/{appID}/{properties} - sets a list of properties for a group

Request (via HTTP Post/Get) "setGroupProperties" command like this:

Response success (in this case, if property already exists in properties file in file system, it is updated; otherwise it is added at the end of properties file. And if properties file does not exist in file system, it is created, according to structure and naming conventions):

http://localhost:8111/setGroupProperties/7/threadSleepTime=800;mqttQos=3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Success</message>
</response>

Response fail (if there is a bad formed property=value pair):

http://localhost:8111/setGroupProperties/7/threadSleepTime=800;mqttQos

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Property with no recognizable value: mqttQos</description>
</response>

Response fail (if there is no application given the id):

http://localhost:8111/setGroupProperties/71/threadSleepTime=800;mqttQos=3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application with id 71 does not exist.</description>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>

get application properties command example

  • getAppProperties/{appID} - returns a list of properties for an application

Request (via HTTP Post/Get) "getAppProperties" command like this:

Response success:

http://localhost:8111/getAppProperties/10

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <attributes>
      <entry>
         <key>RecentTagTimeout</key>
         <value>1 min</value>
      </entry>
      <entry>
         <key>LazyStart</key>
         <value>false</value>
      </entry>
   </attributes>
</response>

Response fail (if there is no properties file in file system):

http://localhost:8111/getAppProperties/3

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <message>Fail</message>
   <description>Application properties file not found for groupName: AppService and appName: StableSet</description>
</response>