Commit 7b1b1063 authored by Federico Sismondi's avatar Federico Sismondi

Merge branch 'develop' of...

Merge branch 'develop' of https://gitlab.distantaccess.com/naiades/naiades-platform-poc into develop
parents 8677472b b4280820
...@@ -114,10 +114,18 @@ UPDATE| ...@@ -114,10 +114,18 @@ UPDATE|
cd naiades-platform-poc cd naiades-platform-poc
docker-compose up -d docker-compose up -d
``` ```
## Put platform down
```bash
cd naiades-platform-poc
docker-compose down
```
## Check services' status ## Check services' status
```bash ```bash
>>> docker-compose ps docker-compose ps
Name Command State Ports Name Command State Ports
------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------
...@@ -133,61 +141,6 @@ mongo-express tini -- /docker-entrypoint ... Up 0. ...@@ -133,61 +141,6 @@ mongo-express tini -- /docker-entrypoint ... Up 0.
## Run demo using shell scripts in `scripts` folder ## Run demo using shell scripts in `scripts` folder
Let's start by looking at the type of REST requests used in the scripts: Please see `getting started` documentation at this [link](https://gitlab.distantaccess.com/naiades/naiades-platform-poc/-/wikis/API-client-examples-(curl-and-python-scripts))
```bash
cat 01_create_entity.sh
curl --location --request POST 'http://localhost:1026/v2/entities/' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-345",
"type": "FlowerBed",
"category": {
"type": "Property",
"value": ["urbanTreeSpot"]
},
"soilMoistureVwc": {
"type": "Property",
"value": 0.85
},
"dateLastWatering": {
"type": "DateTime",
"value": "2020-02-11T08:00:00Z"
},
"soilTemperature": {
"type": "Property",
"value": 17
},
"address": {
"type": "Property",
"value": {
"addressCountry": "Switzerland",
"streetAddress": "Place de Sardaigne",
"adressLocality": "Carouge",
"type": "PostalAddress"
}
},
"location": {
"type": "GeoProperty",
"value": {
"type": "Point",
"coordinates": [46.184255,6.1378375]
}
}
}'
```
Now, let's run the script:
```bash
cd scripts
./01_create_entity.sh
```
## Put platform down
``` bash
cd naiades-platform-poc
docker-compose down
```
# This is for building docker images for running the scripts
FROM python:3.8-slim-buster
MAINTAINER Federico Sismondi <fsismondi@udgalliance.org>
RUN apt-get update
RUN mkdir /scripts
WORKDIR /scripts
COPY requirements.txt requirements.txt
RUN pip install --timeout 300 -r requirements.txt
COPY . /scripts
CMD ["echo", "please override this CMD with some .sh or .py script call"]
#!/usr/bin/env bash
[[ -z "$CRATE_HOST" ]] && echo "Please set CRATE_HOST env var. E.g. export CRATE_HOST=127.0.0.1" && exit
echo "Querying historical data at: ${CRATE_HOST}"
curl --location --request POST \
"http://CRATE_HOST:4200/_sql" \
--header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"stmt":"SHOW TABLES"
}'
\ No newline at end of file
#!/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: carouge" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"description": "Notify QuantumLeap, the historic API, of all WeatherObservedRaw changes",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "WeatherObservedRaw"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"http": {
"url": "http://172.18.1.7:8668/v2/notify"
},
"attrs": [],
"attrsFormat" : "keyValues",
"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: carouge" \
--header "Fiware-ServicePath: /Watering" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"description": "Notify QuantumLeap, the historic API, of all FlowerBed changes",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "FlowerBed"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"http": {
"url": "http://172.18.1.7:8668/v2/notify"
},
"attrs": [],
"metadata": ["dateCreated", "dateModified"]
}
}'
#!/usr/bin/env bash
[[ -z "$QUANTUM_HOST" ]] && echo "Please set QUANTUM_HOST env var. E.g. export QUANTUM_HOST=127.0.0.1" && exit
echo "Querying QuantumLeap API at: ${QUANTUM_HOST}"
curl --location --request GET \
"http://$QUANTUM_HOST:8668/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value?limit=100" \
--header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \
--header "Accept: application/json"
#| python -mjson.tool
requests
\ No newline at end of file
...@@ -4,47 +4,23 @@ ...@@ -4,47 +4,23 @@
echo "Querying context broker at: ${ORION_HOST}" echo "Querying context broker at: ${ORION_HOST}"
curl -iX POST \ curl -iX POST \
"http://$ORION_HOST:1026/v2/entities/" \ "http://$ORION_HOST:1026/v2/entities/?options=keyValues" \
--header "Fiware-Service: carouge" \ --header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \ --header "Fiware-ServicePath: /Watering" \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
--data '{ --data '{
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-345", "id": "urn:ngsi-ld:FlowerBed:FlowerBed-1",
"type": "FlowerBed", "type": "FlowerBed",
"category": { "dateModified":"2017-03-31T08:00",
"type": "Property", "category": ["urbanTreeSpot"],
"value": ["urbanTreeSpot"] "dateLastWatering": "2017-03-31T08:00",
}, "nextWateringDeadline":"2017-04-31T08:00",
"soilMoistureVwc": {
"type": "Property",
"value": 0.85
},
"dateLastWatering": {
"type": "Property",
"value": {
"@type": "DateTime",
"@value": "2020-02-11T08:00:00Z"
}
},
"soilTemperature": {
"type": "Property",
"value": 17
},
"address": { "address": {
"type": "Property",
"value": {
"addressCountry": "Switzerland",
"streetAddress": "Place de Sardaigne", "streetAddress": "Place de Sardaigne",
"adressLocality": "Carouge", "adressLocality": "Carouge",
"type": "PostalAddress" "addressCountry": "Switzerland"
}
}, },
"location": { "soilTemperature": 17,
"type": "GeoProperty", "soilMoistureVwc": 0.85
"value": {
"type": "Point",
"coordinates": [46.184255,6.1378375]
}
}
} }
' '
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}" echo "Querying context broker at: ${ORION_HOST}"
curl --location --request GET \ curl --location --request GET \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345?options=keyValues" \ "http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1?options=keyValues" \
--header "Fiware-Service: carouge" \ --header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \ --header "Fiware-ServicePath: /Watering" \
| python -mjson.tool | python -mjson.tool
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}" echo "Querying context broker at: ${ORION_HOST}"
curl --location --request GET \ curl --location --request GET \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345/attrs/soilMoistureVwc/value" \ "http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value" \
--header "Fiware-Service: carouge" \ --header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \ --header "Fiware-ServicePath: /Watering" \
| python -mjson.tool | python -mjson.tool
......
...@@ -4,13 +4,8 @@ ...@@ -4,13 +4,8 @@
echo "Querying context broker at: ${ORION_HOST}" echo "Querying context broker at: ${ORION_HOST}"
curl --location --request GET \ curl --location --request GET \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345/attrs/soilMoistureVwc" \ "http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc" \
--header "Fiware-Service: carouge" \ --header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \ --header "Fiware-ServicePath: /Watering" \
| python -mjson.tool | python -mjson.tool
#curl --location --request GET \
# "http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345/attrs/location" \
# --header "Fiware-Service: carouge" \
# --header "Fiware-ServicePath: /Watering" \
# | python -mjson.tool
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}" echo "Querying context broker at: ${ORION_HOST}"
curl --location --request PUT \ curl --location --request PUT \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345/attrs/soilMoistureVwc/value"\ "http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value"\
--header "Fiware-Service: carouge" \ --header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /Watering" \ --header "Fiware-ServicePath: /Watering" \
--header "Content-Type: text/plain" \ --header "Content-Type: text/plain" \
......
...@@ -18,7 +18,7 @@ curl --location --request POST \ ...@@ -18,7 +18,7 @@ curl --location --request POST \
"subject": { "subject": {
"entities": [ "entities": [
{ {
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-345", "idPattern": ".*",
"type": "FlowerBed" "type": "FlowerBed"
} }
], ],
......
curl --request DELETE 'localhost:1026/v2/subscriptions/5e54f6dc00043ebcd1ef0850' #!/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"
Markdown is supported
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