-
Notifications
You must be signed in to change notification settings - Fork 69
/
api-spec.yml
335 lines (333 loc) · 8.62 KB
/
api-spec.yml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
openapi: "3.0.2"
info:
title: NervesHub Web
version: "2.0"
servers:
- url: http://localhost:4000/api
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
schemas:
deployment:
type: object
nullable: true
properties:
name:
type: string
example: "production"
is_active:
type: boolean
firmware_uuid:
type: string
format: uuid
firmware_version:
type: string
format: version
example: "1.2.1"
device:
type: object
properties:
connection_status:
type: string
example: "connected"
connection_established_at:
type: string
format: date-time
connection_disconnected_at:
type: string
format: date-time
connection_last_seen_at:
type: string
format: date-time
deployment:
$ref: "#/components/schemas/deployment"
description:
type: string
example: "A device"
firmware_metadata:
$ref: "#/components/schemas/firmware_metadata"
firmware_update_status:
type: string
enum: [latest, pending, updating]
identifier:
type: string
example: "NH1234"
last_communication:
type: string
format: date-time
online:
type: boolean
org_name:
type: string
example: "nerveshub"
product_name:
type: string
example: "sensors"
tags:
type: array
items:
type: string
example:
- "rpi"
- "production"
updates_blocked_until:
type: string
format: date-time
nullable: true
description: Automatic firmware update blocking by NervesHub
updates_enabled:
type: boolean
description: A hard block for devices if `false` and is set by a person
version:
type: string
format: version
example: "1.2.1"
description: Human readable firmware version
error:
type: object
properties:
errors:
type: object
properties:
detail:
type: string
example: "Not found"
firmware_key:
type: object
properties:
name:
type: string
example: test
key:
type: string
example: h8L1FcfK8mUSnIvM0rffjoapItsI4fimIU9x9Jq2TdU=
firmware_metadata:
type: object
properties:
architecture:
type: string
example: "arm"
author:
type: string
nullable: true
example: "The Nerves Team"
description:
type: string
nullable: true
example: "Sensors platform"
fwup_version:
type: string
format: version
example: "1.2.1"
id:
type: string
format: uuid
misc:
type: string
nullable: true
platform:
type: string
example: "rpi"
product:
type: string
example: "sensors"
uuid:
type: string
format: uuid
vcs_identifier:
type: string
nullable: true
version:
type: string
format: version
example: "1.2.1"
description: |
Metadata of the active firmware.
nullable: true
script:
type: object
properties:
id:
type: integer
example: 1
name:
type: string
example: "MOTD"
text:
type: string
example: "NervesMOTD.print()"
paths:
/devices/{id}:
get:
summary: Fetch information about a device.
description: |
If the device is currently online, there will be `firmware_metadata` describing active firmware.
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
description: |
Fetch a device's information. You can learn about the update status of the device via the `firmware_metadata` and `deployment` keys.
`firmware_metadata` map has the UUID and version of the active firmware.
`deployment` contains information about what firmware version and UUID should eventually be running on the device.
properties:
data:
$ref: "#/components/schemas/device"
"404":
description: Not found
content:
application/json:
schema:
$ref: "#/components/schemas/error"
/devices/{identifier}/move:
post:
summary: Move a device to another product, in the same or different organization
parameters:
- in: query
name: identifier
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
properties:
org_name:
type: string
example: "nerveshub"
product_name:
type: string
example: "kiosk"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/device"
/devices/{identifier}/scripts:
get:
summary: List all scripts for a device
parameters:
- in: query
name: identifier
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/script"
/devices/{identifier}/scripts/{id}:
post:
summary: Trigger a script to run
parameters:
- in: query
name: identifier
schema:
type: string
- in: query
name: id
schema:
type: integer
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
example: |
iex(1)> IO.inspect("Hello there")
"Hello there"
/orgs/{org}/keys:
get:
summary: List all firmware signing keys for the organization
parameters:
- in: query
name: org
schema:
type: string
example: nerveshub
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
name:
type: string
example: test
key:
type: string
example: h8L1FcfK8mUSnIvM0rffjoapItsI4fimIU9x9Jq2TdU=
post:
summary: Add a new firmware signing key
parameters:
- in: query
name: org
schema:
type: string
example: nerveshub
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/firmware_key"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/firmware_key"
/users/me:
get:
summary: View information about the authenticated user
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
username:
type: string
example: nerveshub
email:
type: string
example: nerveshub@example.org