Files
gauvainboiche 0d071d2843 Semaine 11
2026-07-11 21:38:00 +02:00

24 lines
694 B
Bash

#!/usr/bin/env bash
set -e
BASE="http://127.0.0.1:5000/api/equipments"
echo "=== GET liste ==="
curl -sf "$BASE" | python -m json.tool
echo "=== POST création ==="
NEW=$(curl -sf -X POST "$BASE" \
-H "Content-Type: application/json" \
-d '{"hostname":"bash-test","type":"switch","ip_address":"10.0.60.1","is_active":true}')
echo "$NEW" | python -m json.tool
ID=$(echo "$NEW" | python -c "import json,sys; print(json.load(sys.stdin)['id'])")
echo "=== GET #$ID ==="
curl -sf "$BASE/$ID" | python -m json.tool
echo "=== PATCH toggle #$ID ==="
curl -sf -X PATCH "$BASE/$ID/toggle" | python -m json.tool
echo "=== DELETE #$ID ==="
curl -sf -X DELETE "$BASE/$ID" -w "HTTP %{http_code}\n"