Template Management

Templates are the fragments that make up the configuration system. Each template has a numeric ID which is automatically assigned by Arigi and uniquely identifies the template in the API, and a label which is human readable and not necessarily unique (although that is probably best).

A template has the following attributes:

label:

Human friendly label.

priority:

Numeric priority index.

op:

Operation to apply.

key:

Key into the configuration object where we apply the template operation.

template:

HJSON or Python (Starlark) template.

List Templates

GET /api/v1/templates

Returns the list of templates.

Example response:

[
    {
        "id": 1,
        "createdAt": "2017-10-28T10:20:05.535808929+02:00",
        "updatedAt": "2017-10-28T10:20:05.535808943+02:00",
        "label": "Disable NAT",
        "priority": 50,
        "key": "options.natEnabled",
        "op": "set",
        "template": "false\n"
    }
]

Set Template

POST /api/v1/templates
PUT /api/v1/templates/(int: templateID)

Creates (POST) or updates (PUT) an existing template.

Example request:

{
    "label": "Disable NAT",
    "priority": 50,
    "key": "options.natEnabled",
    "op": "set",
    "template": "false\n"
    }

Get Template

GET /api/v1/templates/(int: templateID)

Example response:

{
    "id": 1,
    "createdAt": "2017-10-28T10:20:05.535808929+02:00",
    "updatedAt": "2017-10-28T10:20:05.535808943+02:00",
    "label": "Disable NAT",
    "priority": 50,
    "key": "options.natEnabled",
    "op": "set",
    "template": "false\n"
}

Delete Template

DELETE /api/v1/templates/(int: templateID)

The response is 204 No Content on successfull delete.

Tag a Template

PUT /api/v1/templates/(int: templateID)/tags/(string: tag)

The response contains the resulting set of tags for the template.

Example response:

[
    "s1"
]

Untag a Template

DELETE /api/v1/templates/(int: templateID)/tags/(string: tag)

The response contains the resulting set of tags for the template, which is possibly the empty list.

Evaluate a Template (Existing Template)

GET /api/v1/templates/(int: templateID)/evaluate

Evaluates the template against an automatically chosen example device and returns the results, or an error. The request body is empty.

TBD: Example

Evaluate a Template (New Template)

POST /api/v1/templates/evaluate

Evaluates the template against an automatically chosen example device and returns the results, or an error. The template to evaluate is sent as the request body.

TBD: Example