chore: new requests
This commit is contained in:
78
req.sh
78
req.sh
@@ -1,25 +1,30 @@
|
|||||||
#ADDR=api-fema.ekatgortrans.ru:39080
|
#ADDR=api-fema.ekatgortrans.ru:39080
|
||||||
ADDR=https://api.fema.krbl.ru
|
#ADDR=https://api.fema.krbl.ru
|
||||||
#ADDR=62.217.183.88:8080
|
#ADDR=62.217.183.88:8080
|
||||||
|
ADDR=0.0.0.0:8080
|
||||||
LOGIN=admin
|
LOGIN=admin
|
||||||
PASSWORD=admin
|
PASSWORD=admin
|
||||||
|
#PASSWORD=IR7?BoouErjhXsxg
|
||||||
#PASSWORD=ra8KvcMxS2baUxe*
|
#PASSWORD=ra8KvcMxS2baUxe*
|
||||||
#MASTER_CODE=342985
|
#MASTER_CODE=685658
|
||||||
MASTER_CODE=111111
|
MASTER_CODE=111111
|
||||||
|
|
||||||
|
|
||||||
|
#set -x
|
||||||
|
|
||||||
H="-H \"Authorization: Bearer $(cat tmp.token)\""
|
H="-H \"Authorization: Bearer $(cat tmp.token)\""
|
||||||
|
|
||||||
if [[ $1 == "login" ]]; then
|
if [[ $1 == "login" ]]; then
|
||||||
# Login
|
# Login
|
||||||
RESP=$(curl -X POST -H "Content-Type: application/json" -d "{ \"login\": \"$LOGIN\", \"password\": \"$PASSWORD\" }" "$ADDR/auth/signin")
|
RESP=$(curl -X POST -H "Content-Type: application/json" -d "{ \"login\": \"$LOGIN\", \"password\": \"$PASSWORD\" }" "$ADDR/auth/signin")
|
||||||
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
# if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
||||||
echo "Failed to login"
|
# echo "Failed to login"
|
||||||
echo $RESP | jq '.error'
|
# echo $RESP | jq '.error'
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
# fi
|
||||||
|
#
|
||||||
# 2FA
|
# # 2FA
|
||||||
RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
|
# RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
|
||||||
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
||||||
echo "Failed to login"
|
echo "Failed to login"
|
||||||
echo $RESP | jq '.error'
|
echo $RESP | jq '.error'
|
||||||
@@ -28,6 +33,12 @@ if [[ $1 == "login" ]]; then
|
|||||||
|
|
||||||
echo "Login success!"
|
echo "Login success!"
|
||||||
echo $RESP | jq ".data" | tr -d "\"" > tmp.token
|
echo $RESP | jq ".data" | tr -d "\"" > tmp.token
|
||||||
|
elif [[ $1 == "update-user" ]]; then
|
||||||
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||||
|
-d "{\"username\": \"admin\", \"email\": \"yotia@unprism.ru\", \"full_name\": \"oaf\", \"is_admin\": true}" \
|
||||||
|
"$ADDR/auth/updateUser"
|
||||||
|
elif [[ $1 == "users" ]]; then
|
||||||
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/system/getUsers"
|
||||||
elif [[ $1 == "devices" ]]; then
|
elif [[ $1 == "devices" ]]; then
|
||||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices"
|
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices"
|
||||||
elif [[ $1 == "devices-serial" ]]; then
|
elif [[ $1 == "devices-serial" ]]; then
|
||||||
@@ -36,6 +47,40 @@ elif [[ $1 == "devices-serial-with-reg" ]]; then
|
|||||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices" | jq ".devices[] | (.SERIAL) +\" -- \"+ (.REG_NUMBER)" | tr -d "\""
|
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices" | jq ".devices[] | (.SERIAL) +\" -- \"+ (.REG_NUMBER)" | tr -d "\""
|
||||||
elif [[ $1 == "devices-status" ]]; then
|
elif [[ $1 == "devices-status" ]]; then
|
||||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices" | jq ".devices[] | (.SERIAL) +\" -- \"+ (.IS_CONNECTED|tostring)+\" -- \"+ (.REG_NUMBER)" | tr -d "\""
|
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices" | jq ".devices[] | (.SERIAL) +\" -- \"+ (.IS_CONNECTED|tostring)+\" -- \"+ (.REG_NUMBER)" | tr -d "\""
|
||||||
|
elif [[ $1 == "factories" ]]; then
|
||||||
|
curl -X GET -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getFactories" | jq
|
||||||
|
elif [[ $1 == "factory-models" ]]; then
|
||||||
|
if [[ $2 == "" ]]; then
|
||||||
|
echo "No serial presented"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
curl -X GET -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"ids\": $2 }" "$ADDR/data/getFactoryModels" | jq
|
||||||
|
elif [[ $1 == "grouped-sensors" ]]; then
|
||||||
|
if [[ $2 == "" ]]; then
|
||||||
|
echo "No serial presented"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"devices\": [\"$2\"] }" "$ADDR/data/sensors/getGroupedDevicesSensors" | jq
|
||||||
|
elif [[ $1 == "multi-device-sensors" ]]; then
|
||||||
|
if [[ $2 == "" ]]; then
|
||||||
|
echo "No group presented"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $3 == "" ]]; then
|
||||||
|
echo "No devices presented"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"group\": \"$2\", \"devices\": [$3] }" "$ADDR/data/sensors/getMultiDeviceSensors" | jq
|
||||||
|
elif [[ $1 == "device-params-v2" ]]; then
|
||||||
|
if [[ $2 == "" ]]; then
|
||||||
|
echo "No serial presented"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"serial\": \"$2\" }" "$ADDR/settings/deviceSettingsV2" | jq
|
||||||
|
elif [[ $1 == "connected-chart" ]]; then
|
||||||
|
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"start_time\": 1757850710, \"end_time\": 1757850410 }" "$ADDR/data/getConnectedDevicesChart" | jq
|
||||||
elif [[ $1 == "device-params" ]]; then
|
elif [[ $1 == "device-params" ]]; then
|
||||||
if [[ $2 == "" ]]; then
|
if [[ $2 == "" ]]; then
|
||||||
echo "No serial presented"
|
echo "No serial presented"
|
||||||
@@ -55,6 +100,19 @@ elif [[ $1 == "set-device-params" ]]; then
|
|||||||
|
|
||||||
echo "Settings device params for $SERIAL"
|
echo "Settings device params for $SERIAL"
|
||||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/settings/deviceSettings" --data-binary @"$2"
|
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/settings/deviceSettings" --data-binary @"$2"
|
||||||
|
elif [[ $1 == "set-device-params-v2" ]]; then
|
||||||
|
if [[ $2 == "" ]]; then
|
||||||
|
echo "No params file presenter"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
SERIAL=$(cat $2 | jq ".serial")
|
||||||
|
if [[ $SERIAL == "" ]]; then
|
||||||
|
echo "File does not contain serial"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Settings device params for $SERIAL"
|
||||||
|
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/settings/deviceSettingsV2" --data-binary @"$2"
|
||||||
elif [[ $1 == "set-ips" ]]; then
|
elif [[ $1 == "set-ips" ]]; then
|
||||||
if [[ $2 == "" ]]; then
|
if [[ $2 == "" ]]; then
|
||||||
echo "No serial provided"
|
echo "No serial provided"
|
||||||
|
|||||||
Reference in New Issue
Block a user