Debian Codegraph @

testing/web-platform/tests/tools/wave/docs/rest-api/guides/session-start-devices-api.md

raw
1 # Starting sessions on a DUT using the devices API
2
3 See all [REST API Guides](./README.md).
4
5 ## Connecting the DUT
6
7 To start a session on a DUT using the devices API, first register the DUT at
8 the test runner.
9
10 ```
11 POST /api/devices
12 ```
13
14 ```json
15 {
16 "token": "fa3fb226-98ef-11ea-a21d-0021ccd76152"
17 }
18 ```
19
20 Using the device token, you can listen for any events related to the device.
21
22 ```
23 GET /api/devices/fa3fb226-98ef-11ea-a21d-0021ccd76152/events
24 ```
25
26 Once an event occurs, the response to this call will contain the event data.
27 If no event occurs until the request times out, you have to perfom another call.
28
29 ```json
30 {
31 "type": "start_session",
32 "data": {
33 "session_token": "98ed4b8e-98ed-11ea-9de7-0021ccd76152"
34 }
35 }
36 ```
37
38 Using this data you can start the session and get the URL to the next test to
39 open.
40
41 ## Triggering the session start
42
43 Once a device is registered and waits for events, you can use the device's
44 event channel to push an event to start a session on it.
45
46 ```
47 POST /api/devices/fa3fb226-98ef-11ea-a21d-0021ccd76152/events
48 ```
49
50 ```json
51 {
52 "type": "start_session",
53 "data": {
54 "session_token": "98ed4b8e-98ed-11ea-9de7-0021ccd76152"
55 }
56 }
57 ```
58
59 The session related to the provided token can be a newly created one or may
60 already be running.