security_04_update_entity_with_token.sh 864 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env bash

# reference doc: https://fiware-tutorials.readthedocs.io/en/latest/pep-proxy/index.html

[[ -z "$FIWARE_PROXY_HOST" ]] && echo "Please set FIWARE_PROXY_HOST env var. E.g. export FIWARE_PROXY_HOST=127.0.0.1" && exit
echo "Querying Fiware entrypoint (PEP_PROXY) at: ${FIWARE_PROXY_HOST}"

[[ -z "$KEYROCK_TOKEN" ]] && echo "Please set KEYROCK_TOKEN env var. E.g. export KEYROCK_TOKEN=****" && exit

curl --location --request PUT \
    "http://$FIWARE_PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-345/attrs/soilMoistureVwc/value"\
    --header "Fiware-Service: carouge" \
13
    --header "Fiware-ServicePath: /Watering" \
14 15 16 17
    --header "X-Auth-Token: $KEYROCK_TOKEN" \
    --header "Content-Type: text/plain" \
    -d $(( RANDOM % 10 ))

18
echo "If you now re-run script <security_04...>.sh you will get a different value for the entity"