-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapiary.apib
540 lines (338 loc) · 14.8 KB
/
apiary.apib
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
FORMAT: 1A
HOST: https://smartsecurity-webservice.herokuapp.com
# smartsecurity-web-service
This specification defines smartsecurity-web-service API. The smartsecurity-web-service is an API Rest implementation built it with the environment NodeJS, smartsecurity-web-service allows to manage the information provided of three different sources, the first one is the Orion Contextbroker GE of Fiware used to manage the context information, the second one CrateDB used by Quamtumleap GE of Fiware to store time series information and finally the DBMS MariaDB used to store the complementary information.
## Data Models
### Zone
The Zone data model is based on [Building data model of Fiware](https://github.com/Fiware/dataModels/tree/master/specs/Building/Building). The Building data model is used in the SmartSecurity application to delimit the space geographic occupied by an organization, as well as its characteristics. This data model has been defined following the GSMA Building data model adopted recently as a FIWARE data model. It is important to note that, the Building data model does not have the "name" attribute; for our application this is required. For this reason, we have added the name of the zone within the owner attribute of this data model. This model is also used to model other building or a “zone” of an organization; for this reason, we use the category attribute to define if a building is a zone.
### Parking
The Parking data model is based on [OffStreetParking data model of Fiware](https://github.com/Fiware/dataModels/tree/master/specs/Parking/OffStreetParking), Parking model is used in the Smart Security application to delimit the geographic space of the parking lots that are within the of an organization, and describe its characteristics. In addition, this data model allow to reference to another data model that contains the parking within its area, through the areaServed attribute of this data model. For this reason, we use areaServed attribute to reference to the organization’s zone that contains the parking lot.
### Road
The Road data model based on [Road data model of Fiware](https://github.com/Fiware/dataModels/tree/master/specs/Transportation/Road) is used in the SmartSecurity application to define the parking streets of an organization. Also this data model is used to define those streets that are within the geographic space of the organization.
### Road Segment
The RoadSegment data model based on [RoadSegment data model of Fiware](https://github.com/Fiware/dataModels/tree/master/specs/Transportation/RoadSegment) is used in the Smart Security application to describe the characteristics of segments in which a street can be divided; besides, this model provides attributes to detail the properties of the lines or lanes that the street segment contains.
### User
The user data model was designed especially for the Smart Security scenario, the user model complies with the basic attributes used for the Identity Manager of Fiware.
### Device Token
The Device Token data model was designed to complement the information used on Device data model of Fiware, the additional information including in Device Token include attributes used to send and manage the push notifications sent to the mobile application.
### Alert
The Alert Model is based on [Alert data model of Fiware](https://github.com/Fiware/dataModels/blob/master/specs/Alert/).
### Device
The Device Model is based on [Device data model of Fiware](https://github.com/Fiware/dataModels/blob/master/specs/Device/Device/) using only the mandatory attributes.
# Data Structures
## Geometry (object)
A geometry is a GeoJSON object where the type member's value is one of the following strings: "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", or "GeometryCollection".
<http://geojson.org/geojson-spec.html#geometry-objects>
## Polygon (array)
Coordinates of a Polygon are an array of LinearRing coordinate arrays. The first element in the array represents the exterior ring. Any subsequent elements represent interior rings (or holes).
## Point (array)
Coordinates o a especific point including longitude and latitude
## Polyline (array)
Coordinates of a Polygon an array on Line
### Zone (object)
- category: University , Factory (array)
- location (Polygon)
- centerPoint: 18.876443, -99.22011499999999 (Point)
- owner: Cenidet Palmira (string)
- address: Interior Internado Palmira S/N, Palmira, 62490 Cuernavaca, Mor. (string)
- description: Campus Cenidet (string)
### CompleteZone (Zone)
- idZone (string)
- dateCreated (string)
- dateModified (string)
- status: 1 (string)
### Parking (object)
- category: Private, For employees, For Visitors, For Students (array)
- location (Polygon)
- name: Estacionamiento 1,
- description: Estacionamiento 1,
### CompleteParking (Parking)
- idOffStreetParking: OffStreetParking_1534802604754 (string)
- type: OffStreetParking (string)
- areaServed: Zone_1525368918624 (string)
- dateCreated (string)
- dateModified (string)
- status: 1 (string)
### Road (object)
- name: Av. Palmira (string)
- description: Avenida Palmira (string)
- responsible: Zone_1524284309191 (string)
### CompleteRoad (Road)
- idRoad: Road_1534803087609 (string)
- type: Road (string)
- dateCreated (string)
- dateModified (string)
- status: 1 (string)
### RoadSegment (object)
- location (Polyline)
- startPoint: 18.88186, 99.220417 (array[number])
- endPoint: 18.88186, 99.220417 (array[number])
- laneUsage: forward (array)
- name: Av. Palmira 1 (string)
- refRoad: Road_1534803087609 (string)
- totalLaneNumber: 1 (number)
- maximumAllowedSpeed: 10 (number)
- minimumAllowedSpeed: 5 (number)
- width: 5 (number)
### CompleteRoadSegment (RoadSegment)
- idRoadSegment: RoadSegment_1534803216079 (string)
- type: RoadSegment (string)
- dateCreated (string)
- dateModified (string)
- status: 0 (string)
### DeviceToken (object)
- refDevice: Device_Smartphone_1fb5e1d94fbe3b07 (string)
- fcmToken: ftdRdA_u5RA:APA91bH8ydZgC1XkXE9BnczVpwFk3fjaYRpgckPyctZ9hTiedd-kOF2sjvBtD5WrnFClmnSyjctLE3rKUwNDWq9aCLm1MMT0-f_m7HzKiW9W3KNqfa0li_lvRSdEkR2kx5zQmYgwk2E- (string)
- preferences: All (string)
### CompleteDeviceToken (DeviceToken)
- idDeviceToken: DeviceToken_Device_Smartphone_1fb5e1d94fbe3b07 (string)
- dateCreated (string)
- dateModified (string)
- status: 1 (string)
### User
- firstName: "Micuenta",
- lastName: "Pruebas",
- email: "[email protected]"
- userName: mi (string)
- address (string)
- phoneNumber: 217351191662 (string)
### CompleteUser (User)
- id: User_1529706391351 (string)
- dateCreated (string)
- dateModified (string)
- status: 1 (string)
### UserToken
- token (string)
- user (CompleteUser)
### Alert
- id: AlertDevice_Smartphone (string)
- type: Alert (string)
- alertSource: Device_Smartphone_ (string)
- category: unknownAlert (string)
- dateObserved (string)
- description: Unknown Alert (string)
- location: 18.876708, -99.219859 (Point)
- severity: critical (string)
- subCategory: unknown (string)
- validFrom (string)
- validTo (string)
### Device
- id: Device_Smartphone (string)
- type: Device (string)
- accuracy: 3.700000048 (number)
- batteryLevel: 52.999996185 (number)
- category: smartphone (string)
- dateCreated (string)
- dateModified (string)
- ipAddress: 192.168.249.20 (string)
- location: 18.876708, -99.219859 (Point)
- osVersion: 5.1 (string)
- owner : User_1537282536716 (string)
- refDeviceModel: DeviceModel_TCL_ (string)
- serialNumber: 4TZHB6RO99999999 (string)
- time: 1521570000000 (number)
### CrateDevice
- category (string)
- entity_id (string)
- entity_type (string)
- location (Polygon)
- owner (string)
- time_index (string)
### Entities (object)
# Group Data Models API
### Verification [GET /api]
+ Response 200 (application/json)
+ Body
{
"message": "Welcome to DataModels API REST"
}
### Zones [/api/zone]
#### List Zones [GET /api/zone{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteZone])
#### Retreive a zone [GET /api/zone/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ Response 200
- Attributes (CompleteZone)
#### Create a Zone [POST]
+ Attributes (Zone)
+ Request (application/json)
+ Response 200
#### Delete a zone [DELETE /api/zone/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the parking
+ Response 204
### Parking [/api/parking]
#### List Parkings [GET /api/parking{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteParking])
#### Retreive a parking [GET /api/parking/{idOffStreetParking}]
+ Parameters
+ idOffStreetParking: OffStreetParking_1534802604754 (string) ... Id of the parking
+ Response 200
- Attributes (CompleteParking)
#### Create a parking [POST]
+ Attributes (Parking)
+ Request (application/json)
+ Response 200
- Attributes (CompleteParking)
#### Delete a parking [DELETE /api/parking/{idOffStreetParking}]
+ Parameters
+ idOffStreetParking: OffStreetParking_1534802604754 (string) ... Id of the parking
+ Response 204
### Road [/api/road]
#### List Roads [GET /api/road{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteRoad])
#### Retreive a road [GET /api/road/{idRoad}]
+ Parameters
+ idRoad: Road_1535062120621 (string) ... Id of the road
+ Response 200
- Attributes (CompleteRoad)
#### Create a road [POST]
+ Attributes (Road)
+ Request (application/json)
+ Response 200
- Attributes (CompleteRoad)
#### Delete a road [DELETE /api/road/{idRoad}]
+ Parameters
+ idRoad: Road_1535062120621 (string) ... Id of the road
+ Response 204
### Road segment [/api/roadSegment]
#### List road segments [GET /api/roadSegment{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteRoadSegment])
#### Retreive a road segment [GET /api/roadSegment/{idRoadSegment}]
+ Parameters
+ idRoadSegment: RoadSegment_1534803216079 (string) ... Id of the road segment
+ Response 200
- Attributes (CompleteRoadSegment)
#### Create a road segment [POST]
+ Attributes (RoadSegment)
+ Request (application/json)
+ Response 200
- Attributes (CompleteRoadSegment)
#### Delete a road segment [DELETE /api/roadSegment/{idRoadSegment}]
+ Parameters
+ idRoadSegment: RoadSegment_1534803216079 (string) ... Id of the road segment
+ Response 204
### Device Tokens [/api/device/token]
#### List Device Tokens[GET /api/device/token{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteDeviceToken])
#### Retreive a Device Token [GET /api/device/token/{idDeviceToken}]
+ Parameters
+ idDeviceToken: Device_Smartphone_1fb5e1d94fbe3b07 (string) ... Id of the device token
+ Response 200
- Attributes (CompleteDeviceToken)
#### Create a Device Token [POST]
+ Attributes (DeviceToken)
+ Request (application/json)
+ Response 200
- Attributes (CompleteDeviceToken)
#### Delete a Device Token [DELETE /api/device/token/{idDeviceToken}]
+ Parameters
+ idDeviceToken: Device_Smartphone_1fb5e1d94fbe3b07 (string) ... Id of the device token
+ Response 204
### User [/api/user]
#### List Users [GET /api/user{?status}]
+ Parameters
+ status: 1 (optional, string) - "1" gets all active entities, you can use "0" to reference inactives entities
+ Response 200 (application/json)
- Attributes (array[CompleteUser])
#### Login [POST /api/user/login]
+ Attributes
- phoneNumber : 5217351191661 (string)
- password : micienta
+ Request (application/json)
+ Response 200
- Attributes (UserToken)
#### Retreive a User [GET /api/user/{id}]
+ Parameters
+ id: User_1537282536716 (string) ... Id of the user
+ Response 200
- Attributes (CompleteUser)
#### Create a user[POST]
+ Attributes (User)
- password: mi (string)
+ Request (application/json)
+ Response 200
- Attributes (CompleteUser)
#### Delete a user [DELETE /api/user/{id}]
+ Parameters
+ id: User_1537282536716 (string) ... Id of the user
+ Response 204
# Group Special Services API
### Verification [GET /service]
+ Response 200 (application/json)
+ Body
{
"message": "Welcome to Especial Services API"
}
### Alerts [/service/alerts/zone/]
#### Retreive last ten alerts of the day on zone [GET /service/alerts/zone/current/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ Response 200 (application/json)
- Attributes (array[Alert])
#### Retreive last ten alerts of last hour on zone [GET /service/alerts/zone/current/hour/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ Response 200
- Attributes (array[Alert])
#### Retreive last ten alerts on the zone [GET /service/alerts/zone/history/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ Response 201 (application/json)
+ Header
fiware-total-count: 44455
- Attributes (array[Alert])
### Devices [/service/devices/zone/]
#### Retreive the devices on a zone [GET /service/devices/{idZone}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ Response 200
- Attributes (array[Device])
#### Retreive the device that belongs to the user on the zone [GET /devices/zone/{idZone}/owner{?phoneNumber}]
+ Parameters
+ idZone: Zone_1537468126033 (string) ... Id of the zone
+ phoneNumber: 5217351191662
+ Response 200
- Attributes (array[Device])
### Query [/service/query]
#### Make a query consult [POST]
+ Attributes
- id (string)
- type (string)
- options (string)
- georel (string)
- geometry (string)
- coords (Polygon)
+ Request (application/json)
+ Response 200
- Attributes (array[Entities])
# Group CrateDB Api
#### Verification [GET /crate]
+ Response 200 (application/json)
+ Body
{
"message": "Welcome to CRATE API"
}
#### Retreive the device of user that was on the zone [GET /crate/locationOwnerDateTime{?owner,date,time}]
+ Parameters
+ owner: User_1537282536716 (string) ... Id of the zone
+ date: 2018-02-08 (string)
+ time: 12 (number)
+ Response 200
- Attributes (array[CrateDevice])