API Reference
The Config Tree Admin API is intended to provide tools help with administration of Trees. These administration functions are provided as a separate API for security reasons. The Admin API needs to be explicitly included to use these admin functions keeping access separate from the main app permissions.
The API includes the following functions:
- an iterator function to walk the current list of trees.
- an import function to bulk load the data (full or partial) into a tree from a given file in .cfg format or .json format.
- an export function to save the contents of a tree.
- a delete function to remove a tree and all its objects.
Example of Iterating the List of Trees:
void ListTrees(void)
{
LE_INFO(
"Listing configuration Trees in the current system...");
{
char treeName[MAX_TREE_NAME_BYTES] = "";
{
}
}
}
Example of Importing a Tree:
void ImportMyTree(const char* filePath)
{
static char resolvedPath[PATH_MAX] = "";
LE_FATAL_IF(realpath(filePath, resolvedPath) == NULL,
"Could not resolve filePath: error %d",
errno);
"Error occured while writing config data.");
}
ImportMyData("./myData.cfg");
Supported JSON Types:
Primitive Types:
The template of a string type config field is as follows:
{
"name": "aStringField",
"type": "string",
"value": "someStringValue"
}
Example:
{
"name": "valueA",
"type": "string",
"value": "aNewValue"
}
- Integer
The template of a integer type config field is as follows:
@code
{
"name": "anIntField",
"type": "int",
"value":
}
Example:
{
"name": "valueA",
"type": "int",
"value": 1024
}
The template of a string type config field is as follows:
{
"name": "aFloatField",
"type": "float",
"value":
}
Example:
{
"name": "valueA",
"type": "float",
"value": 10.24
}
The template of a string type config field is as follows:
{
"name": "aBoolField",
"type": "bool",
"value":
}
Example:
{
"name": "valueA",
"type": "bool",
"value": false
}
Nested value:
The template of a string type config field is as follows:
{
"name": "aNestedValue",
"type": "stem",
"children": []
}
Example:
{
"name": "nestedValues",
"type": "stem",
"children": [
{
"name": "aBoolValue",
"type": "bool",
"value": true
},
{
"name": "aSecondBoolValue",
"type": "bool",
"value": false
},
{
"name": "aStringValue",
"type": "string",
"value": "Something \"wicked\" this way comes!"
},
{
"name": "anIntVal",
"type": "int",
"value": 1024
},
{
"name": "aFloatVal",
"type": "float",
"value": 10.24
}
]
}
Example of Exporting a Tree
void ExportMyData(const char* filePath)
{
static char resolvedPath[PATH_MAX] = "";
LE_FATAL_IF(realpath(filePath, resolvedPath) == NULL,
"Could not resolve filePath: error %d",
errno);
"Error occured while writing config data.");
}
ExportMyData("./myData.cfg");
Example of Deleting a Tree
Copyright (C) Sierra Wireless Inc.