This document is a guide to using the JSON-RPC protocol to provide management of the configurations in the ConfigTree over an HTTP connection.
The ConfigTree Servlet maps the JSON-RPC methods to the Java methods of the ConfigTree API to carry out the RPC requests. It accepts HTTP parameters and returns JSON objects.
The ConfigTree JSON-RPC service is different than the other pure JSON-RPC services: it is HTTP servlet that returns JSON object but accepts HTTP GET parameters rather than JSON objects. Please see the examples below.
ConfigTree Functions
The following table contains the relevant JSON-RPC functions the ConfigTree module provides for configuration management:
Method |
Return Value |
Parameters |
Parameter Description |
|---|---|---|---|
configtree/importZip |
"OK" if all specified configurations from the ZIP file (containing several configurable types) were accepted, or |
|
The request should be sent as multipart/form-data.
|
configtree/exportZip |
Zipped data stream with the selected configurable types in the specified format. |
|
|
configtree/importConfig |
A JSON Status Object corresponding to the success of the importing operation of the single configurable type. |
|
The request should be sent as multipart/form-data.
|
configtree/exportConfig |
The configuration data stream in the specified format. |
|
|
configtree/getConfigurableTypes |
A string array of names of configurable types. |
- |
- |
configtree/getConfig |
A JSON Config Object defining the configuration node's children and their properties. |
|
|
configtree/setConfig |
A JSON Status Object corresponding to success, failure, or error details. |
|
|
configtree/setMap |
A JSON Status Object corresponding to success, failure, or error details. |
|
|
Common Objects Definitions
The following table contains definitions of the JavaScript objects involved in the JSON-RPC methods for configurations management.
Object |
Key |
Value |
|---|---|---|
Status |
|
|
Examples
This section provides few examples of how the ConfigTree Module supports remote communication over JSON-RPC.
<form action="http://localhost/configtree/importZip" enctype="multipart/form-data" method="POST">
<br /> Format:
<select name="format">
<option value="XML">XML</option>
<option value="BIN">BIN</option>
</select>
<br />IncludeAll<input type="checkbox" name="all"/>
<br />Config1<input type="text" name="config_0"/>
<br />Config2<input type="text" name="config_1"/>
<br />File<input type="file" name="file"/>
<br/>Submit: <input type="submit" value="Import"/>
</form>
[
{
"State": 1,
"ConfigType": "DEMO1"
},
{
"State": 1,
"ConfigType": "DEMO2"
}
]
<form action="http://localhost/configtree/getConfig" method="POST" >
<br />Configurable: <input type="text" name="type"/>
<br />Path: <input type="text" name="path"/>
<br />Submit: <input type="submit" value="Get Config"/>
</form>
{
"DATATYPE": ["1","byte"],
"FRONT_DOOR": {
"RINGTONE": ["callme.mp3","string"],
"RINGTIMEOUT": ["15","int"],
"OPENTIMEOUT": ["5","int"],
"RIGHT_CAMERA": {
"initcode": ["H#H335","string"],
"framerate": ["12","byte"]
},
"LEFT_CAMERA": {
"initcode": ["*335#","string"],
"framerate": ["10","byte"]
}
}
}
<form action="http://localhost/configtree/getConfigurableTypes" ><input type="submit" value="Get Configurables"/></form>
["DEMO1", "DEMO2"]