summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/wave/docs/rest-api/guides/session-start-devices-api.md
blob: a376d3161757e8ad8bd9c2fa1d13d3d3ebf93e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Starting sessions on a DUT using the devices API

See all [REST API Guides](./README.md).

## Connecting the DUT

To start a session on a DUT using the devices API, first register the DUT at 
the test runner.

```
POST /api/devices
```

```json
{
  "token": "fa3fb226-98ef-11ea-a21d-0021ccd76152"
}
```

Using the device token, you can listen for any events related to the device.

```
GET /api/devices/fa3fb226-98ef-11ea-a21d-0021ccd76152/events
```

Once an event occurs, the response to this call will contain the event data. 
If no event occurs until the request times out, you have to perfom another call.

```json
{
  "type": "start_session",
  "data": {
    "session_token": "98ed4b8e-98ed-11ea-9de7-0021ccd76152"
  }
}
```

Using this data you can start the session and get the URL to the next test to 
open.

## Triggering the session start

Once a device is registered and waits for events, you can use the device's 
event channel to push an event to start a session on it.

```
POST /api/devices/fa3fb226-98ef-11ea-a21d-0021ccd76152/events
```

```json
{
  "type": "start_session",
  "data": {
    "session_token": "98ed4b8e-98ed-11ea-9de7-0021ccd76152"
  }
}
```

The session related to the provided token can be a newly created one or may 
already be running.