Files
homelab-frontend/examples/gotify-crud.sh
T

63 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
# Example: Gotify CRUD operations via notification service (X-Service routing)
BASE_URL="${1:-https://api.riotpiao.com}"
AUTH_TOKEN="${2:-}"
AUTH="-H \"Authorization: Bearer $AUTH_TOKEN\""
echo "=== Send Gotify Message ==="
curl -s -X POST "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: send-message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{
"title": "Deployment Complete",
"message": "homelab-frontend v1.2.0 deployed to production",
"priority": 5
}' | jq .
echo ""
echo "=== List Messages ==="
curl -s -X GET "$BASE_URL?limit=10" \
-H "X-Service: notification" \
-H "X-Resource: list-messages" \
-H "Authorization: Bearer $AUTH_TOKEN" | jq .
echo ""
echo "=== List Applications ==="
curl -s -X GET "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: list-applications" \
-H "Authorization: Bearer $AUTH_TOKEN" | jq .
echo ""
echo "=== Create Application ==="
curl -s -X POST "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: create-application" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{
"name": "my-monitor",
"description": "Monitoring alerts"
}' | jq .
echo ""
echo "=== Delete Message (by ID) ==="
curl -s -X DELETE "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: delete-message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{"id": 1}' | jq .
echo ""
echo "=== Delete Application (by ID) ==="
curl -s -X DELETE "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: delete-application" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{"id": 1}' | jq .