feat: Gotify CRUD + internal handler dispatch for notification service
CI / CI (pull_request) Successful in 3m11s
CI / CI (pull_request) Successful in 3m11s
- Add internal handler support to ServiceAdapter (Handler field) - Dispatcher routes to internal handler when set (no reverse proxy) - GotifyClient: full CRUD (send/list/delete messages, CRUD applications) - Refactor notification handler: route by X-Resource header, not body format - Register notification as ServiceAdapter with auth required - Resources: send-email, send-message, list-messages, delete-message, delete-all-messages, list-applications, create-application, delete-application - Update examples: sendmsg-email.sh, gotify-crud.sh - Env vars: GOTIFY_URL, GOTIFY_APP_TOKEN, GOTIFY_CLIENT_TOKEN
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/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 .
|
||||
Reference in New Issue
Block a user