ngsi broker get --host orion
brokerHost http://orion:1026
ngsiType v2
ngsi version -h orion
This example adds a new Product entity ("Lemonade" at 99 cents) to the context.
ngsi create entity \
--data ' {
"id":"urn:ngsi-ld:Product:010", "type":"Product",
"name":{"type":"Text", "value":"Lemonade"},
"size":{"type":"Text", "value": "S"},
"price":{"type":"Integer", "value": 99}
}'
ngsi get entity --id urn:ngsi-ld:Product:010 --type Product
This example adds a new specialOffer
attribute to the existing Product entity with id=urn:ngsi-ld:Product:001
.
ngsi append attrs --id urn:ngsi-ld:Product:010 \
--data '{
"specialOffer":{"value": true}
}'
ngsi get entity --id urn:ngsi-ld:Product:001 --type Product
This example uses the convenience batch processing endpoint to add two new Product entities and one new attribute
(offerPrice
) to the context.
ngsi create entities \
--data '[
{
"id":"urn:ngsi-ld:Product:011", "type":"Product",
"name":{"type":"Text", "value":"Brandy"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:012", "type":"Product",
"name":{"type":"Text", "value":"Port"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1099}
},
{
"id":"urn:ngsi-ld:Product:001", "type":"Product",
"offerPrice":{"type":"Integer", "value": 89}
}
]'
This example uses the convenience batch processing endpoint to add or amend two Product entities and one attribute
(offerPrice
) to the context.
- if an entity already exists, the request will update that entity's attributes.
- if an entity does not exist, a new entity will be created.
ngsi upsert entities \
--data '[
{
"id":"urn:ngsi-ld:Product:011", "type":"Product",
"name":{"type":"Text", "value":"Brandy"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:012", "type":"Product",
"name":{"type":"Text", "value":"Port"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1099}
}
]'
This example reads the full context from an existing Product entity with a known id
.
ngsi upsert entities \
ngsi get entity --id urn:ngsi-ld:Product:010 --type Product
This example reads the value of a single attribute (name
) from an existing Product entity with a known id
.
ngsi get attr --id urn:ngsi-ld:Product:001 --attr name
This example reads the key-value pairs of two attributes (name
and price
) from the context of existing Product
entities with a known id
.
ngsi get entity --keyValues --type Product --id urn:ngsi-ld:Product:001 --attrs name,price
{"id":"urn:ngsi-ld:Product:001","type":"Product","name":"Lemonade","price":99}
ngsi get attrs --keyValues --type Product --id urn:ngsi-ld:Product:001 --attrs name,price
{"name":"Lemonade","price":99}
This example reads the value of two attributes (name
and price
) from the context of existing Product entities
with a known ID.
ngsi get attrs --id urn:ngsi-ld:Product:001 --attrs name,price --values
This example lists the full context of all Product entities.
ngsi list entities --type Product
This example lists the name
and price
attributes of all Product entities.
ngsi list entities --type Product -attrs name,price --keyValues
This example lists the id
and type
of all Product entities.
ngsi list entities --type Product -attrs name,price --keyValues
ngsi list entities --type Product -attrs id
This example updates the value of the price attribute of the Entity with id=urn:ngsi-ld:Product:001
ngsi update attr --id urn:ngsi-ld:Product:001 --attr price --data 89
This example simultaneously updates the values of both the price and name attributes of the Entity with
id=urn:ngsi-ld:Product:001
.
ngsi update attrs --id urn:ngsi-ld:Product:001 \
--data ' {
"price":{"type":"Integer", "value": 89},
"name": {"type":"Text", "value": "Ale"}
}'
This example uses the convenience batch processing endpoint to update existing products.
ngsi update entities \
--data '[
{
"id":"urn:ngsi-ld:Product:001", "type":"Product",
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:002", "type":"Product",
"price":{"type":"Integer", "value": 1199},
"size": {"type":"Text", "value": "L"}
}
]'
This example uses the convenience batch processing endpoint to update existing products.
ngsi upsert entities \
--data '[
{
"id":"urn:ngsi-ld:Product:001", "type":"Product",
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:002", "type":"Product",
"price":{"type":"Integer", "value": 1199},
"specialOffer": {"type":"Boolean", "value": true}
}
]'
This example uses the convenience batch processing endpoint to replace entity data of existing products.
ngsi replace entities \
--data '[
{
"id":"urn:ngsi-ld:Product:010", "type":"Product",
"price":{"type":"Integer", "value": 1199}
}
]'
This example deletes the entity with id=urn:ngsi-ld:Product:001
from the context.
ngsi delete entity --id urn:ngsi-ld:Product:010
This example removes the specialOffer
attribute from the entity with id=urn:ngsi-ld:Product:001
.
ngsi delete attr --id urn:ngsi-ld:Product:001 --attr specialOffer
This example uses the convenience batch processing endpoint to delete some Product entities.
ngsi delete entities \
--data '[
{
"id":"urn:ngsi-ld:Product:001", "type":"Product"
},
{
"id":"urn:ngsi-ld:Product:002", "type":"Product"
}
]'
This example uses the convenience batch processing endpoint to delete some attributes from a Product entity.
ngsi delete entities \
--data '[
{
"id":"urn:ngsi-ld:Product:003", "type":"Product",
"price":{},
"name": {}
}
]'
This example returns the key of all entities directly associated with the urn:ngsi-ld:Product:001
.
ngsi list entities -q "refProduct%==urn:ngsi-ld:Product:001" --attrs type