NGSI Go Quick Start Guide
Add a broker
You register an alias to access the broker.
ngsi broker add --host letsfiware --brokerHost http://localhost:1026 --ngsiType v2
Get broker version by using an alias
You can get the version by using the alias letsfiware
.
ngsi version -h letsfiware
{
"orion" : {
"version" : "3.6.0",
"uptime" : "0 d, 0 h, 0 m, 1 s",
"git_hash" : "973850279e63d58cb93dff751648af5ec6e05777",
"compile_time" : "Wed Mar 2 10:34:48 UTC 2022",
"compiled_by" : "root",
"compiled_in" : "5e6b6f1167f7",
"release_date" : "Wed Mar 2 10:34:48 UTC 2022",
"machine" : "x86_64",
"doc" : "https://fiware-orion.rtfd.io/en/3.6.0/",
"libversions": {
"boost": "1_66",
"libcurl": "libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 nghttp2/1.33.0",
"libmosquitto": "2.0.12",
"libmicrohttpd": "0.9.70",
"openssl": "1.1",
"rapidjson": "1.1.0",
"mongoc": "1.17.4",
"bson": "1.17.4"
}
}
}
Once you access the broker, you can omit to specify the broker.
ngsi version
If you want to check the current default settings, you can run the following command.
ngsi settings list
Create a entity
ngsi create entity --keyValues \
--data ' {
"id":"urn:ngsi-ld:Product:110",
"type":"Product",
"name": "Lemonade",
"size": "S",
"price": 99
}'
Get a entity
ngsi get entity --id urn:ngsi-ld:Product:110 --type Product
{"id":"urn:ngsi-ld:Product:110","type":"Product","name":{"type":"Text","value":"Lemonade","metadata":{}},"price":{"type":"Number","value":99,"metadata":{}},"size":{"type":"Text","value":"S","metadata":{}}}
Update attribute
ngsi update attr --id urn:ngsi-ld:Product:110 --attr price --data 11
Get a entity (keyValues)
ngsi get entity --id urn:ngsi-ld:Product:110 --keyValues
{"id":"urn:ngsi-ld:Product:110","name":"Lemonade","price":11,"size":"S","type":"Product"}
Print number of entities
ngsi wc entities --type Product
10
Delete a entity
ngsi delete entity --id urn:ngsi-ld:Product:110
Print number of entities again
ngsi wc entities --type Product
9