Bachelorthesis_Code/requests.sh

61 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
2021-07-22 00:37:04 +00:00
ACTION=$1
VALUE=$2
2021-07-24 22:05:11 +00:00
ACTIONS=(login register rcvpw username data csv prod_data prod_csv)
print_help(){
echo "Usage: $0 ACTION [TOKEN|INPUT_TYPE]"
2021-07-22 00:37:04 +00:00
echo
echo "available actions:"
for el in "${ACTIONS[@]}"; do
echo - "$el"
done
exit 1
}
if [[ -z $1 ]]; then
print_help
fi
2021-07-22 00:37:04 +00:00
case $ACTION in
"${ACTIONS[0]}") # login
echo "login action"
curl localhost:5050/api/login -X POST -d '{"username":"test","password":"test"}'
;;
2021-07-22 00:37:04 +00:00
"${ACTIONS[1]}") # register
echo "register action"
curl localhost:5050/api/register -X POST -d '{"username":"test","password":"test"}'
;;
2021-07-22 00:37:04 +00:00
"${ACTIONS[2]}") # reveice password
echo "rcv_pw action"
2021-07-22 00:37:04 +00:00
curl localhost:5050/api/protected/rcv_pw
;;
"${ACTIONS[3]}") # get current username
echo "get username action"
curl localhost:5050/api/username -X GET -H "Authorization: Bearer $VALUE"
;;
"${ACTIONS[4]}") # get all data from behametricsserver
echo "get data action"
curl localhost:5000/data
;;
"${ACTIONS[5]}") # get all data from behametricsserver
2021-07-24 22:05:11 +00:00
echo "get csv from input action"
curl localhost:5000/data/csv/"${VALUE}"
;;
2021-07-24 22:05:11 +00:00
"${ACTIONS[6]}") # get all data from behametricsserver
echo "get prod data action"
curl behavior.marcocamenzind.ch:5000/data
;;
"${ACTIONS[7]}") # get all data from behametricsserver
echo "get prod csv from input action"
curl behavior.marcocamenzind.ch:5000/data/csv/"${VALUE}"
;;
*)
2021-07-22 00:37:04 +00:00
echo "Error: Action not available"
echo
print_help
;;
esac