REST API¶
The coalition server provides a REST API using json data.
Jobs¶
-
GET
/api/jobs
¶ Returns the root jobs (with parent=0).
Example request:
GET /api/jobs HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 123, "parent": 0, "title": "Job 123", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }, { "id": 124, "parent": 0, "title": "Job 124", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" } ]
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
GET
/api/jobs/
(int: id)¶ Returns the job (id) object.
Example request:
GET /api/jobs/123 HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 123, "parent": 0, "title": "Job 123", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
PUT
/api/jobs
¶ Create a job. Returns the new job id.
Example request:
PUT /api/jobs HTTP/1.1 Host: localhost { "parent": 0, "title": "Job 1", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "url": "http://localhost/image.png", "progress_pattern": "#%percent" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json 123
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
POST
/api/jobs
¶ Modify the jobs properties.
Example request:
POST /api/jobs HTTP/1.1 Host: localhost { 123: { "title": "Job renamed 123", "command": "echo renamed", }, 124: { "title": "Job renamed 124", "command": "echo renamed", } }
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
GET
/api/jobs/
(int: id)/children
¶ Returns the job (id) children objects.
Example request:
GET /api/jobs/123/children HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 124, "parent": 123, "title": "Job 124", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }, { "id": 125, "parent": 123, "title": "Job 125", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }, ]
-
GET
/api/jobs/
(int: id)/dependencies
¶ Returns the job objects on which the job (id) depends.
Example request:
GET /api/jobs/123/dependencies HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 124, "parent": 0, "title": "Job 124", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }, { "id": 125, "parent": 0, "title": "Job 125", "command": "echo test", "dir": ".", "environment": "", "state": "WAITING", "worker": "worker-1", "start_time": 123456, "duration": 12, "ping_time": 123456, "run_done": 1, "retry": 10, "timeout": 10000, "priority": 1000, "affinity": "LINUX", "user": "render", "finished": 0, "errors": 0, "working": 0, "total": 10, "total_finished": 0, "total_errors": 0, "total_working": 0, "url": "http://localhost/image.png", "progress": 0.5, "progress_pattern": "#%percent" }, ]
-
POST
/api/jobs/
(int: id)/dependencies
¶ Set the job (id) dependencies.
Example request:
POST /api/jobs/123/dependencies HTTP/1.1 Host: localhost [124,125]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
GET
/api/jobs/
(int: id)/log
¶ Returns the job (id) log file.
Example request:
GET /api/jobs/123/log HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json "Job 123 done"
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
DELETE
/api/jobs
¶ Delete the jobs.
Example request:
DELETE /api/jobs HTTP/1.1 Host: localhost [123,124,125]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
POST
/api/resetjobs
¶ Reset the jobs. The job status is set to ‘WAITING’, all the job counters are set to 0.
Example request:
POST /api/resetjobs HTTP/1.1 Host: localhost [123,124,125]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
POST
/api/startjobs
¶ Start the jobs. The job status is set to ‘WAITING’.
Example request:
POST /api/startjobs HTTP/1.1 Host: localhost [123,124,125]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
POST
/api/pausejobs
¶ Pause the jobs. The job status is set to ‘PAUSED’.
Example request:
POST /api/pausejobs HTTP/1.1 Host: localhost [123,124,125]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
Workers¶
-
GET
/api/workers
¶ Returns the workers.
Example request:
GET /api/workers HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "name": "worker-1", "ip": "127.0.0.1", "affinity": "LINUX,WINDOWS", "state": "WAITING", "ping_time": 123456, "finished": 123, "error": 21, "last_job": 1234, "current_event": 1234, "cpu": "[0,0,0,0]", "free_memory": 123456, "total_memory": 1000000, "active": 1 }
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
POST
/api/workers
¶ Modify the workers properties.
Example request:
POST /api/workers HTTP/1.1 Host: localhost { "worker-1": { "affinity": "LINUX", "active": 0, }, "worker-2": { "affinity": "LINUX", "active": 0, } }
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error
-
DELETE
/api/workers
¶ Delete the workers.
Example request:
DELETE /api/workers HTTP/1.1 Host: localhost ["worker-1","worker-2"]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
POST
/api/stopworkers
¶ Stop the workers.
Example request:
POST /api/stopworkers HTTP/1.1 Host: localhost ["worker-1","worker-2"]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
-
POST
/api/startworkers
¶ Start the workers.
Example request:
POST /api/startworkers HTTP/1.1 Host: localhost ["worker-1","worker-2"]
Example response:
HTTP/1.1 200 OK Content-Type: application/json 1
Events¶
-
GET
/api/events
¶ Returns some events.
Parameters: - job – returns the events for this job.
- worker – returns the events for this worker.
- howlong – returns all the events in the last howlong seconds.
Example request:
GET /api/events?job=123&worker=worker-1&howlong=60 HTTP/1.1 Host: localhost
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 123, "worker": "worker-1", "job_id": 123, "job_title": "Job 123", "state": "ERROR", "start": 123456, "duration": 10 }
Status Codes: - 200 OK – no error
- 500 Internal Server Error – error