Jobs

List jobs

Get a list of jobs.

GET /api/v1/jobs/{?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-14T11:15:59.642459766-04:00",
    "data": [
        {
            "id": "1",
            "active": true,
            "status": "running",
            "options": {
                    "tags": [],
                    "skip_tests": null,
                    "begin_at": "",
                    "end_at": "",
                    "extra_cli_args": ""
            },
            "package_id": "1027",
            "package_name": "one",
            "device_id": "12",
            "device_name": "Device Foo",
            "config_id": "34",
            "config_name": "Config Foo",
            "result_id": "20160414111554",
            "user_id": "1",
            "created": "2016-04-14T11:15:54.211891321-04:00",
            "updated": "2016-04-14T11:15:56.529982108-04:00",
            "automatic": false,
            "run_at": "2016-04-14T11:15:54.211891321-04:00",
            "interfaces": [
                    {
                            "value": "eth1",
                            "is_wireless": false,
                            "is_ics": false
                    },
                    {
                            "value": "wifi0",
                            "is_wireless": true,
                            "is_ics": false
                    }
            ],
            "interface_names": [
                    "eth1",
                    "wifi0"
            ],
            "uses_wireless": true,
            "uses_ics": false
        }
    ],
    "links": {
        "current": 1,
        "first": 1,
        "last": 1,
        "limit": 25,
        "next": 0,
        "total": 1
    }
}

Get a job

Get a job.

GET /api/v1/jobs/{id}/

Response 200 OK

{
    "timestamp": "2016-04-14T11:15:59.642459766-04:00",
    "data": {
        "id": "1",
        "active": true,
        "status": "running",
        "options": {
                "tags": [],
                "skip_tests": null,
                "begin_at": "",
                "end_at": "",
                "extra_cli_args": ""
        },
        "package_id": "1027",
        "package_name": "one",
        "device_id": "12",
        "device_name": "Device Foo",
        "config_id": "34",
        "config_name": "Config Foo",
        "result_id": "20160414111554",
        "user_id": "1",
        "created": "2016-04-14T11:15:54.211891321-04:00",
        "updated": "2016-04-14T11:15:56.529982108-04:00",
        "automatic": false,
        "run_at": "2016-04-14T11:15:56.529982108-04:00",
        "interfaces": [
                {
                        "value": "eth1",
                        "is_wireless": false,
                        "is_ics": false
                },
                {
                        "value": "wifi0",
                        "is_wireless": true,
                        "is_ics": false
                }
        ],
        "interface_names": [
                "eth1",
                "wifi0"
        ],
        "uses_wireless": true,
        "uses_ics": false
    }
}

Response 404 Not Found

{
    "error": "no such job"
}

Launch a job

Launch a new job.

POST /api/v1/jobs/

Example

Launch a new job running package 123, skipping tests cdrouter_basic_1 and cdrouter_basic_10, starting at cdrouter_nat_1, ending at cdrouter_nat_2 and tagging the result with one and two.

POST /api/v1/jobs/
{
    "package_id": "123",
    "device_id": "12",
    "config_id": "34",
    "options": {
        "tags": [
            "one",
            "two"
        ],
        "skip_tests": [
            "cdrouter_basic_1",
            "cdrouter_basic_10"
        ],
        "begin_at": "cdrouter_nat_1",
        "end_at": "cdrouter_nat_2",
        "extra_cli_args": ""
    }
}

Response 200 OK

{
    "timestamp": "2016-04-14T11:22:00.90795757-04:00",
    "data": {
        "id": "2",
        "active": false,
        "status": "pending",
        "options": {
            "tags": [
                "one",
                "two"
            ],
            "skip_tests": [
                "cdrouter_basic_1",
                "cdrouter_basic_10"
            ],
            "begin_at": "cdrouter_nat_1",
            "end_at": "cdrouter_nat_2",
            "extra_cli_args": ""
        },
        "package_id": "123",
        "package_name": "one",
        "device_id": "12",
        "device_name": "Device Foo",
        "config_id": "34",
        "config_name": "Config Foo",
        "user_id": "1",
        "created": "2016-04-14T11:22:00.869323288-04:00",
        "updated": "2016-04-14T11:22:00.869323288-04:00",
        "automatic": false,
        "run_at": "2016-04-14T11:22:00.869323288-04:00",
        "interfaces": [
                {
                        "value": "eth1",
                        "is_wireless": false,
                        "is_ics": false
                },
                {
                        "value": "wifi0",
                        "is_wireless": true,
                        "is_ics": false
                }
        ],
        "interface_names": [
                "eth1",
                "wifi0"
        ],
        "uses_wireless": true,
        "uses_ics": false
    }
}

Delete a job

Delete a job.

DELETE /api/v1/jobs/{id}/

Response 204 No Content

Get a job’s interfaces

Process a job with cdrouter-cli -print-interfaces.

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

Example

POST /api/v1/jobs/?process=interfaces
{
    "package_id": "58",
    "options": {
            "extra_cli_args": "-testvar lanInterface=eth2"
    }
}

Response 200 OK

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

Bulk launch jobs

Bulk launch a set of jobs.

POST /api/v1/jobs/{?bulk=launch,filter,all}

URL Parameters

Name Description
bulk string (required) Must be launch
filter string (optional) See Filtering, note that these should be package filters (see below for examples)
all boolean (optional) If true, launch all packages.

Example

Bulk launch two jobs from packages 123 and 456.

POST /api/v1/jobs/?bulk=launch
{
    "jobs": [
        {"package_id": "123"},
        {"package_id": "456"}
    ]
}

Bulk launch two jobs from packages 123 and 456, tagging one with ["red"] and the other with ["blue"].

POST /api/v1/jobs/?bulk=launch
{
    "jobs": [
        {
            "package_id": "123",
            "options": {
                "tags": [
                    "red"
                ]
            }
        },
        {
            "package_id": "456",
            "options": {
                "tags": [
                    "blue"
                ]
            }
        }
    ]
}

Bulk launch jobs from packages matching filters name~DHCP, testlist@>{cdrouter_nat_1} and tags@>{working}, setting each job’s tags field to ["monday"].

POST /api/v1/jobs/?bulk=edit&filter=name~DHCP&filter=testlist@>{cdrouter_nat_1}&filter=tags@>{working}
{
    "fields": {
        "options": {
            "tags": [
                "monday"
            ]
        }
    }
}

Bulk launch jobs from all packages, setting each job’s tags field to ["monday"].

POST /api/v1/jobs/?bulk=launch&all=true
{
    "fields": {
        "options": {
            "tags": [
                "monday"
            ]
        }
    }
}

Response 200 OK

{
    "timestamp": "2016-08-15T13:35:58.912810418-04:00",
    "data": [
        {
            "id": "178",
            "active": false,
            "status": "pending",
            "options": {
                "tags": null,
                "skip_tests": null,
                "begin_at": "",
                "end_at": "",
                "extra_cli_args": ""
            },
            "package_id": "286",
            "package_name": "all",
            "device_id": "0",
            "device_name": "",
            "config_id": "0",
            "config_name": "",
            "user_id": "1",
            "created": "2016-08-15T13:35:58.075165876-04:00",
            "updated": "2016-08-15T13:35:58.075165876-04:00",
            "automatic": false,
            "run_at": "2016-08-15T13:35:58.075165876-04:00",
            "interfaces": [
                    {
                            "value": "eth1",
                            "is_wireless": false,
                            "is_ics": false
                    },
                    {
                            "value": "wifi0",
                            "is_wireless": true,
                            "is_ics": false
                    }
            ],
            "interface_names": [
                    "eth1",
                    "wifi0"
            ],
            "uses_wireless": true,
            "uses_ics": false
        },
        {
            "id": "179",
            "active": false,
            "status": "pending",
            "options": {
                "tags": null,
                "skip_tests": null,
                "begin_at": "",
                "end_at": "",
                "extra_cli_args": ""
            },
            "package_id": "1051",
            "package_name": "all (copy 1)",
            "device_id": "0",
            "device_name": "",
            "config_id": "0",
            "config_name": "",
            "user_id": "1",
            "created": "2016-08-15T13:35:58.16485173-04:00",
            "updated": "2016-08-15T13:35:58.16485173-04:00",
            "automatic": false,
            "run_at": "2016-08-15T13:35:58.16485173-04:00",
            "interfaces": [
                    {
                            "value": "eth1",
                            "is_wireless": false,
                            "is_ics": false
                    },
                    {
                            "value": "wifi0",
                            "is_wireless": true,
                            "is_ics": false
                    }
            ],
            "interface_names": [
                    "eth1",
                    "wifi0"
            ],
            "uses_wireless": true,
            "uses_ics": false
        },
        {
            "id": "180",
            "active": false,
            "status": "pending",
            "options": {
                "tags": null,
                "skip_tests": null,
                "begin_at": "",
                "end_at": "",
                "extra_cli_args": ""
            },
            "package_id": "1232",
            "package_name": "nightly performance",
            "device_id": "0",
            "device_name": "",
            "config_id": "0",
            "config_name": "",
            "user_id": "1",
            "created": "2016-08-15T13:35:58.355105411-04:00",
            "updated": "2016-08-15T13:35:58.355105411-04:00",
            "automatic": false,
            "run_at": "2016-08-15T13:35:58.355105411-04:00",
            "interfaces": [
                    {
                            "value": "eth1",
                            "is_wireless": false,
                            "is_ics": false
                    },
                    {
                            "value": "wifi0",
                            "is_wireless": true,
                            "is_ics": false
                    }
            ],
            "interface_names": [
                    "eth1",
                    "wifi0"
            ],
            "uses_wireless": true,
            "uses_ics": false
        }
    ]
}

Bulk delete jobs

Bulk delete a set of jobs.

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

URL Parameters

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

Example

Bulk delete jobs 1, 2 and 3.

POST /api/v1/jobs/?bulk=delete
{
    "jobs": [
        { "id": "1" },
        { "id": "2" },
        { "id": "3" },
    ]
}

Bulk delete jobs matching filters package_name=dns.

POST /api/v1/jobs/?bulk=delete&filter=package_name=dns

Bulk delete all jobs not currently running.

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

Response 204 No Content