Configs

List configs

Get a list of configs.

GET /api/v1/configs/{?page,limit,filter,sort}

URL Parameters

Name Description
page integer (optional) See Paging
limit integer (optional) See Paging
detailed boolean (optional) See Summary / Detailed Representations
filter string (optional) See Filtering
sort string (optional) See Sorting

Response 200 OK

{
    "timestamp": "2016-04-15T10:19:06.600730366-04:00",
    "data": [
        {
            "id": "162",
            "name": "acs.conf",
            "description": "",
            "created": "2015-10-14T10:56:22.525869-04:00",
            "updated": "2016-04-13T15:07:44.342508-04:00",
            "locked": false,
            "user_id": "1",
            "tags": [],
            "nta_platform": "NTA1000"
        },
        {
            "id": "127",
            "name": "default.conf",
            "description": "default config",
            "created": "2013-07-30T12:40:19-04:00",
            "updated": "2016-04-13T15:07:44.300477-04:00",
            "locked": false,
            "user_id": "1",
            "tags": [
                "bar",
                "baz"
            ],
            "nta_platform": "NTA1000"
        },
        {
            "id": "126",
            "name": "all.conf",
            "description": "all",
            "created": "2013-07-30T12:40:55-04:00",
            "updated": "2016-04-13T15:07:44.327596-04:00",
            "locked": false,
            "user_id": "1",
            "tags": [
                "bar",
                "foo"
            ],
            "nta_platform": "NTA1000"
        }
    ],
    "links": {
        "current": 1,
        "first": 1,
        "last": 10,
        "limit": 3,
        "next": 2,
        "total": 30
    }
}

Get a new config

Get output of cdrouter-cli -new-config.

GET /api/v1/configs/?template=default

Response 200 OK

{
    "timestamp": "2016-04-15T11:17:56.930163989-04:00",
    "data": "SECTION \"About\" {\n\n    # Cable/DSL Router Test Suite\n..."
}

Get a config

Get a config.

GET /api/v1/configs/{id}/

Response 200 OK

{
    "timestamp": "2016-04-15T10:21:05.999909819-04:00",
    "data": {
        "id": "162",
        "name": "acs.conf",
        "description": "",
        "created": "2015-10-14T10:56:22.525869-04:00",
        "updated": "2016-04-13T15:07:44.342508-04:00",
        "locked": false,
        "contents": "testvar lanIp 192.168.1.2\ntestvar wanMode DHCP\n",
        "user_id": "1",
        "tags": [],
        "note": "",
        "interfaces": [
                {
                        "name": "lan",
                        "value": "eth1",
                        "is_wireless": false,
                        "is_ics": false
                },
                {
                        "name": "wan",
                        "value": "eth2",
                        "is_wireless": false,
                        "is_ics": false
                }
        ],
        "nta_platform": "NTA1000"
    }
}

Response 404 Not Found

{
    "error": "no such config"
}

Get a config as plaintext

Get a config as plaintext.

GET /api/v1/configs/{id}/?format=text

Response 200 OK

Content-Type: text/plain
Content-Disposition: inline; filename="{name}.txt"

testvar lanIp 192.168.1.1
testvar wanMode PPPoE

Response 404 Not Found

{
    "error": "no such config"
}

Create a config

Create a new config.

POST /api/v1/configs/

Example

{
    "contents": "testvar lanIp 192.168.1.1\ntestvar wanMode PPPoE\n",
    "name": "new config",
    "description": "my new config",
    "tags": [
        "one",
        "two",
        "three"
    ]
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:22:57.215100915-04:00",
    "data": {
        "id": "1017",
        "name": "new config",
        "description": "my new config",
        "created": "2016-04-15T10:22:57.17705281-04:00",
        "updated": "2016-04-15T10:22:57.17705281-04:00",
        "locked": false,
        "contents": "testvar lanIp 192.168.1.1\ntestvar wanMode PPPoE\n",
        "user_id": "1",
        "tags": [
            "one",
            "three",
            "two"
        ],
        "note": "",
        "interfaces": [
                {
                        "name": "lan",
                        "value": "eth1",
                        "is_wireless": false,
                        "is_ics": false
                },
                {
                        "name": "wan",
                        "value": "eth2",
                        "is_wireless": false,
                        "is_ics": false
                }
        ],
        "nta_platform": "NTA1000"
    }
}

Edit a config

Edit a config.

PATCH /api/v1/configs/{id}/

Example

PATCH /api/v1/configs/123/
{
    "name": "new config",
    "description": "my not so new config",
    "contents": "testvar lanIp 192.168.1.1\ntestvar wanMode PPPoE\n",
    "user_id": "1",
    "tags": [
        "one",
        "three",
        "two"
    ]
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:28:53.440760029-04:00",
    "data": {
        "id": "1017",
        "name": "new config",
        "description": "my not so new config",
        "created": "2016-04-15T10:22:57.177053-04:00",
        "updated": "2016-04-15T10:28:53.396094424-04:00",
        "locked": false,
        "contents": "testvar lanIp 192.168.1.1\ntestvar wanMode PPPoE\n",
        "user_id": "1",
        "tags": [
            "one",
            "three",
            "two"
        ],
        "note": "",
        "interfaces": [
                {
                        "name": "lan",
                        "value": "eth1",
                        "is_wireless": false,
                        "is_ics": false
                },
                {
                        "name": "wan",
                        "value": "eth2",
                        "is_wireless": false,
                        "is_ics": false
                }
        ],
        "nta_platform": "NTA1000"
    }
}

Delete a config

Delete a config.

DELETE /api/v1/configs/{id}/

Response 204 No Content

Lock a config

Lock a config. Locking a config prevents it from being modified or deleted until it is unlocked.

POST /api/v1/configs/{id}/lock

Response 200 OK

{
  "timestamp": "2023-03-29T15:38:27.983437345-04:00",
  "data": {
    "id": "3",
    "name": "acs.conf",
    "description": "foo bar",
    "created": "2020-07-15T15:37:30.907349-04:00",
    "updated": "2022-11-16T09:01:24.342727-05:00",
    "locked": true,
    "contents": "SECTION \"About\" {\n\n    # Cable/DSL...",
    "user_id": "1",
    "tags": [
      "lan-eth1",
      "wan-eth2"
    ],
    "note": ""
  }
}

Unlock a config

Unlock a config. Unlocking a locked config allows it to be modified or deleted once again.

POST /api/v1/configs/{id}/unlock

Response 200 OK

{
  "timestamp": "2023-03-29T15:38:27.983437345-04:00",
  "data": {
    "id": "3",
    "name": "acs.conf",
    "description": "foo bar",
    "created": "2020-07-15T15:37:30.907349-04:00",
    "updated": "2022-11-16T09:01:24.342727-05:00",
    "locked": false,
    "contents": "SECTION \"About\" {\n\n    # Cable/DSL...",
    "user_id": "1",
    "tags": [
      "lan-eth1",
      "wan-eth2"
    ],
    "note": ""
  }
}

Get a config’s shares

Get shares for a config.

GET /api/v1/configs/{id}/shares

Response 200 OK

{
    "timestamp": "2016-04-15T10:00:22.32676552-04:00",
    "data": [
        {
            "user_id": "307",
            "read": true,
            "write": false,
            "execute": false
        },
        {
            "user_id": "309",
            "read": true,
            "write": false,
            "execute": false
        }
    ]
}

Edit a config’s shares

Edit shares for a config.

PATCH /api/v1/configs/{id}/shares

Example

PATCH /api/v1/configs/123/shares
{
    "user_ids": [
        309,
        307
    ]
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:00:22.32676552-04:00",
    "data": [
        {
            "user_id": "309",
            "read": true,
            "write": false,
            "execute": false
        },
        {
            "user_id": "307",
            "read": true,
            "write": false,
            "execute": false
        }
    ]
}

Export a config

Export a config.

GET /api/v1/configs/{id}/?format=gz

Response 200 OK

Content-Type: application/x-gzip
Content-Disposition: inline; filename="{name}.gz"

Check a config

Process config contents with cdrouter-cli -check-config.

POST /api/v1/configs/?process=check

Example

POST /api/v1/configs/?process=check
{
    "contents": "testvar wanMode invalid\n"
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:50:35.855609092-04:00",
    "data": {
        "errors": [
            {
                "lines": [
                    "1"
                ],
                "error": "testvar 'wanMode' with value 'invalid' is invalid:\nBad value 'invalid', must be 'static', 'DHCP', 'PPPoE', 'PPPoA', 'PPTP', 'L2TP', 'dslite', 'none'"
            }
        ]
    }
}

Upgrade a config

Process config contents with cdrouter-cli -upgrade-config.

POST /api/v1/configs/{?process=upgrade,migrate}

URL Parameters

Name Description
process string (required) Must be upgrade
migrate boolean (optional) If true, also migrate config to current NTA platform.

Example

Upgrade (and migrate) the a config. The nta_platform field in the request body is only necessary when ?migrate=true. When ?migrate=true in the request, the response body’s data.nta_platform field gives the config’s new NTA platform.

POST /api/v1/configs/?process=upgrade&migrate=true
{
    "contents": "testvar wanMode DHCP\n",
    "nta_platform": "NTA1000"
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:54:43.424425881-04:00",
    "data": {
        "success": true,
        "output": "SECTION \"About\" {\n\n    # Cable/DSL Router Test Suite\n    # \n...",
        "nta_platform": "NTA3000"
    }
}

Get a config’s networks

Process config contents with cdrouter-cli -print-networks-json.

POST /api/v1/configs/?process=networks

Example

POST /api/v1/configs/?process=networks
{
    "contents": "testvar wanMode DHCP\n"
}

Response 200 OK

{
    "timestamp": "2016-04-15T10:56:41.604750532-04:00",
    "data": {
        "name": "DUT",
        "type": "root",
        "side": "root",
        "children": [
            {
                "name": "lan (enp6s5f0)",
                "type": "ethernet-interface",
                "side": "lan",
                "title": "lanMode: DHCP"
            },
            {
                "name": "wan (enp6s5f1)",
                "type": "ethernet-interface",
                "side": "wan",
                "title": "wanMode: static | VLAN: 100 | TR-069, Multicast, RADIUS interface",
                "children": [
                    {
                        "name": "RADIUS Server (3.3.3.44)",
                        "type": "address",
                        "side": "wan",
                        "title": "wanRadiusIp"
                    },
                    {
                        "name": "ISP's WAN IP Address/Netmask",
                        "type": "network",
                        "side": "wan",
                        "title": "wanIspIp/wanIspMask (202.254.1.1/24)",
                        "children": [
                            {
                                "name": "Free ISP Address (202.254.1.3)",
                                "type": "address",
                                "side": "wan",
                                "title": "wanIspNextIp"
                            },
                            {
                                "name": "ISP's WAN IP Address (202.254.1.1)",
                                "type": "address",
                                "side": "wan",
                                "title": "wanIspIp"
                            },
                            {
                                "name": "Assigned WAN IP Address (202.254.1.2)",
                                "type": "address",
                                "side": "wan",
                                "title": "wanIspAssignIp"
                            },
                            {
                                "name": "DHCP Pool-DHCP Pool End (202.254.1.11-202.254.1.20)",
                                "type": "address",
                                "side": "wan",
                                "title": "dhcpClientStart-dhcpClientEnd"
                            }
                        ]
                    },
                    ...
                ]
            }
        ]
    }
}

Get a config’s interfaces

Process config contents with cdrouter-cli -print-interfaces.

POST /api/v1/configs/?process=interfaces

Example

POST /api/v1/configs/?process=interfaces
{
    "contents": "testvar lanInterface eth1\ntestvar wanInterface wifi0\n"
}

Response 200 OK

{
    "timestamp": "2022-02-14T10:37:07.88200925-05:00",
    "data": [
        {
            "name": "lan",
            "value": "eth1",
            "is_wireless": false,
            "is_ics": false
        },
        {
            "name": "wan",
            "value": "wifi0",
            "is_wireless": true,
            "is_ics": false
        }
    ]
}

Bulk export configs

Bulk export a set of configs.

GET /api/v1/configs/{?bulk=export,ids}

URL Parameters

Name Description
bulk string (required) Must be export
ids string (required) Comma-separated config IDs to export

Example

GET /api/v1/configs/?bulk=export&ids=123,456,789

Response 200 OK

Content-Type: application/x-gzip
Content-Disposition: inline; filename="configs-{timestamp}.gz"

Bulk copy configs

Bulk copy a set of configs.

POST /api/v1/configs/?bulk=copy

Example

POST /api/v1/configs/?bulk=copy
{
    "configs": [
        {"id": "162"},
        {"id": "127"}
    ]
}

Response 200 OK

Returns configs array containing new configs copied from input IDs.

{
    "timestamp": "2016-04-15T10:31:43.137280238-04:00",
    "data": [
        {
            "id": "1018",
            "name": "Config A (copy 1).conf",
            "description": "",
            "created": "2015-10-14T10:56:22.525869-04:00",
            "updated": "2016-04-13T15:07:44.342508-04:00",
            "locked": false,
            "contents": "testvar lanIp 192.168.1.1\ntestvar wanMode PPPoE\n",
            "user_id": "1",
            "tags": []
        },
        {
            "id": "1019",
            "name": "Config B (copy 1).conf",
            "description": "",
            "created": "2013-07-30T12:40:19-04:00",
            "updated": "2016-04-13T15:07:44.300477-04:00",
            "locked": false,
            "contents": "testvar lanIp 192.168.1.2\ntestvar wanMode DHCP\n",
            "user_id": "1",
            "tags": [
                "foo"
            ]
        }
    ]
}

Bulk edit configs

Bulk edit a set of configs.

POST /api/v1/configs/{?bulk=edit,filter,all}

URL Parameters

Name Description
bulk string (required) Must be edit
filter string (optional) See Filtering
all boolean (optional) If true, apply edits to all configs.

Example

Bulk edit configs 5 and 286, setting their user_id field to 3 and tags field to ["foo", "bar", "baz"]. Also, bulk set the testvar ipv6FirewallUdpOpenPorts to 8080, delete the testvar l2tpPassword from testvar group lan2, create the testvar group wan2 and delete the testvar group lan3.

The action field for each object in the testvars array must be set-testvar, delete-testvar, create-group or delete-group. If not specified, action defaults to set-testvar.

POST /api/v1/configs/?bulk=edit
{
    "configs": [
        {
            "id": "5"
        },
        {
            "id": "286"
        }
    ],
    "fields": {
        "user_id": "3",
        "tags": [
            "foo",
            "bar",
            "baz"
        ]
    },
    "testvars": [
        {
            "name": "ipv6FirewallUdpOpenPorts",
            "value": "8080",
            "action": "set-testvar"
        },
        {
            "group": "lan2",
            "name": "l2tpPassword",
            "action": "delete-testvar"
        },
        {
            "group": "wan2",
            "action": "create-group"
        },
        {
            "group": "lan3",
            "action": "delete-group"
        }
    ]
}

Bulk edit configs matching filters user_id=3 and tags@>{working}, setting their tags field to ["not working"].

POST /api/v1/configs/?bulk=edit&filter=user_id=3&filter=tags@>{working}
{
    "fields": {
        "tags": [
            "not working"
        ]
    }
}

Bulk edit configs matching filters tags@>{vlan,l2tp}, setting their testvars l2tpPassword to 123456 and wanVlanId to 123.

POST /api/v1/configs/?bulk=edit&filter=tags@>{vlan,l2tp}
{
    "testvars": [
        {
            "name": "l2tpPassword",
            "value": "123456",
            "action": "set-testvar"
        },
        {
            "name": "wanVlanId",
            "value": "123",
            "action": "set-testvar"
        }
    ]
}

Bulk edit all configs, setting their user_id field to 3.

POST /api/v1/configs/?bulk=edit&all=true
{
    "fields": {
        "user_id": "3"
    }
}

Response 204 No Content

Bulk upgrade configs

Bulk upgrade a set of configs.

POST /api/v1/configs/{?bulk=upgrade,filter,all,migrate}

URL Parameters

Name Description
bulk string (required) Must be upgrade
filter string (optional) See Filtering
all boolean (optional) If true, upgrade all configs.
migrate boolean (optional) If true, also migrate configs to current NTA platform.

Example

Bulk upgrade (and migrate) configs 5 and 286.

POST /api/v1/configs/?bulk=upgrade&migrate=true
{
    "configs": [
        {
            "id": "5"
        },
        {
            "id": "286"
        }
    ]
}

Bulk upgrade configs matching filters user_id=3 and tags@>{working}.

POST /api/v1/configs/?bulk=upgrade&filter=user_id=3&filter=tags@>{working}

Bulk upgrade configs matching filters tags@>{vlan,l2tp}.

POST /api/v1/configs/?bulk=upgrade&filter=tags@>{vlan,l2tp}

Bulk upgrade all configs.

POST /api/v1/configs/?bulk=upgrade&all=true

Response 204 No Content

Bulk delete configs

Bulk delete a set of configs.

POST /api/v1/configs/{?bulk=delete,filter,all}

URL Parameters

Name Description
bulk string (required) Must be delete
filter string (optional) See Filtering
all boolean (optional) If true, delete all configs.

Example

Bulk delete configs 5 and 286.

POST /api/v1/configs/?bulk=delete
{
    "configs": [
        {"id": "5"},
        {"id": "286"}
    ]
}

Bulk delete configs matching filters user_id=3 and tags@>{not working}.

POST /api/v1/configs/?bulk=delete&filter=user_id=3&filter=tags@>{not working}

Bulk delete all configs.

POST /api/v1/configs/?bulk=delete&all=true

Response 204 No Content

List a config’s testvars

Get a list of a config’s testvars.

GET /api/v1/configs/{id}/testvars/

Response 200 OK

{
    "timestamp": "2016-04-15T11:00:48.368133838-04:00",
    "data": [
        {
            "group": "main",
            "name": "ipv6FirewallUdpOpenPorts",
            "value": "",
            "default": "",
            "isdefault": true,
            "line": 0
        },
        {
            "group": "main",
            "name": "l2tpPassword",
            "value": "qacafe123",
            "default": "qacafe123",
            "isdefault": true,
            "line": 0
        },
        {
            "group": "main",
            "name": "wanInnerVlanId",
            "value": "",
            "default": "",
            "isdefault": true,
            "line": 0
        }
    ]
}

Get a config’s testvar

Get a testvar from a config.

GET /api/v1/configs/{id}/testvars/{name}/{?group}

URL Parameters

Name Description
group string (optional) Testvar group to use. Default: main

Example

GET /api/v1/configs/123/testvars/lanIp/?group=lan2

Response 200 OK

{
    "timestamp": "2016-05-11T09:23:12.439841033-04:00",
    "data": {
        "group": "lan2",
        "name": "lanIp",
        "value": "192.168.2.1",
        "default": "192.168.2.1",
        "isdefault": true,
        "line": 0
    }
}

Edit a config’s testvar

Edit a testvar in a config.

PATCH /api/v1/configs/{id}/testvars/{name}/{?group}

URL Parameters

Name Description
group string (optional) Testvar group to use. Default: main

Example

PATCH /api/v1/configs/123/testvars/lanIp/?group=lan2
{
    "value": "192.168.2.4"
}

Response 200 OK

{
    "timestamp": "2016-05-11T09:23:12.439841033-04:00",
    "data": {
        "group": "lan2",
        "name": "lanIp",
        "value": "192.168.2.4",
        "default": "192.168.2.1",
        "isdefault": false,
        "line": 1558
    }
}

Delete a config’s testvar

Delete a testvar in a config. Deleting a testvar unsets any explicitly configured value for it in the config.

DELETE /api/v1/configs/{id}/testvars/{name}/{?group}

URL Parameters

Name Description
group string (optional) Testvar group to use. Default: main

Example

DELETE /api/v1/configs/123/testvars/lanIp/?group=lan2

Response 204 No Content

Create a testvar group within a config

Create a testvar group within in a config.

POST /api/v1/configs/{id}/testvars/{?group}

URL Parameters

Name Description
group string Testvar group to use. Default: main

Example

POST /api/v1/configs/123/testvars/?group=lan2

Response 204 No Content

Delete a testvar group within a config

Delete a testvar group within in a config.

DELETE /api/v1/configs/{id}/testvars/{?group}

URL Parameters

Name Description
group string Testvar group to use. Default: main

Example

DELETE /api/v1/configs/123/testvars/?group=lan2

Response 204 No Content

Bulk edit a config’s testvars

Bulk edit a config’s testvars.

POST /api/v1/configs/{id}/testvars/?bulk=edit

URL Parameters

Name Description
bulk string (required) Must be edit

Example

The action field for each object in the request body must be set-testvar, delete-testvar, create-group or delete-group. If not specified, action defaults to set-testvar.

POST /api/v1/configs/123/testvars/?bulk=edit
[
    {
        "group": "main",
        "name": "ipv6FirewallUdpOpenPorts",
        "value": "8080",
        "action": "set-testvar"
    },
    {
        "group": "main",
        "name": "l2tpPassword",
        "value": "321efac",
        "action": "set-testvar"
    },
    {
        "group": "main",
        "name": "wanInnerVlanId",
        "value": "100",
        "action": "set-testvar"
    }
]

Response 200 OK

{
    "timestamp": "2016-04-15T11:00:48.368133838-04:00",
    "data": [
        {
            "group": "main",
            "name": "ipv6FirewallUdpOpenPorts",
            "value": "8080",
            "default": "",
            "isdefault": false,
            "line": 123
        },
        {
            "group": "main",
            "name": "l2tpPassword",
            "value": "efac321",
            "default": "qacafe123",
            "isdefault": false,
            "line": 456
        },
        {
            "group": "main",
            "name": "wanInnerVlanId",
            "value": "100",
            "default": "",
            "isdefault": false,
            "line": 789
        },
        ...
    ]
}