forked from FIWARE/tutorials.Getting-Started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIWARE Getting Started.postman_collection.json
386 lines (386 loc) · 17.2 KB
/
FIWARE Getting Started.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
{
"info": {
"_postman_id": "dd7b3ba8-5aa3-405a-b054-47608a483f77",
"name": "FIWARE Getting Started",
"description": "Let’s start with the data from a supermarket chain’s store finder and create a very simple *“Powered by FIWARE”* application by passing in the address and location of each store as context data to the FIWARE context broker.\n\nThe `docker-compose` file for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Getting-Started/icon/GitHub-Mark-32px.png) [FIWARE 101: An Introduction to the FIWARE Platform](https://github.com/Fiware/tutorials.Getting-Started)\n\n# Architecture\n\nOur demo 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\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.Getting-Started/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\n\n# Starting the Containers\n\n## Initialization\n\nFirst pull the necessary Docker images from Docker Hub and create a network for our containers to connect to:\n\n```console \ndocker pull mongo:3.6\ndocker pull fiware/orion\ndocker network create fiware_default\n```\n\n## Start Up\n\nA Docker container running a MongoDB database can be started and connected to the network with the following command:\n\n```console\ndocker run -d --name=context-db --network=fiware_default \\\n --expose=27017 mongo:3.6 --bind_ip_all --smallfiles\n``` \n\nThe Orion Context Broker can be started and connected to the network with the following command:\n\n```console\ndocker run -d --name orion --network=fiware_default \\\n -p 1026:1026 fiware/orion -dbhost context-db\n``` \n\nYou can check if the Orion Context Broker is running by making an HTTP request to the exposed port:\n\n```console\ncurl -X GET http://localhost:1026/version\n```\n\nAlternatively run all your curl commands from within the container network:\n\n```console\ndocker run --network fiware_default --rm appropriate/curl -s \\\n -X GET http://orion:1026/version\n```\n\n**What if I get an error response?**\n\nIf you get an error response, the Orion Content Broker cannot be found where expected\nfor this tutorial - you will need to substitute the URL and port in each Postman request \nwith the corrected ip address. All the Postman requests in this tutorial assume \nthat orion is available on `localhost:1026`. \n \nTry the following remedies:\n\n* To check that the dockers container are running try the following:\n\n```console\ndocker ps\n```\n\nYou should see two containers running. If orion is not running, you can restart the \ncontainers as necessary. This command will also display open port information.\n\n* If you have installed [`docker-machine`](https://docs.docker.com/machine/) and [Virtual Box](https://www.virtualbox.org/), you will need to retrieve the virtual host ip as shown:\n\n```console\ncurl -X GET http://$(docker-machine ip default):1026/version\n```\n\nIf you need to update the location of orion:\n\n1. Click on the elipsis `...` at the head of the imported postman collection\n2. Select `edit` from the dropdown\n3. Click on the `variables` tab and alter the value from `localhost:1026` as necessary.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Obtaining Version Information",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/version/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"version",
""
]
},
"description": "Once the Orion Context Broker is running, You can check the status by making an HTTP request to the exposed port. \nIf the response is blank, this is usually because the MongoDB database holding the context information is not running or not connected.\n\n>**Troubleshooting:** What if the response is blank ?\n>\n> * To check that a docker container is running try\n>\n>```bash\n>docker ps\n>```\n>\n>You should see two containers running. If orion is not running, you can restart the containers as necessary."
},
"response": []
},
{
"name": "Creating your first Data Entity",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"urn:ngsi-ld:Store:001\",\n \"type\": \"Store\",\n \"address\": {\n \"type\": \"PostalAddress\",\n \"value\": {\n \"streetAddress\": \"Bornholmer Straße 65\",\n \"addressRegion\": \"Berlin\",\n \"addressLocality\": \"Prenzlauer Berg\",\n \"postalCode\": \"10439\"\n },\n \"metadata\": {\n \t\t\"verified\": {\n \t\t\"value\": true,\n \t\t\"type\": \"Boolean\"\n \t\t}\n \t}\n },\n \"location\": {\n \"type\": \"geo:json\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [13.3986, 52.5547]\n }\n },\n \"name\": {\n \"type\": \"Text\",\n \"value\": \"Bösebrücke Einkauf\"\n }\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
]
},
"description": "## Creating Context Data\n\nAt its heart, FIWARE is a system for managing context information, so lets add some context data into the system by creating a new entity (a store in **Berlin**). Any entity must have a `id` and `type` attributes, additional attributes are optional and will depend on the system being described. Each additional attribute should also have a defined `type` and a `value` attribute."
},
"response": []
},
{
"name": "Creating your Second Data Entity",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"type\": \"Store\",\n \"id\": \"urn:ngsi-ld:Store:002\",\n \"address\": {\n \"type\": \"PostalAddress\",\n \"value\": {\n \"streetAddress\": \"Friedrichstraße 44\",\n \"addressRegion\": \"Berlin\",\n \"addressLocality\": \"Kreuzberg\",\n \"postalCode\": \"10969\"\n },\n \"metadata\": {\n \t\t\"verified\": {\n \t\t\"value\": true,\n \t\t\"type\": \"Boolean\"\n \t\t}\n \t}\n },\n \"location\": {\n \"type\": \"geo:json\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [13.3903, 52.5075]\n }\n },\n \"name\": {\n \"type\": \"Text\",\n \"value\": \"Checkpoint Markt\"\n }\n}"
},
"url": {
"raw": "http://{{orion}}/v2/entities/",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
]
}
},
"response": []
},
{
"name": "Retrieving Context Information",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities"
]
},
"description": "This example returns the full data context"
},
"response": []
},
{
"name": "Obtain Entity Data by id",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Store:001?options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
"urn:ngsi-ld:Store: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"
},
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id",
"disabled": true
},
{
"key": "attrs",
"value": "name",
"description": "Ordered list of attribute names to display",
"disabled": true
}
]
},
"description": "This example returns the context data of `store1`. The `id` of the entity should be unique or the `type` parameter should also be used.\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` elements."
},
"response": []
},
{
"name": "Obtain Entity Data by type",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/?type=Store&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id"
},
{
"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"
},
{
"key": "attrs",
"value": "name",
"description": "Ordered list of attribute names to display",
"disabled": true
}
]
},
"description": "This example returns the data of all `Store` entities within the context data. \n\nThe `type` parameter limits the response to store entities only.\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` elements."
},
"response": []
},
{
"name": "Filter context data by attribute value",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/?q=name=='Checkpoint Markt'&type=Store&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "q",
"value": "name=='Checkpoint Markt'"
},
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id"
},
{
"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"
},
{
"key": "attrs",
"value": "name",
"description": "Ordered list of attribute names to display",
"disabled": true
}
]
},
"description": "## Filter context data by comparing the values of an attribute\n\nThis example returns the data of all `Store` entities found with the name *Checkpoint Markt*. \n\nFiltering can be done using the `q` parameter - if a string has spaces in it, it can be URL encoded and held within single quote characters `'` = `%27`\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` and `metadata` elements."
},
"response": []
},
{
"name": "Filter context data by sub-attribute value",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/?q=address.addressLocality=='Kreuzberg'&type=Store&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "q",
"value": "address.addressLocality=='Kreuzberg'"
},
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id"
},
{
"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"
}
]
},
"description": "## Filter context data by comparing the values of an attribute\n\nThis example returns the data of all `Store` entities found in the **Kreuzberg** district of Berlin.\n\nFiltering can be done using the `q` parameter - sub-attributes are annotated using the dot syntax e.g. `address.addressLocality`\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` and `metadata` elements."
},
"response": []
},
{
"name": "Filter context data by querying metadata",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/?mq=address.verified==true&type=Store&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "mq",
"value": "address.verified==true"
},
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id"
},
{
"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"
}
]
},
"description": "## Filter context data by comparing the values of an metadata attribute\n\nThis example returns the data of all `Store` entities with a verified address.\n\nMetadata queries can be made using the `mq` parameter."
},
"response": []
},
{
"name": "Filter context data by distance",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{orion}}/v2/entities/?georel=near;maxDistance:1500&geometry=point&coords=52.5162,13.3777&type=Store&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
],
"path": [
"v2",
"entities",
""
],
"query": [
{
"key": "georel",
"value": "near;maxDistance:1500"
},
{
"key": "geometry",
"value": "point"
},
{
"key": "coords",
"value": "52.5162,13.3777"
},
{
"key": "type",
"value": "Store",
"description": "Entity type, to avoid ambiguity in case there are several entities with the same entity id"
},
{
"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"
},
{
"key": "attrs",
"value": "name",
"description": "Ordered list of attribute names to display",
"disabled": true
}
]
},
"description": "## Filter context data by comparing the values of a geo:point attribute\n\nThis example returns the data of all `Store` entities found within 1.5km the **Brandenburg Gate** in **Berlin** (*52.5162N 13.3777W*)"
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "581cc060-de73-4283-915a-fcaa1c126830",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "5215414e-418f-4c32-8070-b68d62c90ea4",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"id": "df0c7c83-8325-4d8f-8b3f-bea47630872d",
"key": "orion",
"value": "localhost:1026",
"type": "string"
}
]
}