#!/usr/bin/env bash # reference doc: https://fiware-tutorials.readthedocs.io/en/latest/pep-proxy/index.html [[ -z "$PROXY_HOST" ]] && echo "Please set PROXY_HOST env var. E.g. export PROXY_HOST=127.0.0.1" && exit echo "Querying Fiware entrypoint (PEP_PROXY) at: ${PROXY_HOST}" [[ -z "$KEYROCK_TOKEN" ]] && echo "Please set KEYROCK_TOKEN env var. E.g. export KEYROCK_TOKEN=****" && exit [[ -z "$SUBSCRIPTION_URL" ]] && echo "Please set SUBSCRIPTION_URL env var. E.g. export SUBSCRIPTION_URL=http://172.18.1.11:5000/on_change_soilMoisture" && echo "You can check out the wms-example source code for a server implementation example." && exit echo "Callback URL for subscriptions is: ${SUBSCRIPTION_URL}" curl --location --request POST \ "http://$PROXY_HOST:1027/v2/subscriptions/" \ --header "Fiware-Service: carouge" \ --header "Content-Type: application/json" \ --header "Accept: application/json" \ --header "X-Auth-Token: $KEYROCK_TOKEN" \ --data '{ "description": "A subscription to subscribe to FlowerBed.soilMoisture", "subject": { "entities": [ { "id": "urn:ngsi-ld:FlowerBed:FlowerBed-1", "type": "FlowerBed" } ], "condition": { "attrs": [ "soilMoisture" ] } }, "notification": { "http": { "url": "'${SUBSCRIPTION_URL}'" }, "attrs": [ "soilMoisture" ], "attrsFormat": "keyValues" }, "throttling": 5 }'