Skip to content

Commit a2aa6df

Browse files
committed
API documentation
1 parent 462b2c6 commit a2aa6df

File tree

6 files changed

+575
-0
lines changed

6 files changed

+575
-0
lines changed

docs/API.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# APIv1
2+
3+
* [Job API](apiv1/jobs.md)
4+
* [Target API](apiv1/targets.md)
5+
* [Runner API](apiv1/runners.md)
6+
* [API for general information](apiv1/info.md)

docs/apiv1/info.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Info API
2+
3+
### Version
4+
Retrieve version information.
5+
6+
GET /version
7+
8+
#### Example
9+
10+
curl -X GET https://hwut.de/apiv1/version
11+
12+
13+
#### Response
14+
`200 OK`
15+
16+
```
17+
{
18+
"git_branch": "develop",
19+
"git_hash": "4242424",
20+
"version": "0.0.1"
21+
}
22+
```
23+
24+
### Authentication test
25+
26+
GET /auth_test
27+
28+
#### Example
29+
30+
curl -X GET https://hwut.de/apiv1/auth_test
31+
32+
33+
#### Response
34+
`200 OK`
35+
36+
```
37+
You're authenticated if you can read this.
38+
```

docs/apiv1/jobs.md

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
## Jobs API
2+
3+
### Submit job
4+
5+
PUT /jobs/submit
6+
7+
Executable (`*.bin`, `*.hex` or `*.elf` file) is the request body.
8+
9+
#### Parameters
10+
| Name | Type | Description |
11+
|-------|---------|-------------|
12+
| duration_limit_seconds | int | Time limit for the job execution |
13+
| board | string | Board to run the test on |
14+
| comment | string | The comment can be used to assign a title or description to the job. (**optional**) |
15+
16+
#### Example
17+
18+
curl -T example.elf -X PUT "https://hwut.de/apiv1/jobs/submit?board=nucleo-f303re&duration_limit_seconds=5"
19+
20+
#### Response
21+
`201 Created`
22+
23+
Header `Location: /jobs/42`
24+
25+
Status and more information about the created job can be retrieved
26+
from the url in the Location header field.
27+
28+
### Job information
29+
Get number of tracks
30+
31+
GET /job/{id}
32+
33+
#### Example
34+
35+
curl -X GET "https://hwut.de/apiv1/jobs/42"
36+
37+
#### Response
38+
39+
`200 OK`
40+
41+
```
42+
{
43+
"id": 42,
44+
"created": "2020-01-01 00:00:00.000000",
45+
"status": "RUNNING",
46+
"owner": "user"
47+
}
48+
```
49+
50+
or if the user is the owner of the job:
51+
52+
```
53+
{
54+
"id": 42,
55+
"created": "2020-01-01 00:00:00.000000",
56+
"status": "RUNNING",
57+
"owner": "user",
58+
"comment": "Bla blubb comment",
59+
"duration_limit_seconds": 120,
60+
"filename_executable": "xs4IsRBCGs_RWCRUXgOZfs0e20aWFJLWecndiFBJG34",
61+
"filename_log": null,
62+
"filename_other": null,
63+
"board": "nucleo-f303re"
64+
}
65+
```
66+
67+
### Job information
68+
Cancel a job
69+
70+
DELETE /job/{id}
71+
72+
#### Example
73+
74+
curl -X DELETE "https://hwut.de/apiv1/jobs/42"
75+
76+
#### Response
77+
78+
`204 No Content`
79+
80+
or
81+
82+
`400 Bad request - 'Unable to cancel job. Current job status: FINISHED'`
83+
if the job cannot be cancel.
84+
85+
86+
### Job status shortcut
87+
Check if a job has finished
88+
89+
GET /job/{id}/is_finished
90+
91+
#### Example
92+
93+
curl -X GET "https://hwut.de/apiv1/jobs/42/is_finished"
94+
95+
#### Response
96+
97+
`204 No Content` if the job has finished
98+
99+
or
100+
101+
`404 Not found` if the job has not yet finished.
102+
103+
104+
### Job list
105+
Get list of jobs
106+
107+
GET /jobs
108+
109+
#### Parameters
110+
111+
| Name | Type | Description |
112+
|-------|---------|-------------|
113+
| limit | int | Number of jobs to include in the response (optional, default 50) |
114+
| offset | int | Offset from the first job to include in the response (optional, default 0) |
115+
116+
Note: Parameters are not implemented yet.
117+
118+
#### Example
119+
120+
curl -X GET "https://hwut.de/apiv1/jobs"
121+
122+
#### Response
123+
124+
`200 OK`
125+
126+
```
127+
[
128+
{
129+
"id": 42,
130+
"created": "2020-01-01 00:00:00.000000",
131+
"status": "RUNNING",
132+
"owner": "user"
133+
},
134+
{...}
135+
]
136+
```
137+
138+
### Retrieve job logfile
139+
140+
GET /job/{id}/log
141+
142+
#### Example
143+
144+
curl -X GET "https://hwut.de/apiv1/jobs/42/log"
145+
146+
#### Response
147+
148+
`200 OK`
149+
and the log file (MIME type 'text/plain') as response body.
150+
151+
`404 Not found` if the log is not available, e.g. is the job is not finished.
152+
153+
### COPY!!!!!!!!!!!!!!!!!!
154+
Get number of tracks
155+
156+
GET /track/num
157+
158+
#### Parameters
159+
160+
| Name | Type | Description |
161+
|-------|---------|-------------|
162+
| user_track | array of ints | Description (optional) |
163+
164+
165+
#### Example
166+
167+
curl -X GET "https://hwut.de/apiv1/jobs/42"
168+
169+
#### Response
170+
171+
Status `200 OK`

docs/apiv1/runners.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
## Runner API
2+
3+
### Runner list
4+
Retrieve version information.
5+
6+
GET /runners/*
7+
GET /runners/by_board/{board}
8+
9+
#### Example
10+
11+
curl -X GET https://hwut.de/apiv1/runners/by_board/nucleo-f303re
12+
13+
#### Response
14+
`200 OK`
15+
16+
```
17+
[
18+
{
19+
"id": 42,
20+
"enabled": true,
21+
"board": "nucleo-f303re"
22+
},
23+
{...}
24+
]
25+
```
26+
27+
or if the user owns the runner:
28+
29+
```
30+
[
31+
{
32+
"id": 42,
33+
"token": "cI3lkAFM5KyREj1M78eeSbBeslAje-gRz2fWbe34a6U",
34+
"created": "2020-01-01 00:00:00.000000",
35+
"enabled": true,
36+
"last_seen": "2020-03-01 00:00:00.000000",
37+
"ping_counter": 421337,
38+
"job_counter": 1337,
39+
"busy": false,
40+
"board": "nucleo-f303re"
41+
},
42+
{...}
43+
]
44+
```
45+
46+
or an empty list if no runner is found.
47+
48+
49+
### Runner information
50+
Get information about the specified runner.
51+
52+
GET /runners/{id}
53+
54+
#### Example
55+
56+
curl -X GET https://hwut.de/apiv1/runners/42
57+
58+
#### Response
59+
`200 OK`
60+
61+
```
62+
{
63+
"id": 42,
64+
"enabled": true,
65+
"board": "nucleo-f303re"
66+
}
67+
```
68+
69+
or if the user owns the runner:
70+
71+
```
72+
{
73+
"id": 42,
74+
"token": "cI3lkAFM5KyREj1M78eeSbBeslAje-gRz2fWbe34a6U",
75+
"created": "2020-01-01 00:00:00.000000",
76+
"enabled": true,
77+
"last_seen": "2020-03-01 00:00:00.000000",
78+
"ping_counter": 421337,
79+
"job_counter": 1337,
80+
"busy": false,
81+
"board": "nucleo-f303re"
82+
}
83+
```
84+
85+
86+
### Create a new runner
87+
88+
PUT /runners/add
89+
90+
#### Parameters
91+
| Name | Type | Description |
92+
|-------|---------|-------------|
93+
| board | string | Board the runner is using |
94+
95+
#### Example
96+
97+
curl -X PUT https://hwut.de/apiv1/runners/add?board=nucleo-f303re
98+
99+
#### Response
100+
`200 Created`
101+
102+
Header: `Location: /runners/42`
103+
104+
105+
### Delete a runner
106+
107+
DELETE /runners/{id}
108+
109+
#### Example
110+
111+
curl -X DELETE https://hwut.de/apiv1/runner/42
112+
113+
#### Response
114+
`204 No Content`

0 commit comments

Comments
 (0)