Configuration API Usage Guide
Quick Usage
- With a user under tenant
MASTER_CONFIG
create a config module in YAML withPOST /modules/{module}
with headersAccept: text/yaml
andContent-type: text/yaml
. You must also have user roleCMS_CONFIG_ADMIN
to save. - Retrieve that YAML configuration under the same user with
GET /modules/{module}
andAccept: text/yaml
. - With a different user under a different tenant (e.g.
TENANT_X
), retrieve the master config withGET /modules/{module}
andAccept: text/yaml
. The configuration will be the same as from the first step. - Still under tenant
TENANT_X
, create a config module in YAML withPOST /modules/{module}
with headersAccept: text/yaml
andContent-type: text/yaml
. You must also have user roleCMS_CONFIG_ADMIN
to save. - Retrieve that YAML configuration with
GET /modules/{module}
andAccept: text/yaml
. It will be the YAML ofTENANT_X
, notMASTER_CONFIG
. - If you delete (
DELETE /modules/{module}
) the above module underTENANT_X
, then you will still retrieve the config fromMASTER_CONFIG
. - If the module does not exist in either
MASTER_CONFIG
norTENANT_X
, then a 404 response will be returned.
In-Depth Usage
Save YAML, Retrieve JSON
You can configurations in basic YAML (no fragments or aliases) with comments on their own line. Here are some examples:
YAML (PUT/POST
and Content-type: text/yaml
)
# This is a comment
foo: bar
JSON (GET
and Accept: application/json
)
{"foo": "bar"}
and
YAML (PUT/POST
and Content-type: text/yaml
)
# This is a comment
foo:
bar:
- 1
- 2
# That was an array
JSON (GET
and Accept: application/json
)
{"foo":{"bar":[1,2]}}
Note: Comments must be treated with the same care as keys and values with respect to indentation, and must be on their own lines. Here are some examples of unacceptable YAML snippets:
foo: # This is an invalid comment (must be on a new line)
foo:
# This is an invalid comment
bar: 'baz'
foo:
# This is an invalid comment
bar: 'baz'
foo:
# This is a valid comment
bar: 'baz'
Drill Down into Configurations
You can drill down into a configuration to avoid editing and retrieving one massive configuration. Given
foo:
bar:
baz: 'hello'
you can query GET /modules/{module}/foo/bar
(Accept: application/json
) to retrieve simply
{"baz": "hello"}
Similarly with PUT
, if you run PUT /modules/{module}/foo/bar
with the following YAML payload
baz: 'goodbye'
and query the full YAML (Accept: text/yaml
), you will get
foo:
bar:
baz: 'goodbye'
This makes it convenient to work with sections of a module.
History of Modules
When a PUT
operation is made, a history of previous configs is appended.
- Under a user of a given tenant, perform
GET /history/modules/{module}
withAccept: text/yaml
. - You should get a history array similar to the following.
The first entry is the current configuration. Timestamps are given in two formats, the first being since epoch in seconds. The[ { "id": -1, "timestamp": 1613069544, "vancouverTime": "2021-02-11T10:52:24", "config": "alerts:\n table:\n defaultSort:\n ...", "sizeChars": 30894 }, { "id": 2182, "timestamp": 1612981332, "vancouverTime": "2021-02-10T10:22:12", "config": "alerts:\n table:\n defaultSort:\n ...", "sizeChars": 30894 },
sizeChars
is the length of the given configuration in ASCII characters. - Without adding parameters, the max history entries returned is 100 because the response payload can grow to several megabytes otherwise.
- You can add the
?limit=[1..100]
and?page=[0..n]
parameters to control paging. - You can select a date range with
?fromDateInclusive=
and?toDateExclusive=
subject to the 100 entry limit. - Use epoch seconds as dates, or ISO8601 dates in the above date query parameters.
- By adding
?brief=true
, you can get the same history array without the config fields populated, and the page limit increases to 1000 (e.g.?limit=[1..1000]
).[ { "id": -1, "timestamp": 1613069544, "vancouverTime": "2021-02-11T10:52:24", "config": null, "sizeChars": 30894 }, { "id": 2182, "timestamp": 1612981332, "vancouverTime": "2021-02-10T10:22:12", "config": null, "sizeChars": 30894 },
- Specify
?id=n
if you want to retrieve a known history entry by id. - Deleting a module deletes the history of that module, so be careful.