Every server extension defines a set of configuration data
in its *.Schema.json
file.
The "ComplexConfig" sample extension is a server extension
with relatively complex configuration data.
Additionally, the configuration data can be viewed/edited via
the server configuration page.
If you want to learn about JSON schema and how to use
(recursive) definitions, this is a good starting point.
The extension uses the "RequestListener" interface to provide
functions to interact with the configuration data.
The implementations of the ComplexConfig.MarkAsDone
and
ComplexConfig.CreateReport
function symbols
showcase the usage of the GetConfigValue
, ReplaceConfigValue
and RenameConfigValue
functions that are used by almost
all server extensions.
First steps:
-
Read all data from the "Garden" project.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.Config::projects::Garden", "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.Config::projects::Garden", "readValue": { "done": [], "reports": [], "todo": [ { "name": "Mow the lawn" }, { "name": "Plant trees", "notes": [ { "children": [ { "text": "Oak" }, { "text": "Maple" } ], "text": "Species" } ] } ] } } ] }
-
Move a
todo
list item to thedone
list using theComplexConfig.MarkAsDone
function symbol.Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.MarkAsDone", "writeValue": { "project": "Garden", "index": 1 }, "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.MarkAsDone" } ] }
-
Add a summary of all the items from the
done
list to thereports
array. Then clear thedone
array. We do this by calling theComplexConfig.CreateReport
function symbol.Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.CreateReport", "writeValue": { "project": "Garden" }, "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.CreateReport" } ] }
-
Read all data from the "Garden" project after calling
ComplexConfig.MarkAsDone
andComplexConfig.CreateReport
.Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.Config::projects::Garden", "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "ComplexConfig.Config::projects::Garden", "readValue": { "done": [], "reports": [ "# Done in the week of Monday, February 20, 2023\r\n1. Plant trees\r\n - Species\r\n - Oak\r\n - Maple\r\n" ], "todo": [ { "name": "Mow the lawn" } ] } } ] }