|
|
# Prepare environment
|
|
|
``` bash
|
|
|
export ORION_HOST=127.0.0.1
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
# Create, retrieve and update `entity`
|
|
|
|
|
|
Create the entity Flowerbed number 345:
|
|
|
|
|
|
````bash
|
|
|
mandint@naiades-platform-poc:~/naiades-platform-poc/scripts$ ./watering_01_create_entity.sh
|
|
|
Querying context broker at: 127.0.0.1
|
|
|
HTTP/1.1 100 Continue
|
|
|
|
|
|
HTTP/1.1 201 Created
|
|
|
Connection: Keep-Alive
|
|
|
Content-Length: 0
|
|
|
Location: /ngsi-ld/v1/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345
|
|
|
Date: Tue, 12 May 2020 11:32:28 GMT
|
|
|
```
|
|
|
|
|
|
Get all entities of a certain type:
|
|
|
|
|
|
```bash
|
|
|
mandint@naiades-platform-poc:~/naiades-platform-poc/scripts$ ./watering_02_retrieve_entities_by_type.sh
|
|
|
Querying context broker at: 127.0.0.1
|
|
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
|
|
Dload Upload Total Spent Left Speed
|
|
|
100 645 100 645 0 0 17916 0 --:--:-- --:--:-- --:--:-- 17916
|
|
|
[
|
|
|
{
|
|
|
"@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
|
|
|
"address": {
|
|
|
"type": "Property",
|
|
|
"value": {
|
|
|
"addressCountry": "Switzerland",
|
|
|
"adressLocality": "Carouge",
|
|
|
"streetAddress": "Place de Sardaigne",
|
|
|
"type": "PostalAddress"
|
|
|
}
|
|
|
},
|
|
|
"category": {
|
|
|
"type": "Property",
|
|
|
"value": "urbanTreeSpot"
|
|
|
},
|
|
|
"dateLastWatering": {
|
|
|
"type": "Property",
|
|
|
"value": {
|
|
|
"@type": "DateTime",
|
|
|
"@value": "2020-02-11T08:00:00Z"
|
|
|
}
|
|
|
},
|
|
|
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-345",
|
|
|
"location": {
|
|
|
"type": "GeoProperty",
|
|
|
"value": {
|
|
|
"coordinates": [
|
|
|
46.184255,
|
|
|
6.137837
|
|
|
],
|
|
|
"type": "Point"
|
|
|
}
|
|
|
},
|
|
|
"soilMoistureVwc": {
|
|
|
"type": "Property",
|
|
|
"value": 0.85
|
|
|
},
|
|
|
"soilTemperature": {
|
|
|
"type": "Property",
|
|
|
"value": 17
|
|
|
},
|
|
|
"type": "FlowerBed"
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
In the following we propose a simpler type-less query.
|
|
|
|
|
|
Getting keyvalues only simplify post-processing, use this unless you are parsing ngsi-ld object with libraries which require `type` information!
|
|
|
|
|
|
```
|
|
|
mandint@naiades-platform-poc:~/naiades-platform-poc/scripts$ ./watering_03_retrieve_entity_keyValues_by_id.sh
|
|
|
Querying context broker at: 127.0.0.1
|
|
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
|
|
Dload Upload Total Spent Left Speed
|
|
|
100 472 100 472 0 0 14750 0 --:--:-- --:--:-- --:--:-- 15225
|
|
|
{
|
|
|
"@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
|
|
|
"address": {
|
|
|
"addressCountry": "Switzerland",
|
|
|
"adressLocality": "Carouge",
|
|
|
"streetAddress": "Place de Sardaigne",
|
|
|
"type": "PostalAddress"
|
|
|
},
|
|
|
"category": "urbanTreeSpot",
|
|
|
"dateLastWatering": {
|
|
|
"@type": "DateTime",
|
|
|
"@value": "2020-02-11T08:00:00Z"
|
|
|
},
|
|
|
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-345",
|
|
|
"location": {
|
|
|
"coordinates": [
|
|
|
46.184255,
|
|
|
6.137837
|
|
|
],
|
|
|
"type": "Point"
|
|
|
},
|
|
|
"soilMoistureVwc": 0.85,
|
|
|
"soilTemperature": 17,
|
|
|
"type": "FlowerBed"
|
|
|
}
|
|
|
``` |