-
Notifications
You must be signed in to change notification settings - Fork 0
/
agile-core.yml
863 lines (858 loc) · 23.4 KB
/
agile-core.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
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
swagger: '2.0'
info:
title: Agile HTTP API
description: The Agile HTTP API to interact with local DBus objects
version: 1.0.0
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
# the domain of the service
host: localhost:8080
# array of all schemes that your API supports
schemes:
- http
# will be prefixed to all paths
basePath: /api
consumes:
- application/json
produces:
- application/json
# security:
# - type: basic
# in: header
# - type: oauth2
# authorizationUrl: /api/oauth
# flow: [implicit, password, application, accessCode]
externalDocs:
url: http://agile-iot.github.io/agile-api-spec
description: DBus AGILE API spec
tags:
- name: DeviceManager
description: Device management API
- name: Device
description: Device related API
- name: ProtocolManager
description: Protocol management API
- name: Protocol
description: Protocol related API
paths:
'/device/{deviceId}/status':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
get:
operationId: Status
tags:
- Device
description: 'Indicate the current device status'
responses:
'200':
description: 'Status read done'
schema:
$ref: '#/definitions/StatusType'
examples:
application/json:
status: CONNECTED
'204':
description: 'No data available'
'/device/{deviceId}':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
get:
operationId: Read
tags:
- Device
description: 'Read values of all components from the device'
responses:
'200':
description: 'Read done'
schema:
type: array
$ref: '#/definitions/RecordObject'
examples:
application/json:
-
deviceID: bleA0E6F8B62304
componentID: Temperature
value: '23.46875'
unit: 'Degree celsius'
format: ""
lastUpdate: '1477491668082'
-
deviceID: bleA0E6F8B62304
componentID: Humidity
value: '58.929443'
unit: 'Relative humidity'
format: ""
lastUpdate: '1477491668082'
'204':
description: 'No data available'
'/device/{deviceId}/connection':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
post:
operationId: Connect
tags:
- Device
description: 'Connect the device at protocol level'
responses:
'200':
description: 'Device connected'
delete:
operationId: Disconnect
tags:
- Device
description: 'Disconnect device at protocol level'
responses:
'200':
description: 'Device disconnected'
'/device/{deviceId}/execute/{command}':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
-
name: command
in: path
description: 'Operation name to be performed'
required: true
type: string
post:
operationId: Execute
tags:
- Device
description: 'Perform an action on the device'
responses:
'200':
description: 'Action sent'
'204':
description: 'Action sent, no response received'
'/device/{deviceId}/{componentId}/subscribe':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
-
name: componentId
in: path
description: 'Agile component name, like a sensor'
required: true
type: string
post:
operationId: Subscribe
tags:
- Device
description: "Enable a subscription to a data stream. Asynchronous data updates will\nbe delivered via websocket.\n"
responses:
'200':
description: 'Subscription registered'
delete:
operationId: Unsubscribe
tags:
- Device
description: 'Unsubscribe from a data stream'
responses:
'200':
description: Unsubscribed
'/device/{deviceId}/{componentId}':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
-
name: componentId
in: path
description: 'Device component name, like a Temperature'
required: true
type: string
get:
operationId: Read
tags:
- Device
description: 'Read from a device component'
responses:
'200':
description: 'Read done'
schema:
$ref: '#/definitions/RecordObject'
examples:
application/json:
deviceID: bleA0E6F8B62304
componentID: Temperature
value: '23.46875'
unit: 'Degree celsius'
format: ""
lastUpdate: '1477491668082'
'204':
description: 'No data available'
post:
operationId: Write
tags:
- Device
description: 'Write to a device component'
responses:
'200':
description: 'Write sent'
'204':
description: 'Write sent, no results returned'
'/device/{deviceId}/{componentId}/lastUpdate':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
-
name: componentId
in: path
description: 'Agile component name, like a sensor'
required: true
type: string
get:
operationId: Data
tags:
- Device
description: 'Get the last record fetched from the component'
responses:
'200':
description: 'Record fetched'
schema:
$ref: '#/definitions/RecordObject'
examples:
application/json:
deviceID: bleA0E6F8B62304
componentID: Temperature
value: '23.46875'
unit: 'Degree celsius'
format: ""
lastUpdate: '1477491668082'
'204':
description: 'No data available'
'404':
description: 'Device not available'
'/device/{deviceId}/lastUpdate':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
get:
operationId: Data
tags:
- Device
description: 'Get the last record fetched from the device'
responses:
'200':
description: 'Record fetched'
schema:
$ref: '#/definitions/RecordObject'
examples:
application/json:
deviceID: bleA0E6F8B62304
componentID: Temperature
value: '23.46875'
unit: 'Degree celsius'
format: ""
lastUpdate: '1477491668082'
'204':
description: 'No data available'
'404':
description: 'Device not available'
/devices:
get:
operationId: Devices
tags:
- DeviceManager
description: 'List all registered devices'
responses:
'200':
description: 'List the registered device'
schema:
type: array
$ref: '#/definitions/DeviceDefinition'
examples:
application/json:
-
deviceId: bleA1B2C3D4E5F6
address: 'A1:B2:C3:D4:E5:F6'
name: MyFirstSensorTag
description: ""
protocol: iot.agile.protocol.ble
path: /iot/agile/Device/bleA1B2C3D4E5F6
streams:
-
id: temperature
unit: celsius
-
id: light
unit: lumen
-
id: pressure
unit: hPa
-
deviceId: bleA6B5C4D3E2F1
address: 'A6:B5:C4:D3:E2:F1'
name: MySecondSensorTag
description: ""
protocol: iot.agile.protocol.ble
path: /iot/agile/Device/bleA6B5C4D3E2F1
streams:
-
id: temperature
unit: celsius
-
id: light
unit: lumen
-
id: pressure
unit: hPa
'204':
description: 'Device list is empty'
post:
operationId: Register
description: 'Register a new device based on information from ProtocolManager and device type'
tags:
- DeviceManager
parameters:
-
name: payload
in: body
description: 'The request body describing a device and the intended type'
required: true
schema:
$ref: '#/definitions/RegisterPayload'
examples:
application/json:
overview:
id: 'A0:E6:F8:B6:F2:00'
name: 'CC2650 SensorTag'
protocol: iot.agile.protocol.BLE
status: AVAILABLE
type: 'TI SensorTag'
responses:
'200':
description: 'Device created'
schema:
$ref: '#/definitions/DeviceDefinition'
examples:
application/json:
deviceId: bleA1B2C3D4E5F6
address: 'A1:B2:C3:D4:E5:F6'
name: MyFirstSensorTag
description: ""
protocol: iot.agile.protocol.ble
path: /iot/agile/Device/bleA1B2C3D4E5F6
streams:
-
id: temperature
unit: celsius
-
id: light
unit: lumen
-
id: pressure
unit: hPa
/devices/typeof:
post:
operationId: TypeOf
description: 'Get matching types for a device overview'
tags:
- DeviceManager
parameters:
-
name: overview
in: body
description: 'The request body describing a device'
required: true
schema:
$ref: '#/definitions/DeviceOverview'
examples:
application/json:
id: 'A0:E6:F8:B6:F2:00'
name: 'CC2650 SensorTag'
protocol: iot.agile.protocol.BLE
status: AVAILABLE
responses:
'200':
description: 'list of possible device types'
schema:
type: array
items:
type: string
'/devices/{deviceId}':
parameters:
-
name: deviceId
in: path
description: 'Agile device Id'
required: true
type: string
get:
operationId: Read
description: 'Get a device definition'
tags:
- DeviceManager
responses:
'200':
description: 'Device loaded'
schema:
$ref: '#/definitions/DeviceDefinition'
examples:
application/json:
deviceId: bleA1B2C3D4E5F6
address: 'A1:B2:C3:D4:E5:F6'
name: SensorTag
description: ""
protocol: iot.agile.protocol.ble
path: /iot/agile/Device/bleA1B2C3D4E5F6
streams:
-
id: temperature
unit: celsius
-
id: light
unit: lumen
-
id: pressure
unit: hPa
'404':
description: 'Device not found'
put:
operationId: Update
tags:
- DeviceManager
parameters:
-
name: body
in: body
description: 'The request body describing a device'
required: true
schema:
$ref: '#/definitions/DeviceDefinition'
examples:
application/json:
deviceId: bleA1B2C3D4E5F6
address: 'A1:B2:C3:D4:E5:F6'
name: SensorTag
description: ""
protocol: iot.agile.protocol.ble
path: /iot/agile/Device/bleA1B2C3D4E5F6
streams:
-
id: temperature
unit: celsius
-
id: light
unit: lumen
-
id: pressure
unit: hPa
-
id: optical
unit: unit
description: 'Update a device definition'
responses:
'200':
description: 'Device updated'
'404':
description: 'Device not found'
delete:
operationId: Delete
tags:
- DeviceManager
description: 'Delete a device definition and unregister it'
responses:
'200':
description: 'Device removed'
'404':
description: 'Device not found'
'/protocol/{protocolId}/connection/{deviceId}':
parameters:
-
name: protocolId
in: path
description: 'Agile Id of the protocol'
required: true
type: string
-
name: deviceId
in: path
description: 'Agile internal Id of the protocol'
required: true
type: string
post:
operationId: Connect
tags:
- Protocol
description: 'Connect to the device'
responses:
'200':
description: 'Connection initialized'
'404':
description: 'Device not found'
delete:
operationId: Disconnect
tags:
- Protocol
description: 'Disconnect from the device'
responses:
'200':
description: 'Disconnection completed'
'404':
description: 'Device not found'
'/protocol/{protocolId}/discovery':
parameters:
-
name: protocolId
in: path
description: 'Agile Id of the protocol'
required: true
type: string
post:
operationId: StartDiscovery
tags:
- Protocol
description: 'Start the discovery process'
responses:
'200':
description: 'Discovery started'
'404':
description: 'Device not found'
delete:
operationId: StopDiscovery
tags:
- Protocol
description: 'Stop the discovery process'
responses:
'200':
description: 'Discovery process stopped'
'404':
description: 'Device not found'
'/protocol/{protocolId}/{deviceId}':
parameters:
-
name: protocolId
in: path
description: 'Agile internal Id of the protocol'
required: true
type: string
-
name: deviceId
in: path
description: 'Agile protocol Id of the device'
required: true
type: string
post:
operationId: Write
tags:
- Protocol
description: 'Call a write via protocol'
parameters:
-
name: data
in: body
description: 'An object containing the content to write'
required: true
schema:
$ref: '#/definitions/ProtocolMessage'
responses:
'200':
description: 'Write suceeded'
'404':
description: 'Device or component not found'
get:
operationId: Read
tags:
- Protocol
description: 'Call a read via protocol'
responses:
'200':
description: 'Read suceeded'
schema:
$ref: '#/definitions/RecordObject'
'404':
description: 'Device or component not found'
/protocols:
get:
operationId: Protocols
tags:
- ProtocolManager
description: 'Get the list of registered protocols'
responses:
'200':
description: 'Protocols list provided'
schema:
$ref: '#/definitions/ProtocolOverview'
examples:
application/json:
-
id: BLE
name: 'Bluetooth LE'
interface: iot.agile.protocol.BLE
status: AVAILABLE
-
id: ZigBee
name: 'ZigBee communication protocol'
interface: iot.agile.protocol.ZigBee
status: AVAILABLE
'204':
description: 'No protocols registered.'
'/protocols/{protocolId}':
parameters:
-
name: protocolId
in: path
description: 'Agile protocol Id'
required: true
type: string
post:
operationId: Add
tags:
- ProtocolManager
description: 'Register a new Dbus object implementing the protocol API'
responses:
'202':
description: 'Protocol has been added'
'400':
description: 'An error occured processing the request'
delete:
operationId: Remove
tags:
- ProtocolManager
description: 'Unregister a Dbus Protocol object reference'
responses:
'200':
description: 'Protocol unregistered'
'404':
description: 'Protocol not found'
/protocols/devices:
get:
operationId: Devices
tags:
- ProtocolManager
description: 'List all discovered devices on all available protocols'
responses:
'200':
description: "The list of devices found via discovery\n"
schema:
type: array
$ref: '#/definitions/DeviceOverview'
examples:
application/json:
-
name: SensorTag
id: 'AA:BB:CC:DD'
protocol: iot.agile.protocol.BLE
status: AVAILABLE
-
name: LightDimmer
id: 'CC:DD:AA:BB'
protocol: iot.agile.protocol.Zwave
status: AVAILABLE
/protocols/discovery:
get:
operationId: DiscoveryStatus
tags:
- ProtocolManager
description: 'Return the status of discovery on the available protocols'
responses:
'200':
description: "Return the list of protocol discovery status\n"
schema:
$ref: '#/definitions/DiscoveryStatus'
examples:
application/json:
-
name: BLE
status: RUNNING
-
name: ZigBee
status: NONE
-
name: ZWave
status: FAILURE
post:
operationId: StartDiscovery
tags:
- ProtocolManager
description: 'Start a device discovery on all available protocols'
responses:
'204':
description: "The discovery has been successfully started on all the regitered\nprotocols; asynchronous updates will be sent via websocket\n"
'409':
description: "Indicates that discovery has been requested to the underlying\nprotocols but one or more reported a failure\n"
delete:
operationId: StopDiscovery
tags:
- ProtocolManager
description: 'Stop a device discovery if previously initiated'
responses:
'204':
description: "The discovery has been successfully stopped on all the regitered\nprotocols; There will be no further device updates via websocket\n"
'409':
description: "Indicates that discovery has been requested to stop on the underlying\nprotocols but one or more reported a failure\n"
definitions:
DeviceOverview:
description: 'An overview of a device a protocol knows about'
type: object
properties:
name:
description: 'Friendly name of the device'
type: string
protocol:
description: 'Protocol reference for this device'
type: string
id:
description: 'Protocol level id used to identify and access the device'
type: string
status:
enum:
- CONNECTED
- DISCONNECTED
- AVAILABLE
- UNAVAILABLE
DiscoveryStatus:
type: object
properties:
name:
description: 'Name of the protocol'
type: string
status:
enum:
- NONE
- RUNNING
- FAILURE
ProtocolMessage:
type: object
properties:
data:
type: string
format:
type: string
ProtocolOverview:
type: object
properties:
name:
description: 'The protocol name'
type: string
id:
description: 'the internal code identifying the protocol'
type: string
interface:
description: 'The DBus interface reference'
type: string
status:
$ref: '#/definitions/ProtocolStatus'
ProtocolStatus:
description: "Identify a status of the Protocol, indicating if operational (AVAILABLE) or\nif for some reason further user-side checks are required.\n"
enum:
- AVAILABLE
- UNAVAILABLE
- NOT_CONFIGURED
- DISABLED
- ENABLED
- FAILURE
ChannelTypeEnum:
enum:
- Number
- String
- Boolean
- GeoPoint
- Object
DeviceComponent:
description: 'A device component from which get a data stream, like a sensor'
type: object
properties:
id:
type: string
unit:
type: string
properties:
$ref: '#/definitions/KeyValue'
DeviceDefinition:
description: 'A device definition that contains informations describing the current device'
type: object
properties:
deviceId:
description: 'Agile specific device ID'
type: string
address:
description: 'Protocol specific device address'
type: string
name:
type: string
description:
type: string
protocol:
type: string
path:
description: 'DBus specific path to reach the object instance'
type: string
streams:
description: 'A list of components from which get data streams'
type: array
items:
$ref: '#/definitions/DeviceComponent'
RegisterPayload:
description: Payload
type: object
properties:
overview:
$ref: '#/definitions/DeviceOverview'
type:
type: string
StatusType:
enum:
- CONNECTED
- DISCONNECTED
RecordObject:
description: 'Contains the measurment from a sensor and the metadata regarding its source'
type: object
properties:
DeviceId:
description: 'The Agile Id that generated the value'
type: string
ComponentId:
description: 'The component Id or sensor from where the value comes from'
type: string
Value:
description: 'The value, stored as string'
type: string
Unit:
description: 'The measurment unit for the value'
type: string
Format:
description: 'A format description to read the data value'
type: string
LastUpdate:
description: 'A UNIX timestamp rapresenting the last update of a record'
type: number
KeyValue:
description: 'A list of key/value pairs'
type: object