Commit 2563c597 authored by Federico Sismondi's avatar Federico Sismondi
Browse files

Updated entities administration scripts

parent f1459372
...@@ -37,7 +37,7 @@ def get_ngsiv2_typed_description(val): ...@@ -37,7 +37,7 @@ def get_ngsiv2_typed_description(val):
else: else:
new_val = re.sub(pat, '', val) new_val = re.sub(pat, '', val)
return {'type': 'Text', 'value': new_val} return {'type': 'Text', 'value': new_val}
elif isinstance(val, datetime.datetime): elif isinstance(val, datetime):
# replace +00:00 is the same as Z but Orion doesnt like it :/ # replace +00:00 is the same as Z but Orion doesnt like it :/
return {'type': 'DateTime', 'value': str(val.isoformat()).replace("+00:00", "Z")} return {'type': 'DateTime', 'value': str(val.isoformat()).replace("+00:00", "Z")}
elif isinstance(val, dict): elif isinstance(val, dict):
...@@ -63,6 +63,9 @@ attrs = { ...@@ -63,6 +63,9 @@ attrs = {
'windSpeed': 0, 'windSpeed': 0,
'pressureTendency': 0.0, 'pressureTendency': 0.0,
'relativeHumidity': 0, 'relativeHumidity': 0,
"dewPoint": 0,
"windDirection": 0,
}, },
'WeatherForecast': { 'WeatherForecast': {
'dateIssued': datetime.utcnow(), # mandatory 'dateIssued': datetime.utcnow(), # mandatory
...@@ -97,33 +100,33 @@ entities = [ ...@@ -97,33 +100,33 @@ entities = [
('urn:ngsi-ld:WeatherObserved:WeatherObserved-1', ['alicante']), ('urn:ngsi-ld:WeatherObserved:WeatherObserved-1', ['alicante']),
('urn:ngsi-ld:WeatherObserved:WeatherObserved-2', ['alicante']), ('urn:ngsi-ld:WeatherObserved:WeatherObserved-2', ['alicante']),
# prediction use case - forecast today # # prediction use case - forecast today
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-0', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-0', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-1', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-1', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-2', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-2', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-3', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-3', ['carouge', 'alicante', 'braila']),
#
# prediction use case - forecast tomorrow # # prediction use case - forecast tomorrow
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-0', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-0', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-1', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-1', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-2', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-2', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-3', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-3', ['carouge', 'alicante', 'braila']),
#
# prediction use case - forecast tomorrow # # prediction use case - forecast tomorrow
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-0', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-0', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-1', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-1', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-2', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-2', ['carouge', 'alicante', 'braila']),
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-3', ['carouge', 'alicante', 'braila']), # ('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-3', ['carouge', 'alicante', 'braila']),
#
# watering use case - flower beds # # watering use case - flower beds
('urn:ngsi-ld:FlowerBed:FlowerBed-1', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-1', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-2', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-2', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-3', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-3', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-4', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-4', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-5', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-5', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-6', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-6', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-7', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-7', ['carouge']),
('urn:ngsi-ld:FlowerBed:FlowerBed-8', ['carouge']), # ('urn:ngsi-ld:FlowerBed:FlowerBed-8', ['carouge']),
] ]
# http headers # http headers
......
#!/usr/bin/env bash
[[ -z "$ORION_HOST" ]] && echo "Please set ORION_HOST env var. E.g. export ORION_HOST=127.0.0.1" && exit
echo "Querying context broker at: ${ORION_HOST}"
# API NOTES:
# "condition": { "attrs": [] } -> means monitor all the attributes in the entity
curl --location --request POST \
"http://$ORION_HOST:1026/v2/subscriptions/" \
--header "Fiware-Service: alicante" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"description": "Notify QuantumLeap, the historic API, of all WeatherObserved changes",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "WeatherObserved"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"http": {
"url": "http://172.18.1.7:8668/v2/notify"
},
"attrs": [],
"attrsFormat" : "normalized",
"metadata": ["dateCreated", "dateModified"]
}
}'
#!/usr/bin/env bash
[[ -z "$ORION_HOST" ]] && echo "Please set ORION_HOST env var. E.g. export ORION_HOST=127.0.0.1" && exit
echo "Querying context broker at: ${ORION_HOST}"
# API NOTES:
# "condition": { "attrs": [] } -> means monitor all the attributes in the entity
curl --location --request POST \
"http://$ORION_HOST:1026/v2/subscriptions/" \
--header "Fiware-Service: braila" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"description": "Notify QuantumLeap, the historic API, of all WeatherObserved changes",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "WeatherObserved"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"http": {
"url": "http://172.18.1.7:8668/v2/notify"
},
"attrs": [],
"attrsFormat" : "normalized",
"metadata": ["dateCreated", "dateModified"]
}
}'
...@@ -12,12 +12,12 @@ curl --location --request POST \ ...@@ -12,12 +12,12 @@ curl --location --request POST \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
--header "Accept: application/json" \ --header "Accept: application/json" \
--data '{ --data '{
"description": "Notify QuantumLeap, the historic API, of all WeatherObservedRaw changes", "description": "Notify QuantumLeap, the historic API, of all WeatherObserved changes",
"subject": { "subject": {
"entities": [ "entities": [
{ {
"idPattern": ".*", "idPattern": ".*",
"type": "WeatherObservedRaw" "type": "WeatherObserved"
} }
], ],
"condition": { "condition": {
...@@ -29,7 +29,7 @@ curl --location --request POST \ ...@@ -29,7 +29,7 @@ curl --location --request POST \
"url": "http://172.18.1.7:8668/v2/notify" "url": "http://172.18.1.7:8668/v2/notify"
}, },
"attrs": [], "attrs": [],
"attrsFormat" : "keyValues", "attrsFormat" : "normalized",
"metadata": ["dateCreated", "dateModified"] "metadata": ["dateCreated", "dateModified"]
} }
}' }'
curl --request DELETE 'localhost:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345'
#!/usr/bin/env bash
[[ -z "$ORION_HOST" ]] && echo "Please set ORION_HOST env var. E.g. export ORION_HOST=127.0.0.1" && exit
echo "Querying context broker at: ${ORION_HOST}"
curl --location --request DELETE "http://$ORION_HOST:1026/v2/subscriptions/5ec4fbfe91d551c2b4612f42"\
--header "Fiware-Service: carouge"
TODO list:
- PATCH /entity value of moisture & updated date of reading
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment