Skip to main content

APIs

Data model

A config is just an String id and a json value :

{
"id": "my:id",
"value": "A value"
}

CRUD API

Configs expose a classic CRUD REST api :

List all

curl -X GET \
'http://localhost:9000/api/configs?pattern=*&page=1&pageSize=15' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' | jq

Will respond with a 200 status code:

{
"results": [
{
"id": "ragnar:lodbrok:email",
"value": { "email": "ragnar.lodbrok@gmail.com" }
}
],
"metadata": {
"page": 1,
"pageSize": 15,
"count": 1,
"nbPages": 1
}
}

The query params are optional and the value used in this example are the default one.

Create a config

curl -XPOST \
'http://localhost:9000/api/configs' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '{ "id": "ragnar:lodbrok:city", "value": {"city": "Kattegat"} }' | jq

Will respond with a 201 status code:

{
"id": "ragnar:lodbrok:city",
"value": { "city": "Kattegat" }
}

Get a config

curl -X GET \
'http://localhost:9000/api/configs/ragnar:lodbrok:city' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' | jq

Will respond with a 200 status code:

{
"id": "ragnar:lodbrok:city",
"value": {
"city": "Kattegat"
}
}

Update a config

curl -X PUT \
'http://localhost:9000/api/configs/ragnar:lodbrok:city' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '{ "id": "ragnar:lodbrok:city", "value": {"city": "Northumbria"} }' | jq

Will respond with a 200 status code:

{
"id": "ragnar:lodbrok:city",
"value": {
"city": "Northumbria"
}
}

Patch a config

Partial updates can be done using json patch :

curl -X PATCH \
'http://localhost:9000/api/configs/ragnar:lodbrok:city' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '[{"op": "replace", "path": "/value", "value": {"city": "Northumbria"} }]' | jq

Will respond with a 200 status code:

{
"id": "ragnar:lodbrok:city",
"value": {
"city": "Northumbria"
}
}

Delete a config

curl -X DELETE \
'http://localhost:9000/api/configs/ragnar:lodbrok:city' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' | jq

Will respond with a 200 status code:

{
"id": "ragnar:lodbrok:city",
"value": {
"city": "Northumbria"
}
}

Tree API

The tree api format the response as tree. Be careful using this API because the results are not paged so be sure to use an appropriate pattern :

For example if we create this datas :

curl -XPOST \
'http://localhost:9000/api/configs' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '{ "id": "ragnar:lodbrok:city", "value": "{\"city\": \"Kattegat\"}" }' | jq

curl -XPOST \
'http://localhost:9000/api/configs' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '{ "id": "ragnar:lodbrok:email", "value": "\"ragnar.lodbrok@gmail.com\"" }' | jq

And then use the tree APIs

curl -X GET \
'http://localhost:9000/api/tree/configs?pattern=ragnar:*' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' | jq

We will get the following response:

{
"ragnar": {
"lodbrok": {
"city": {
"city": "Kattegat"
},
"email": {
"email": "ragnar.lodbrok@gmail.com"
}
}
}
}

As you can see, the keys are split with : and the json and the json values are expended into a tree representation.

Download and Upload

Download and upload is done using the nd-json format.

Download

curl -X GET \
'http://localhost:9000/api/configs.ndjson' \
-H 'Content-Type: application/json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' | jq

Will return each item separated by a \n.

{
"id": "ragnar:lodbrok:city",
"value": {"city": "Northumbria"}
}
{
"id": "ragnar:lodbrok:email",
"value": {"email": "ragnar.lodbrok@gmail.com"}
}

Upload

curl -X POST \
'http://localhost:9000/api/configs.ndjson' \
-H 'Content-Type: application/nd-json' \
-H 'Izanami-Client-Id: xxxx' \
-H 'Izanami-Client-Secret: xxxx' \
-d '{ "id": "ragnar:lodbrok:city", "value": {"city": "Northumbria"}" }
{"id": "ragnar:lodbrok:email", "value": {"email": "ragnar.lodbrok@gmail.com"}}' \
| jq

Will return

{
"success": 2,
"errors": {
"errors": [],
"fieldErrors": {}
}
}