Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
naiades
naiades-platform-poc
Commits
2563c597
Commit
2563c597
authored
Oct 21, 2020
by
Federico Sismondi
Browse files
Updated entities administration scripts
parent
f1459372
Changes
7
Hide whitespace changes
Inline
Side-by-side
scripts-admin/create_entities.py
View file @
2563c597
...
...
@@ -37,7 +37,7 @@ def get_ngsiv2_typed_description(val):
else
:
new_val
=
re
.
sub
(
pat
,
''
,
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 :/
return
{
'type'
:
'DateTime'
,
'value'
:
str
(
val
.
isoformat
()).
replace
(
"+00:00"
,
"Z"
)}
elif
isinstance
(
val
,
dict
):
...
...
@@ -63,6 +63,9 @@ attrs = {
'windSpeed'
:
0
,
'pressureTendency'
:
0.0
,
'relativeHumidity'
:
0
,
"dewPoint"
:
0
,
"windDirection"
:
0
,
},
'WeatherForecast'
:
{
'dateIssued'
:
datetime
.
utcnow
(),
# mandatory
...
...
@@ -97,33 +100,33 @@ entities = [
(
'urn:ngsi-ld:WeatherObserved:WeatherObserved-1'
,
[
'alicante'
]),
(
'urn:ngsi-ld:WeatherObserved:WeatherObserved-2'
,
[
'alicante'
]),
# prediction use case - forecast today
(
'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-2'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
(
'urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-3'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
# prediction use case - forecast tomorrow
(
'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-2'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
(
'urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-3'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
# prediction use case - forecast tomorrow
(
'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-2'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
(
'urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-3'
,
[
'carouge'
,
'alicante'
,
'braila'
]),
# watering use case - flower beds
(
'urn:ngsi-ld:FlowerBed:FlowerBed-1'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-2'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-3'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-4'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-5'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-6'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-7'
,
[
'carouge'
]),
(
'urn:ngsi-ld:FlowerBed:FlowerBed-8'
,
[
'carouge'
]),
#
#
prediction use case - forecast today
#
('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-2', ['carouge', 'alicante', 'braila']),
#
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day0-3', ['carouge', 'alicante', 'braila']),
#
#
#
prediction use case - forecast tomorrow
#
('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-2', ['carouge', 'alicante', 'braila']),
#
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day1-3', ['carouge', 'alicante', 'braila']),
#
#
#
prediction use case - forecast tomorrow
#
('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-2', ['carouge', 'alicante', 'braila']),
#
('urn:ngsi-ld:WeatherForecast:WeatherForecast-Day2-3', ['carouge', 'alicante', 'braila']),
#
#
#
watering use case - flower beds
#
('urn:ngsi-ld:FlowerBed:FlowerBed-1', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-2', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-3', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-4', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-5', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-6', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-7', ['carouge']),
#
('urn:ngsi-ld:FlowerBed:FlowerBed-8', ['carouge']),
]
# http headers
...
...
scripts-admin/historic_api_subscribe_to_weather_observed_alicante.sh
0 → 100755
View file @
2563c597
#!/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"]
}
}'
scripts-admin/historic_api_subscribe_to_weather_observed_braila.sh
0 → 100755
View file @
2563c597
#!/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"]
}
}'
scripts-admin/historic_api_subscribe_to_weather_observed.sh
→
scripts-admin/historic_api_subscribe_to_weather_observed
_carouge
.sh
View file @
2563c597
...
...
@@ -12,12 +12,12 @@ curl --location --request POST \
--header
"Content-Type: application/json"
\
--header
"Accept: application/json"
\
--data
'{
"description": "Notify QuantumLeap, the historic API, of all WeatherObserved
Raw
changes",
"description": "Notify QuantumLeap, the historic API, of all WeatherObserved changes",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "WeatherObserved
Raw
"
"type": "WeatherObserved"
}
],
"condition": {
...
...
@@ -29,7 +29,7 @@ curl --location --request POST \
"url": "http://172.18.1.7:8668/v2/notify"
},
"attrs": [],
"attrsFormat" : "
keyValues
",
"attrsFormat" : "
normalized
",
"metadata": ["dateCreated", "dateModified"]
}
}'
scripts/xx_delete_entity.sh
deleted
100755 → 0
View file @
f1459372
curl
--request
DELETE
'localhost:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345'
scripts/xx_delete_subs.sh
deleted
100755 → 0
View file @
f1459372
#!/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"
scripts/xx_todo.sh
deleted
100755 → 0
View file @
f1459372
TODO list:
- PATCH /entity value of moisture & updated
date
of reading
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment