Compare commits

...

3 Commits

Author SHA1 Message Date
Andrey Egorov
3450a97a03 chore: argus and groups requests 2025-10-11 09:58:14 +03:00
Andrey Egorov
5db3aefb79 chore: geo 2025-10-09 00:13:33 +03:00
Andrey Egorov
4b9f23adf1 chore: better login 2025-10-07 17:44:56 +03:00

60
req.sh
View File

@@ -8,6 +8,7 @@ PASSWORD=admin
#PASSWORD=ra8KvcMxS2baUxe*
#MASTER_CODE=685658
MASTER_CODE=111111
MFA_OFF="YES"
#set -x
@@ -17,16 +18,18 @@ H="-H \"Authorization: Bearer $(cat tmp.token)\""
if [[ $1 == "login" ]]; then
# Login
RESP=$(curl -X POST -H "Content-Type: application/json" -d "{ \"login\": \"$LOGIN\", \"password\": \"$PASSWORD\" }" "$ADDR/auth/signin")
# if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
# echo "Failed to login"
# echo $RESP | jq '.error'
# exit 1
# fi
#
# # 2FA
# RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
if [ "$MFA_OFF" != "YES" ]; then
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
echo "Failed to login1"
echo $RESP | jq '.error'
exit 1
fi
# 2FA
RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
fi
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
echo "Failed to login"
echo "Failed to login2"
echo $RESP | jq '.error'
exit 1
fi
@@ -49,7 +52,7 @@ 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 "\""
elif [[ $1 == "export-backup" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d '{ "startTime": 1758880189, "endTime": 1753024741 }' \
-d "{ \"startTime\": $(($(date +%s)-20000)), \"endTime\": $(date +%s) }" \
"$ADDR/data/backup/export" --output export.zip
elif [[ $1 == "export-logs" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
@@ -64,11 +67,40 @@ elif [[ $1 == "alarms-amount" ]]; then
"$ADDR/data/alarms/getAlarmsAmount" | jq
elif [[ $1 == "alarms" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d '{ "devices": ["A56AF66F17D902B8"], "start_time": 1757890398, "end_time": 1757892398, "page_number": 1, "page_size": 30}' \
-d "{ \"devices\": [\"A56AF66F17D902B8\"], \"start_time\": $(($(date +%s)-5000)), \"end_time\": $(date +%s), \"order\": [[\"sensor_id\", \"+\"]], \"page_number\": 1, \"page_size\": 30}" \
"$ADDR/data/alarms/getAlarms" | jq
elif [[ $1 == "geo" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"requests\": [ { \"type\": 2, \"mark\": \"$2\" } ] }" \
"$ADDR/data/geo/getSerial" | jq
elif [[ $1 == "argus" ]]; then
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
"$ADDR/settings/argusServerAddr?device=A56AF66F17D902B8" | jq
elif [[ $1 == "argus1" ]]; then
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"device\": \"A56AF66F17D902B8\", \"addr\": \"test-addr1\" }" \
"$ADDR/settings/argusServerAddr" | jq
elif [[ $1 == "argus2" ]]; then
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
"$ADDR/settings/argusSerial?device=A56AF66F17D902B8" | jq
elif [[ $1 == "argus3" ]]; then
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"device\": \"A56AF66F17D902B8\", \"argusSerial\": \"argus-test-erial\" }" \
"$ADDR/settings/argusSerial" | jq
elif [[ $1 == "device-group" ]]; then
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
"$ADDR/settings/deviceGroup?device=A56AF66F17D902B8" | jq
elif [[ $1 == "device-group1" ]]; then
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"device\": \"A56AF66F17D902B8\", \"group\": 4 }" \
"$ADDR/settings/deviceGroup" | jq
elif [[ $1 == "transport-group-create" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"name\": \"test-group-1\" }" \
"$ADDR/transport/createGroup" | jq
elif [[ $1 == "sensor-data" ]]; then
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"device\": \"A56AF66F17D902B8\", \"sensor\": \"TEMPERATURE/85\", \"start\": $(($(date +%s)-1000)), \"end\": $(date +%s), \"skip\": 1 }" \
-d "{ \"device\": \"2025082700003820\", \"sensor\": \"TEMPERATURE/PIIZI_TEMPERATURE_1\", \"start\": $(($(date +%s)-5000)), \"end\": $(date +%s), \"skip\": 1 }" \
"$ADDR/data/sensors/getDeviceSensorData" | jq
elif [[ $1 == "factory-models" ]]; then
if [[ $2 == "" ]]; then
@@ -111,7 +143,9 @@ elif [[ $1 == "device-params" ]]; 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/deviceSettings" | jq
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
-d "{ \"serial\": \"$2\" }" \
"$ADDR/settings/deviceSettings" | jq
elif [[ $1 == "set-device-params" ]]; then
if [[ $2 == "" ]]; then
echo "No params file presenter"