-
Notifications
You must be signed in to change notification settings - Fork 2
/
apiary.apib
721 lines (545 loc) · 25.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
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
FORMAT: 1A
HOST: https://app.apiary.io/ngsi9
TITLE: IoT Discovery GE Open API Specification
DATE: 17/09/2016
VERSION: Release_5
APIARY_PROJECT: ngsi9
SPEC_URL: http://
GITHUB_SOURCE: https://github.com/UniSurreyIoT/fiware-iot-discovery-ngsi9/blob/master/doc/apiary/ngsi9-server.apib
# FIWARE NGSI-9 API Core (v1)
The FIWARE version of the OMA NGSI-9 interface is a RESTful API via HTTP. Its purpose is to exchange information about the availability of context information. The three main interaction types are
* one-time queries for discovering hosts (also called 'agents' here) where certain context information is available
* subscriptions for context availability information updates (and the corresponding notifications)
* registration of context information, i.e. announcements that certain context information is available (invoked by context providers)
## Editors
+ Tarek Elsaleh (UNIS)
## Copyright
Copyright (c) 2016 UNIS
## License
This specification is licensed under the
[FIWARE Open Specification License (implicit patent license)](https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Implicit_Patents_License).
## Acknowledgements
Main contributers to the FIWARE NGSI-9 Binding Specification:
Fermin Galan Marquez (TID), Tobias Jacobs (NEC), Ken Gunner (TID), Salvatore Longo (NEC), Martin Bauer (NEC), Juanjo Hierro (TID), Boris Moltchanov (TI), Laurent Artusio (FT)
## Versions
+ This Version: http://docs.ngsi9.apiary.io/
## Status
FIWARE Release 5
## Conformance
All the interfaces described by this specification are mandatory and must be implemented in order to be compliant with.
# Specification
This section is intended to describe the main concepts, constructs, data structures etc. used by your specification.
## Introduction
###Standard NGSI-9 Operation Resources
The five resources listed in the table below represent the five operations offered by systems that implement the NGSI-9 Context Management role. Each of these resources allows interaction via http POST. All attempts to interact by other verbs shall result in an HTTP error status 405; the server should then also include the ‘Allow: POST’ field in the response.
| Resource | Base URI: http://{serverRoot}/ngsi9 | HTTP verbs |
|----|----|----|
| | | POST|
|Context Registration Resource |/registerContext|Generic context registration. The expected request body is an instance of registerContextRequest; the response body is an instance of registerContextResponse.|
|Discovery resource|/discoverContextAvailability|Generic discovery of context information providers. The expected request body is an instance of discoverContextAvailabilityRequest; the response body is an instance of discoverContextAvailabilityResponse.|
|Availability subscription resource|/subscribeContextAvailability|Generic subscription to context availability information. The expected request body is an instance of subscribeContextAvailabilityRequest; the response body is an instance of subscribeContextAvailabilityResponse.|
|Availability subscription update resource|/updateContextAvailabilitySubscription|Generic update of context availability subscriptions. The expected request body is an instance of updateContextAvailabilitySubscriptionRequest; the response body is an instance of updateContextAvailabilitySubscriptionResponse.|
|Availability subscription deletion resource|/unsubscribeContextAvailability|Generic deletion of context availability subscriptions. The expected request body is an instance of unsubscribeContextAvailabilityRequest; the response body is an instance of unsubscribeContextAvailabilityResponse.|
|Notify context resource|/{notificationURI}|Generic availability notification.The expected request body is an instance of notifyContextAvailabilityRequest; the response body is an instance of notifyContextAvailabilityResponse.|
###Convenience Operation Resources
The table below gives an overview of the resources for convenience operation and the effects of interacting with them via the standard HTTP verbs GET, PUT, POST, and DELETE.
|Resource|Base URI: http://{serverRoot}/ngsi9|HTTP verbs||||
|----|----|----|----|----|----|----|
| | | GET|PUT|POST|DELETE|
|Individual context entity |/contextEntities/{EntityID}|Retrieve information on providers of any information about the context entity|-|Register a provider of information about the entity|-|
|Attribute container of individual context entity|/contextEntities/{EntityID}/attributes|Retrieve information on providers of any information about the context entity|-|Register a provider of information about the entity|-|
|Attribute of individual context entity|/contextEntities/{EntityID}/attributes/{attributeName}|Retrieve information on providers of the attribute value|-|Register a provider of information about the attribute|-|
|Context entity type|/contextEntityTypes/{typeName}|Retrieve information on providers of any information about context entities of the type|-|Register a provider of information about context entitie of the type|-|
|Attribute container of entity type|/contextEntityTypes/{typeName}/attributes|Retrieve information on providers of any information about context entities of the type|-|Register a provider of information about context entitie of the type|-|
|Attribute of entity type|/contextEntityTypes/{typeName}/attributes/{attributeName}|Retrieve information on providers of values of this attribute of context entities of the type|-|Register a provider of information about this attribute of context entities of the type|-|
|Availability subscription container|/contextAvailabilitySubscriptions|-|-|Create a new availability subscription|-|
|Availability subscription|/contextAvailabilitySubscriptions/{subscriptionID}|-|Update subscription|-|Cancel subscription
###API operation on Context Consumer Component
This section describes the resource that has to be provided by the context consumer in order to receive availability notifications. All attempts to interact with it by other verbs than POST shall result in an HTTP error status 405; the server should then also include the ‘Allow: POST’ field in the response.
|Resource|Base URI: http://{serverRoot}/ngsi9|HTTP verbs|
|----|----|----|
| | | POST|
|Notify context resource|//{callbackURL}|Generic availability notification.The expected request body is an instance of notifyContextAvailabilityRequest; the response body is an instance of notifyContextAvailabilityResponse.|
## Terminology
## Concepts
###Basic NGSI Context Management Information Model
####Entities
The central aspect of the NGSI-9/10 information model is the concept of entities. Entities are the virtual representation of all kinds of physical objects in the real world. Examples for physical entities are tables, rooms, or persons. Virtual entities have an identifier and a type. For example, a virtual entity representing a person named “John” could have the identifier “John” and the type “person”.
####Attributes
Any available information about physical entities is expressed in the form of attributes of virtual entities. Attributes have a name and a type as well. For example, the body temperature of John would be represented as an attribute having the name “body_temperature” and the type “temperature”. Values of such attributes are contained by value containers. This kind of container does not only consist of the actual attribute value, but also contains a set of metadata. Metadata is data about data; in in our body temperature example this metadata could represent the time of measurement, the measurement unit, and other information about the attribute value.
####Attribute Domains
There also is a concept of attribute domains in OMA NGSI 9/10. An attribute domain logically groups together a set of attributes. For example, the attribute domain "health_status" could comprise of the attributes "body_temperature" and "blood_pressure".
####Context Elements
The data structure used for exchanging information about entities is context element. A context element contains information about multiple attributes of one entity. The domain of these attributes can also be specified inside the context element; in this case all provided attribute values have to belong to that domain.
Formally, a context element contains the following information
an entity id and type
a list of triplets <attribute name, attribute type, attribute value> holding information about attributes of the entity
(optionally) the name of an attribute domain
(optionally) a list of triplets <metadata name, metadata type, metadata value> that apply to all attribute values of the given domain
NGSI Context Management Interfaces
OMA NGSI defines two interfaces for exchanging information based on the information model. The interface OMA NGSI-10 is used for exchanging information about entities and their attribute, i.e., attribute values and metadata. The interface OMA NGSI-9 is used for availability information about entities and their attributes. Here, instead of exchanging attribute values, information about which provider can provide certain attribute values is exchanged.
## Data Structures
# REST API
# Group Root
### Context Registration Resource [POST /registerContext]
You may create your own request using this action. It takes a JSON
object containing a RegisterContextRequest message.
+ Request (application/json)
{
"contextRegistrations": [
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
},
{
"type": "Room",
"isPattern": "false",
"id": "Room2"
}
],
"attributes": [
{
"name": "temperature",
"type": "float",
"isDomain": "false"
},
{
"name": "pressure",
"type": "integer",
"isDomain": "false"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
],
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration" : "P1M",
"registrationId" : "52a744b011f5816465943d58"
}
### Discover Context availability operation [POST /discoverContextAvailability]
You may create your own request using this action. It takes a JSON
object containing a discoverContextAvailabilityRequest message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
]
}
+ Response 200 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"contextRegistrationResponses": [
{
"contextRegistration": {
"attributes": [
{
"isDomain": "false",
"name": "temperature",
"type": "float"
}
],
"entities": [
{
"id": "Room1",
"isPattern": "false",
"type": "Room"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
### Subscribe to Context availability operation [POST /subscribeContextAvailability]
You may create your own request using this action. It takes a JSON
object containing a subscribeContextAvailability message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:8080/accumulate",
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration": "P1M",
"subscriptionId": "52a745e011f5816465943d59"
}
### Update Subscription to Context availability operation [POST /updateContextAvailabilitySubscription]
You may create your own request using this action. It takes a JSON
object containing a updateContextAvailabilitySubscriptionRequest message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:8080/accumulate",
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration": "P1M",
"subscriptionId": "52a745e011f5816465943d59"
}
### Unsubscribe to Context availability operation [POST /unsubscribeContextAvailability]
You may create your own request using this action. It takes a JSON
object containing a unsubscribeContextAvailabilityRequest message.
+ Request (application/json)
{
"subscriptionId": "52a745e011f5816465943d59"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
},
"subscriptionId": "52a745e011f5816465943d59"
}
### Notify Context availability operation [POST /{callbackURL}]
This operation is initiated by the NGSI-9 server, when a registration match a subscription. It sends a JSON
object containing a NotifyContextAvailabilityRequest message, and receives from the subscriber a NotifyContextAvailabilityResponse message
+ Request (application/json)
{
"subscriptionId": "52a745e011f5816465943d59",
"contextRegistrationResponses": [
{
"contextRegistration": {
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
},
{
"type": "Room",
"isPattern": "false",
"id": "Room2"
}
],
"attributes": [
{
"name": "temperature",
"type": "float",
"isDomain": "false",
"metadatas": [
{
"name": "accuracy",
"type": "float",
"value": "0.8"
}
]
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
# Convenience operations [/]
Instances of this resource type are used for retrieving which information about a certain context entity is available. Furthermore, the availability of context information about this entity can be announced by interaction with this resource.
The {entitityID} part of the resource URI must denote the ID of an individual entity. The usage of regular expressions in {entityID} is supported neither here nor for any subresource.
## Convenience operation - Individual Context Entity [/contextEntities/{EntityID}]
### Register Context [POST]
This operation registers the availability of context information about the entity identified by the {entityID} part of the resource URI. Note that this operation can be used both for new registrations and for updates of existing registrations; in the latter case the request message should include the RegistrationId field.
The request message is an instance of registerProviderRequest. The response message is an instance of registerContextResponse.
+ Request (application/json)
{
"contextRegistrations": [
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
},
{
"type": "Room",
"isPattern": "false",
"id": "Room2"
}
],
"attributes": [
{
"name": "temperature",
"type": "float",
"isDomain": "false"
},
{
"name": "pressure",
"type": "integer",
"isDomain": "false"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
],
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration" : "P1M",
"registrationId" : "52a744b011f5816465943d58"
}
### Discover Context [GET]
Retrieve all availability information about the context entity represented by the resource (i.e. URIs of all applications that provide context information about the entity).
The response body is an instance of DiscoverContextAvailabilityResponse. Its ContextRegistrationResponseList contains context availability information related to the context entity that is determined by the {entitityID} part of the resource URI.
Use a GET request to retreive results for the {EntityID} specified in the URL path.
+ Response 200 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"contextRegistrationResponses": [
{
"contextRegistration": {
"attributes": [
{
"isDomain": "false",
"name": "temperature",
"type": "float"
}
],
"entities": [
{
"id": "Room1",
"isPattern": "false",
"type": "Room"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
## Convenience operation - Attribute of Individual Context Entity [/contextEntities/{EntityID}/attributes/{attributeName}]
### Discover Context [GET]
Retrieve all availability information about the attribute represented by the resource, including the respective metadata. The response body is an instance of DiscoverContextAvailabilityResponse, where the same restrictions as for GET operations on context entity resources apply. Additionally, only availability information related to the attribute determined by the {attributeName} part of the resource URI must be contained in the response.
Use a GET request to retreive results for the {EntityID} and {attributeName} specified in the URL path.
+ Response 200 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"contextRegistrationResponses": [
{
"contextRegistration": {
"attributes": [
{
"isDomain": "false",
"name": "temperature",
"type": "float"
}
],
"entities": [
{
"id": "Room1",
"isPattern": "false",
"type": "Room"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
## Convenience operation - Context Entity Type [/contextEntities/ContextEntityType/{typeName}]
Instances of this resource are used for retrieving availability information about context entities of the type represented by the resourceand announce the availability of such information.
### Discover Context [GET]
Retrieve availability of information about context entities of the type represented by this resource. The response body is an instance of discoverContextAvailabilityResponse, which only contains availability information related to entities having type {typeName}.
Use a GET request to retreive results for the {typeName} specified in the URL path.
+ Response 200 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"contextRegistrationResponses": [
{
"contextRegistration": {
"attributes": [
{
"isDomain": "false",
"name": "temperature",
"type": "float"
}
],
"entities": [
{
"id": "Room1",
"isPattern": "false",
"type": "Room"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
## Convenience operation - Attribute of Context Entity Type [/contextEntityTypes/{typeName}/attributes/{attributeName}]
Instances of this resource are used for retrieving availability information regarding a specific attribute of all context entities having a certain type, and for announcing the availability of such kind of information.
### Discover Context [GET]
Retrieve information on where values of the the attribute represented by the resource is available, and what the respective metadata is. The context entities of interest are all context entities of the type represented by the {typeName} part of the access URI.
+ Response 200 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"contextRegistrationResponses": [
{
"contextRegistration": {
"attributes": [
{
"isDomain": "false",
"name": "temperature",
"type": "float"
}
],
"entities": [
{
"id": "Room1",
"isPattern": "false",
"type": "Room"
}
],
"providingApplication": "http://mysensors.com/Rooms"
}
}
]
}
## Convenience operation - Availability Subscription [/contextAvailabilitySubscriptions]
This is a container resource for context availability subscriptions, where new subscriptions are created via POST.
### Create a new availability subscription [POST]
Create a new context availability subscription. The type of the request and response body is SubscribeContextAvailabilityRequest and SubscribeContextAvailabilityResponse, respectively. The subscription will be represented by a new child resource, whose URI is determined by the subscription ID inside the response body. The recipient URI of the subscription is to be specified in the Reference field of the the request body.
You may create your own request using this action. It takes a JSON object containing a subscribeContextAvailability message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:8080/accumulate",
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration": "P1M",
"subscriptionId": "52a745e011f5816465943d59"
}
## Convenience operation - Availability Subscription Container [/contextAvailabilitySubscriptions/{subscriptionID}]
Instances of this resource represent context availability subscriptions. They can be interacted with via PUT and DELETE. Creation of new availability subscriptions is done by interaction with the parent resource.
### Update Subscription [PUT]
This operation updates a context availability subscription. The request and response body is updateContextAvailabilitySubscriptionRequest and updateContextAvailabilitySubscriptionResponse, respectively. The subscriptionId field inside the request message must equal the {subscriptionID} part of the access URI, otherwise an error shall be returned.
You may create your own request using this action. It takes a JSON object containing a updateContextAvailabilitySubscriptionRequest message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:8080/accumulate",
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration": "P1M",
"subscriptionId": "52a745e011f5816465943d59"
}
### Cancel Subscription [DELETE]
This operation is used for deleting a context availability subscription, which corresponds to an unsubscribeContextAvailability operation. The request contains no body, and the response body is of type UnsubscribeContextAvailabilityResponse.
You may create your own request using this action. It takes a JSON object containing a updateContextAvailabilitySubscriptionRequest message.
+ Request (application/json)
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:8080/accumulate",
"duration": "P1M"
}
+ Response 201 (application/json)
+ Headers
Location: /ngsi9
+ Body
{
"duration": "P1M",
"subscriptionId": "52a745e011f5816465943d59"
}