Semaine 11
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user