forked from FIWARE/tutorials.CRUD-Operations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIWARE CRUD Operations.postman_collection.json
827 lines (827 loc) · 41.6 KB
/
FIWARE CRUD Operations.postman_collection.json
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
{
"info": {
"_postman_id": "35d014dc-aa73-4424-8307-2e177af64f2a",
"name": "FIWARE CRUD Operations",
"description": "This tutorial builds on the data created in the previous [stock management example](http://fiware.github.io/tutorials.Entity-Relationships/) and introduces the concept of [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete), allowing users to manipulate the data held within the context.\n\nThe `docker-compose` file for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.CRUD-Operations/icon/GitHub-Mark-32px.png) [FIWARE 103: Manipulating Context Data through CRUD Operations ](https://github.com/Fiware/tutorials.CRUD-Operations)\n\n# Data Entities\n\nWithin the FIWARE platform, an entity represents the state of a physical or conceptural object which exists in the real world.\n\n## Entities within a stock management system\n\nWithin our simple stock management system, currently have four types of entity. The relationship between our entities is defined as shown:\n\n![](https://fiware.github.io/tutorials.Entity-Relationships/img/entities.png)\n\n* A **Store** is a real world bricks and mortar building. Stores would have properties such as:\n + A name of the store e.g. \"Checkpoint Markt\"\n + An address \"Friedrichstraße 44, 10969 Kreuzberg, Berlin\"\n + A phyiscal location e.g. *52.5075 N, 13.3903 E*\n* A **Shelf** is a real world device to hold objects which we wish to sell. Each shelf would have properties such as:\n + A name of the shelf e.g. \"Wall Unit\"\n + A phyiscal location e.g. *52.5075 N, 13.3903 E*\n + A maximum capacity\n + An association to the store in which the shelf is present\n* A **Product** is defined as something that we sell - it is conceptural object. Products would have properties such as:\n + A name of the product e.g. \"Vodka\"\n + A price e.g. 13.99 Euros\n + A size e.g. Small\n* An **Inventory Item** is another conceptural entity, used to assocate products, stores, shelves and physical objects. It would have properties such as:\n + An assocation to the product being sold\n + An association to the store in which the product is being sold\n + An association to the shelf where the product is being displayed\n + A stock count of the quantity of the product available in the warehouse\n + A stock count of the quantity of the product available on the shelf\n\n\nAs you can see, each of the entities defined above contain some properties which are liable to change. A product could change its price, stock could be sold and the shelf count of stock could be reduced and so on.\n\n\n# Architecture\n\nThis application will only make use of one FIWARE component - the [Orion Context Broker](https://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker). Usage of the Orion Context Broker is sufficient for an application to qualify as *“Powered by FIWARE”*.\n\nCurrently, the Orion Context Broker relies on open source [MongoDB](https://www.mongodb.com/) technology to keep persistence of the context data it holds. Therefore, the architecture will consist of two elements:\n\n* The Orion Context Broker server which will receive requests using [NGSI](https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json)\n* The underlying MongoDB database associated to the Orion Context Broker server\n\nSince all interactions between the two elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports. \n\n![](https://fiware.github.io/tutorials.CRUD-Operations/img/architecture.png)\n\nThe necessary configuration information can be seen in the services section of the associated `docker-compose.yml` file:\n\n```yaml\n orion:\n image: fiware/orion:latest\n hostname: orion\n container_name: orion\n depends_on:\n - context-db\n networks:\n - default\n expose:\n - \"1026\"\n ports:\n - \"1026:1026\"\n command: -dbhost context-db -logLevel DEBUG\n```\n\n```yaml\n context-db:\n image: mongo:3.6\n hostname: context-db\n container_name: context-db\n expose:\n - \"27017\"\n ports:\n - \"27017:27017\"\n networks:\n - default\n command: --bind_ip_all --smallfiles\n```\n\nBoth containers are residing on the same network - the Orion Context Broker is listening on Port `1026` \nand MongoDB is listening on the default port `271071`. Both containers are also exposing the same ports\nexternally - this is purely for the tutorial access - so that cUrl or Postman can access them without\nbeing part of the same network. The command line initialization should be self explanatory.\n\n![](https://fiware.github.io/tutorials.Entity-Relationships/img/architecture.png)\n\n# Prerequisites\n\n## Docker\n\nTo keep things simple both components will be run using [Docker](https://www.docker.com). **Docker** is a container technology which allows to different components isolated into their respective environments. \n\n* To install Docker on Windows follow the instructions [here](https://docs.docker.com/docker-for-windows/)\n* To install Docker on Mac follow the instructions [here](https://docs.docker.com/docker-for-mac/)\n* To install Docker on Linux follow the instructions [here](https://docs.docker.com/install/)\n\n**Docker Compose** is a tool for defining and running multi-container Docker applications. A [YAML file](https://raw.githubusercontent.com/Fiware/tutorials.Entity-Relationships/master/docker-compose.yml) is used configure the required\nservices for the application. This means all container sevices can be brought up in a single commmand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users will need to follow the instructions found [here](https://docs.docker.com/compose/install/)\n\n## Cygwin \n\nWe will start up our services using a simple bash script. Windows users should download [cygwin](www.cygwin.com) to provide a command line functionality similar to a Linux distribution on Windows. \n\n\n# Start Up\n\nAll services can be initialised from the command line by running the bash script provided within the repository:\n\n```bash\n./services start\n```\n\nThis command will also import seed data from the previous [Store Finder tutorial](https://github.com/Fiware/tutorials.Entity-Relationships) on startup.\n\n# What is CRUD?\n\n**Create**, **Read**, **Update** and **Delete** are the four basic functions of persistent storage. These operations are usually referred to using the acronym **CRUD**. Within a database each of these operations map directly to a series of commands, however the relationship with a RESTful API is slightly more complex.\n\nThe Orion Context Broker server uses [NGSI](https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json) to manipulate the context data. As a RESTful API, requests to manipulate the data held within the context follow the standard conventions found when mapping HTTP verbs to CRUD operations. \n\n## Entity CRUD Operations\n\n\nFor operations where the `<entity>` is not yet known within the context or is unspecified, the `/v2/entities` endpoint is used.\n\nOnce an `<entity>` is known within the context, individual data entities can be manipulated using the `/v2/entities/<entity>` endpoint.\n\nIt is recommended that entity identifiers should be a URN following [NGSI-LD guidelines](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf), therefore each `id` is a URN follows a standard format: `urn:ngsi-ld:<entity-type>:<entity-id>`. This will mean that every `id` in the context data will be unique.\n\n\n| HTTP Verb | `/v2/entities` | `/v2/entities/<entity>` |\n|----------- |:--------------: |:-----------------------: |\n| **POST** | CREATE a new entity and add to the context. | CREATE or UPDATE an attribute of a specified entity. |\n| **GET** | READ entity data from the context. This will return data from multiple entities. The data can be filtered. | READ entity data from a specified entity. This will return data from a single entity only. The data can be filtered. | \n| **PUT** | Not Used | Not Used |\n| **PATCH** | Not Used | Not Used |\n| **DELETE** | Not Used | DELETE an entity from the context | \n\nA complete list of entity endpoints can be found by looking at the [NGSI v2 Swagger Specification](https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json#/Entities)\n\n## Attribute CRUD Operations\n\nTo perform CRUD operations on attributes, the `<entity>` must be known. Each attribute is effectively a key value pair.\n\n There are three endpoints:\n\n* `/v2/entities/<entity>/attrs` is only used for a patch operation to update one or more exisiting attributes.\n* `/v2/entities/<entity>/attrs/<attribute>` is used to manipulate an attribute as a whole.\n* `/v2/entities/<entity>/attrs/<attribute>/value` is used to read or update the `value` of an attribute, leaving the `type` untouched.\n\n\n| HTTP Verb | `/v2/entities/<entity>/attrs` | `/v2/entities/<entity>/attrs/<attribute>` | `/v2/entities/<entity>/attrs/<attribute>/value` |\n|----------- |:-----------------------------: |:-----------------------------------------: |:-----------------------------------------------: |\n| **POST** | Not Used | Not Used | Not Used |\n| **GET** | Not Used | Not Used | READ the value of an attribute from a specified entity. This will return a single field. |\n| **PUT** | Not Used | Not Used | UPDATE the value of single attribute from a specified entity. |\n| **PATCH** | UPDATE one or more existing attributes from an existing entity. | Not Used | Not Used |\n| **DELETE**. | Not Used | DELETE an existing attribute from an existing entity. | Not Used |\n\nA complete list of attribute endpoints can be found by looking at the [NGSI v2 Swagger Specification](https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json#/Attributes)\n\n\n## Batch CRUD Operations\n\nAdditionally the Orion Context Broker a convenience batch operation endpoint `/v2/op/update` to manipulate multiple entities in a single operation.\n\nBatch operations are always made using a POST request, where the payload is an object with two properties:\n\n* `actionType` specifies the kind of action to invoke (e.g. `DELETE`) \n* `entities` is an array object holding the list of entities to update, along with the relevant entity data used to make the operation.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Create Operations",
"description": "Create Operations map to HTTP POST.\n\nAny newly created entity must have a `id` and `type` attributes, each additional attributes are optional and will depend on the system being described. Each additional attribute should also have a \ndefined `type` and a `value` attribute. \n\n",
"item": [
{
"name": "Create a New Data Entity",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": " {\n \"id\":\"urn:ngsi-ld:Product:010\", \"type\":\"Product\",\n \"name\":{\"type\":\"Text\", \"value\":\"Lemonade\"},\n \"size\":{\"type\":\"Text\", \"value\": \"S\"},\n \"price\":{\"type\":\"Integer\", \"value\": 99}\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
]
},
"description": "This example adds a new **Product** entity to the context.\n\nNew entities can be added by making a POST request to the `/v2/entities/` endpoint.\n\nThe request will **fail** if any of the attributes already exist in the context.\n\nAny entity must have a `id` and `type` attributes, each additional attributes are optional \nand will depend on the system being described. Each additional attribute should also have a \ndefined `type` and a `value` attribute. The product has been assigned a unique `id` following\nthe NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`.\n\n---\nSubsequent requests using the same `id` will result in an error response."
},
"response": []
},
{
"name": "Create a New Attribute",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"specialOffer\":{\"value\": true}\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/attrs",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
"attrs"
]
},
"description": "This example adds a new `specialOffer` attribute to the existing **Product** entity with `id=urn:ngsi-ld:Product:001`\n\nNew attributes can be added by making a POST request to the `/v2/entities/<entity>/attrs` endpoint. \n\nThe payload should consist of a JSON object holding the attribute names and values as shown. \n\nIf no `type` is specified a default `type` (`Boolean`, `Text` or `Number` or `StructuredValue`) will be assigned.\n\n---\nSubsequent requests using the same `id` will update the value of the attribute in the context"
},
"response": []
},
{
"name": "Batch Create New Data Entities or Attributes",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"append_strict\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:011\", \"type\":\"Product\",\n \"name\":{\"type\":\"Text\", \"value\":\"Brandy\"},\n \"size\":{\"type\":\"Text\", \"value\": \"M\"},\n \"price\":{\"type\":\"Integer\", \"value\": 1199}\n },\n {\n \"id\":\"urn:ngsi-ld:Product:012\", \"type\":\"Product\",\n \"name\":{\"type\":\"Text\", \"value\":\"Port\"},\n \"size\":{\"type\":\"Text\", \"value\": \"M\"},\n \"price\":{\"type\":\"Integer\", \"value\": 1099}\n },\n {\n \"id\":\"urn:ngsi-ld:Product:001\", \"type\":\"Product\",\n \"offerPrice\":{\"type\":\"Integer\", \"value\": 89}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update",
""
]
},
"description": "This example uses the convenience batch processing endpoint to add two new **Product** entities and one new attribute (`offerPrice`)\nto the context. \n\nThe request will **fail** if any of the attributes already exist in the context.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes\n* `actionType=append_strict` means that the request only succeed all entities / attributes are new.\n* The `entities` attribute holds an array of entities we wish to create.\n\nEach product has a unique `id` following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`.\n\n---\nSubsequent request using the same data with the `actionType=append_strict` batch operation will result in an error response."
},
"response": []
},
{
"name": "Batch Create/Overwrite New Data Entities",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"append\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:011\", \"type\":\"Product\",\n \"name\":{\"type\":\"Text\", \"value\":\"Brandy\"},\n \"size\":{\"type\":\"Text\", \"value\": \"M\"},\n \"price\":{\"type\":\"Integer\", \"value\": 1199}\n },\n {\n \"id\":\"urn:ngsi-ld:Product:012\", \"type\":\"Product\",\n \"name\":{\"type\":\"Text\", \"value\":\"Port\"},\n \"size\":{\"type\":\"Text\", \"value\": \"M\"},\n \"price\":{\"type\":\"Integer\", \"value\": 1099}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update",
""
]
},
"description": "This example uses the convenience batch processing endpoint to adds or ammend two **Product** entities and one attribute (`offerPrice`) to the context.\n\n* if the entities already exist - the request will update the attributes of an entity. \n\n* if the entities do not exist, a new entity will be created.\n\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes:\n* `actionType=append` means we will overwrite existing entities if they exist\n* The `entities` attribute holds an array of entities we wish to create/overwrite.\n\nEach product has a unique `id` following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`.\n\n---\nSubsequent request using the same data with the `actionType=append` batch operation can applied without changing the result beyond the initial application."
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "e188a3c9-0964-40d4-bb85-30f8dba187dd",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "50a197ae-0c79-49f9-9f06-850bcee94f15",
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "Read Operations",
"description": "Read Operations map to HTTP GET.\n\n* The `/v2/entities/` endpoint is used for listing operations\n* The `/v2/entities/<entity>` endpoint is used for retrieving the details of a single entity\n\n## Filtering\n\n* The `options` parameter (combined with the `attrs` parameter) is used to filter the fields returned\n* The `q` parameter can be used to filter the entities returned \n",
"item": [
{
"name": "Read a Data Entity (verbose)",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:010",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:010"
]
},
"description": "This example reads the full context from an existing **Product** entity with a known id.\n\nContext data can be retrieved by making a GET request to the `/v2/entities/<entity>` endpoint."
},
"response": []
},
{
"name": "Read an Attribute from a Data Entity",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/attrs/name/value",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
"attrs",
"name",
"value"
]
},
"description": "This example reads the value of a single attribute (`name`) from an existing **Product** entity with a known `id`.\n\nContext data can be retrieved by making a GET request to the `/v2/entities/<entity>/attrs/<attribute>/value` endpoint."
},
"response": []
},
{
"name": "Read a Data Entity (key value pairs)",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/?options=keyValues&attrs=name,price",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
""
],
"query": [
{
"key": "options",
"value": "keyValues",
"description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only\n"
},
{
"key": "attrs",
"value": "name,price",
"description": "Ordered list of attribute names to display"
}
]
},
"description": "This example reads the key-value pairs for two requested attributes (`name` and `price`) from the context of existing **Product** entity with a known `id`.\n\nCombine the `options=keyValues` parameter and the `attrs` parameter to obtain key-values."
},
"response": []
},
{
"name": "Read Multiple attributes values from a Data Entity",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/?options=values&attrs=name,price",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
""
],
"query": [
{
"key": "options",
"value": "values",
"description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only"
},
{
"key": "attrs",
"value": "name,price",
"description": "Ordered list of attribute names to display"
}
]
},
"description": "This example reads the value of two requested attributes (`name` and `price`) from the context of existing **Product** entity with a known `id`.\n\nCombine the `options=values` parameter and the `attrs` parameter to return a list of values in an array"
},
"response": []
},
{
"name": "List all Data Entities (verbose)",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/?type=Product",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "type",
"value": "Product"
}
]
},
"description": "This example lists the full context of all **Product** entities.\n\nFull context data for a specified entity type can be retrieved by making a GET request to the `/v2/entities/` endpoint and supplying the `type` parameter."
},
"response": []
},
{
"name": "List all Data Entities (key value pairs)",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/?type=Product&options=keyValues&attrs=name,price",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "type",
"value": "Product",
"description": "Entity type"
},
{
"key": "options",
"value": "keyValues",
"description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only\n"
},
{
"key": "attrs",
"value": "name,price",
"description": "Ordered list of attribute names to display"
}
]
},
"description": "This example lists the `name` and `price` attributes of all **Product** entities.\n\nFull context data for a specified entity type can be retrieved by making a GET request to the `/v2/entities/` endpoint and supplying the `type` parameter combine this with the `options=keyValues` parameter and the `attrs` parameter to obtain key-values."
},
"response": []
},
{
"name": "List Data Entity by id",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/?type=Product&options=count&attrs=id",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "type",
"value": "Product",
"description": "Entity type"
},
{
"key": "options",
"value": "count",
"description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only"
},
{
"key": "attrs",
"value": "id",
"description": "Ordered list of attribute names to display"
}
]
},
"description": "This example lists the `id` and `type` of all **Product** entities.\n\nContext data for a specified entity type can be retrieved by making a GET request to the `/v2/entities/` endpoint and supplying the `type` parameter. Combine this with `options=count` and `attrs=id` to return the `id` attributes of the given `type`"
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "dc10dc62-ba5f-4e31-b75e-20e743651cb4",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "6d3402d3-9f76-4770-96a6-3ea6b7325376",
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "Update Operations",
"description": "Overwrite operations are mapped to HTTP PUT.\nHTTP PATCH can be used to update several attributes at once.\n",
"item": [
{
"name": "Overwrite the value of an Attribute value",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": {
"mode": "raw",
"raw": "89"
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/attrs/price/value",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
"attrs",
"price",
"value"
]
},
"description": "This example updates the value of the `price` attribute of the Entity with `id=urn:ngsi-ld:Product:001`\n\nExisiting attribute values can be altered by making a PUT request to the `/v2/entities/<entity>/attrs/<attribute>/value` endpoint."
},
"response": []
},
{
"name": "Overwrite Multiple Attributes of a Data Entity",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": " {\n \"price\":{\"type\":\"Integer\", \"value\": 89}\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:001/attrs",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:001",
"attrs"
]
},
"description": "This example simultaneously updates the values of both the `price` and `name` attributes of the Entity with `id=urn:ngsi-ld:Product:001`\n\nMultiple Existing attribute values can be updated by making a PATCH request to the `/v2/entities/<entity>/attrs` endpoint."
},
"response": []
},
{
"name": "Batch Overwrite Attributes of Multiple Data Entities",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"update\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:001\", \"type\":\"Product\",\n \"price\":{\"type\":\"Integer\", \"value\": 1199}\n },\n {\n \"id\":\"urn:ngsi-ld:Product:002\", \"type\":\"Product\",\n \"price\":{\"type\":\"Integer\", \"value\": 1199},\n \"size\": {\"type\":\"Text\", \"value\": \"L\"}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update"
]
},
"description": "This example uses the convenience batch processing endpoint to create a series of available products.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes - `actionType=update` means we will overwrite existing entities if they exist whereas the `entities` attribute holds an array of entities we wish to update.\n\nEach product has a unique `id` following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`."
},
"response": []
},
{
"name": "Batch Create/Overwrite Attributes of Multiple Data Entities",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"append\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:001\", \"type\":\"Product\",\n \"price\":{\"type\":\"Integer\", \"value\": 1199}\n },\n {\n \"id\":\"urn:ngsi-ld:Product:002\", \"type\":\"Product\",\n \"price\":{\"type\":\"Integer\", \"value\": 1199},\n \"specialOffer\": {\"type\":\"Boolean\", \"value\": true}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update"
]
},
"description": "This example uses the convenience batch processing endpoint to create a series of available products.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes - `actionType=append` means we will overwrite existing entities if they exist whereas the `entities` attribute holds an array of entities we wish to update.\n\nEach product has a unique `id` following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`."
},
"response": []
},
{
"name": "Batch Replace Entity Data",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"replace\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:010\", \"type\":\"Product\",\n \"price\":{\"type\":\"Integer\", \"value\": 1199}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update"
]
},
"description": "This example uses the convenience batch processing endpoint to create a series of available products.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes - `actionType=replace` means we will overwrite existing entities if they exist whereas the `entities` attribute holds an array of entities we wish to update.\n\nEach product has a unique `id` following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) and has been assigned `type=Product`."
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "061914f4-8b31-4177-a3e2-5a7d0bf58522",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "b098aeb4-22e9-4224-a638-ac10bb75d84f",
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "Delete Operations",
"description": "Delete Operations map to HTTP DELETE.\n\n## Data Relationships\n\nIf there are entities within the context which relate to one another, you must be careful when deleting an entity. You will need to check that no references are left dangling once the entity has been deleted. \n\nOrganizing a cascade of deletions is beyond the scope of this tutorial, but it would be possible using a batch delete request.",
"item": [
{
"name": "Delete a Data Entity",
"request": {
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:010",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:010"
]
},
"description": "This example deletes the Entity with `id=urn:ngsi-ld:Product:001` from the context\n\nEntities be deleted by making a DELETE request to the `/v2/entities/<entity>` endpoint.\n\n---\nSubsequent requests using the same `id` will result in an error response since the entity no longer exists"
},
"response": []
},
{
"name": "Delete an Attribute from a Data Entity",
"request": {
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Product:010/attrs/specialOffer",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Product:010",
"attrs",
"specialOffer"
]
},
"description": "This example remove the `specialOffer` attribute from the Entity with `id=urn:ngsi-ld:Product:010` \n\nAttributes be deleted by making a DELETE request to the `/v2/entities/<entity>/attrs/<attribute>` endpoint.\n\n---\nIf the attribute does not exist in the context, the result in an error response."
},
"response": []
},
{
"name": "Batch Delete Multiple Data Entities",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"delete\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:001\", \"type\":\"Product\"\n },\n {\n \"id\":\"urn:ngsi-ld:Product:002\", \"type\":\"Product\"\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update"
]
},
"description": "This example uses the convenience batch processing endpoint to delete a series of available products.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes - `actionType=delete` means we will\ndelete something from the context and the `entities` attribute holds the `id` of the entities we wish to update.\n\n---\nIf any entity does not exist in the context, the result in an error response."
},
"response": []
},
{
"name": "Batch Delete Multiple Attributes from a Data Entity",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\":\"delete\",\n \"entities\":[\n {\n \"id\":\"urn:ngsi-ld:Product:010\", \"type\":\"Product\",\n \"price\":{},\n \"name\": {}\n }\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/op/update",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"op",
"update"
]
},
"description": "This example uses the convenience batch processing endpoint to delete a series of attributes from an available product.\n\nBatch processing uses the `/v2/op/update` endpoint with a payload with two attributes - `actionType=delete` means we will\ndelete something from the context and the `entities` attribute holds an array of attributes we wish to update.\n\n---\nIf any attribute does not exist in the context, the result in an error response."
},
"response": []
},
{
"name": "Find existing data relationships",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"actionType\": \"APPEND\",\n \"entities\": [\n {\n \"id\": \"7770\",\n \"type\": \"Shelf\",\n \"store\": { \n \"type\": \"Relationship\",\n \"value\": \"urn:ngsi-ld:Store:store1\"\n },\n \"location\": {\n \"type\": \"geo:json\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [13.3986112, 52.554699]\n }\n },\n \"name\": {\n \"type\": \"Text\",\n \"value\": \"Corner Unit\"\n },\n \"maxCapacity\": {\n \"type\": \"Integer\",\n \"value\": 50\n }\n},\n\n {\n \"id\": \"7771\",\n \"type\": \"Shelf\",\n \"store\": {\n \"type\": \"Relationship\",\n \"value\": \"urn:ngsi-ld:Store:store1\"\n },\n \"location\": {\n \"type\": \"geo:json\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 13.3987221,\n 52.5546640\n ]\n }\n },\n \"name\": {\n \"type\": \"Text\",\n \"value\": \"Wall Unit 1\"\n },\n \"maxCapacity\": {\n \"type\": \"Integer\",\n \"value\": 100\n }\n },\n \n {\n \"id\": \"7772\",\n \"type\": \"Shelf\",\n \"store\": {\n \"type\": \"Relationship\",\n \"value\": \"urn:ngsi-ld:Store:store1\"\n },\n \"location\": {\n \"type\": \"geo:json\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 13.3987221,\n 52.5546640\n ]\n }\n },\n \"name\": {\n \"type\": \"Text\",\n \"value\": \"Wall Unit 2\"\n },\n \"maxCapacity\": {\n \"type\": \"Integer\",\n \"value\": 100\n }\n }\n \n \n\n\n\n\n ]\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/?q=refProduct==urn:ngsi-ld:Product:001&options=count&attrs=type",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "q",
"value": "refProduct==urn:ngsi-ld:Product:001"
},
{
"key": "options",
"value": "count",
"description": "* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values `attrs` for an ordered list of attributes only"
},
{
"key": "attrs",
"value": "type",
"description": "Ordered list of attribute names to display"
}
]
},
"description": "This example returns the key of all entities directly associated with the `urn:ngsi-ld:Product:001`.\n\n* If this request returns an empty array, the entity has no associates - it can be safely deleted\n* If the response lists a series of **InventoryItem** entities they should be deleted before the product is removed from the context."
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "add1245d-f9c3-4610-ae32-d12708236de5",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "0dd3c8e8-b424-43ae-a176-72bcb7b2ba7c",
"type": "text/javascript",
"exec": [
""
]
}
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "dff76437-6762-4f0f-9258-d0e5c77cca33",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "afdd2592-13bb-436d-a728-8af2d8c3d958",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"id": "0b237012-4447-4688-bc10-bd8332c946c3",
"key": "orion",
"value": "localhost:1026",
"type": "string",
"description": ""
}
]
}