-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi_v1.yml
706 lines (664 loc) · 19.4 KB
/
openapi_v1.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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
openapi: "3.0.2"
info:
title: API Title
version: "1.0"
description: SIA API Description
contact:
name: Mohammad Mohsen
email: kuro.ece@gmail.com
url: https://www.linkedin.com/in/mohammadtolba/
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: https://localhost:8000/api/v1/
description: Localhost
components:
schemas:
Member:
title: Member
type: object
properties:
url:
type: string
format: uri
id:
type: integer
format: int64
username:
type: string
first_name:
type: string
last_name:
type: string
email:
type: string
format: email
is_active:
type: boolean
default: true
is_staff:
type: boolean
default: false
date_joined:
type: string
format: date-time
devicegroup_set:
type: array
items:
type: string
format: uri
example:
url: https://localhost:8000/api/v1/members/username
id: 1
username: username
first_name: first_name
last_name: last_name
email: member@example.com
is_active: true
is_staff: false
date_joined: 2021-01-01T00:00:00Z
devicegroup_set:
- https://localhost:8000/api/v1/members/username/groups/group_name_1
- https://localhost:8000/api/v1/members/username/groups/group_name_2
- https://localhost:8000/api/v1/members/username/groups/group_name_3
Group:
title: Group
type: object
properties:
url:
type: string
format: uri
name:
type: string
id:
type: integer
format: int64
description:
type: string
creation_date:
type: string
format: date-time
owner:
type: string
format: uri
device_set:
type: array
items:
type: string
format: uri
example:
url: https://localhost:8000/api/v1/members/username/groups/group_name
name: group_name
id: 1
description: group_description
creation_date: 2021-01-01T00:00:00Z
owner: https://localhost:8000/api/v1/members/username
device_set:
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid_1
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid_2
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid_3
Device:
title: Device
type: object
properties:
url:
type: string
format: uri
name:
type: string
uid:
type: string
date_added:
type: string
format: date-time
is_active:
type: boolean
group:
type: string
format: uri
data_set:
type: array
items:
type: string
format: uri
example:
url: https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid
name: device_name
uid: device_uid
date_added: 2021-01-01T00:00:00Z
is_active: true
group: https://localhost:8000/api/v1/members/username/groups/group_name
data_set:
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid/data/data_id_1
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid/data/data_id_2
- https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid/data/data_id_3
Data:
title: Data
type: object
properties:
url:
type: string
format: uri
message:
type: string
format: json
date:
type: string
format: date-time
device:
type: string
format: uri
example:
url: https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid/data/data_id
message: { "temperature": 25, "humidity": 50 }
date: 2021-01-01T00:00:00Z
device: https://localhost:8000/api/v1/members/username/groups/group_name/devices/device_uid
parameters:
username:
name: username
in: path
required: true
schema:
type: string
description: The username of the member
group_name:
name: group_name
in: path
required: true
schema:
type: string
description: The name of the device group
device_uid:
name: device_uid
in: path
required: true
schema:
type: string
description: The unique UID of the device
data_id:
name: data_id
in: path
required: true
schema:
type: integer
format: int64
description: The UID of the device data message
securitySchemes:
name:
description: Basic Authentication
type: http
scheme: basic
responses:
noContent:
description: No Content
content:
application/json:
schema:
title: ObjectDeletedResponse
type: object
properties:
detail:
type: string
example: No content.
notFound:
description: Not Found
content:
application/json:
schema:
title: ObjectNotFoundErrorResponse
type: object
properties:
detail:
type: string
example: Not found.
badRequest:
description: Bad Request
content:
application/json:
schema:
title: BadRequestErrorResponse
type: object
properties:
detail:
type: string
example: Bad request.
unauthorized:
description: Unauthorized
content:
application/json:
schema:
title: UnauthorizedErrorResponse
type: object
properties:
detail:
type: string
example: Unauthorized.
created:
description: Created
content:
application/json:
schema:
title: ObjectCreatedResponse
type: object
properties:
detail:
type: string
example: Created.
memberDetails:
description: Member Details
content:
application/json:
schema:
$ref: "#/components/schemas/Member"
deviceGroupDetails:
description: Device Group Details
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
deviceDetails:
description: Device Details
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
dataDetails:
description: Data Details
content:
application/json:
schema:
$ref: "#/components/schemas/Data"
paths:
/members/{username}:
summary: |
An API endpoint to get a member's information, using the member's username.
It allows retrieving the details of the current user only.
Attempting to retrieve the details of another user will result in a not found error.
get:
summary: Get a member by its username
operationId: getMemberByUsername
tags:
- Details
- Members
parameters:
- $ref: "#/components/parameters/username"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Member"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups:
summary: |
An API endpoint to get all device groups of the current user,
or create a new device group under the current user.
get:
summary: Get all device groups for the current user.
operationId: listUserDeviceGroups
tags:
- List
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Group"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
post:
summary: |
Create a new device group.
A device group name must be unique for each user. For example:
user_1 can't have two groups named group_1. But user_2 and user_1 can both have a group named group_1.
A device group name can't contain any of the following characters: / ? < > \ : * | " ' or spaces.
operationId: createDeviceGroup
tags:
- Create
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
"400":
$ref: "#/components/responses/badRequest"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups/{group_name}:
summary: |
An API endpoint to get a device group of the current user, by the group's name.
get:
summary: Get a device group by its name
operationId: getDeviceGroupByName
tags:
- Details
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
put:
summary: Update a device group data by its name
operationId: updateDeviceGroupByName
tags:
- Update
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
patch:
summary: Update some of a device group's data by its name
operationId: partialUpdateDeviceGroupByName
tags:
- Partial Update
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Group"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
delete:
summary: Delete a device group by its name
operationId: deleteDeviceGroupByName
tags:
- Delete
- Device Groups
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
responses:
"204":
$ref: "#/components/responses/noContent"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups/{group_name}/devices:
summary: |
An API endpoint to get all devices in a device group,
or add a new device to a device group.
get:
summary: Get all devices in a device group
operationId: listDevicesInGroup
tags:
- List
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Device"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
post:
summary: |
Add a device to a device group.
The device UID is a unique identifier for each device. And it's created automatically by the server.
A device name must be unique for each user. For example:
user_1 can't have two devices named device_1. But user_2 and user_1 can both have a device named device_1.
A device name can't contain any of the following characters: / ? < > \ : * | " ' or spaces.
operationId: addDeviceToGroup
tags:
- Create
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
"400":
$ref: "#/components/responses/badRequest"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups/{group_name}/devices/{device_uid}:
get:
summary: Get a device by its UID
operationId: getDeviceByUID
tags:
- Details
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
put:
summary: Update device's data by its UID
operationId: updateDeviceByUID
tags:
- Update
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
patch:
summary: Update some of a device's data by its UID
operationId: partialUpdateDeviceByUID
tags:
- Partial Update
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Device"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
delete:
summary: Delete a device by its UID
operationId: deleteDeviceByUID
tags:
- Delete
- Devices
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
responses:
"204":
$ref: "#/components/responses/noContent"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups/{group_name}/devices/{device_uid}/data:
get:
summary: Get all data sent by a device
operationId: listDeviceData
tags:
- List
- Data
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Data"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
post:
summary: Add data to a device
operationId: addDataToDevice
tags:
- Create
- Data
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Data"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Data"
"400":
$ref: "#/components/responses/badRequest"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
/members/{username}/groups/{group_name}/devices/{device_uid}/data/{data_id}:
get:
summary: Get data by its ID
operationId: getDataById
tags:
- Details
- Data
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
- $ref: "#/components/parameters/data_id"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Data"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
delete:
summary: Delete data by its ID
operationId: deleteDataById
tags:
- Delete
- Data
parameters:
- $ref: "#/components/parameters/username"
- $ref: "#/components/parameters/group_name"
- $ref: "#/components/parameters/device_uid"
- $ref: "#/components/parameters/data_id"
responses:
"204":
$ref: "#/components/responses/noContent"
"401":
$ref: "#/components/responses/unauthorized"
"404":
$ref: "#/components/responses/notFound"
security:
- basicAuth: []