Skip to content

Instantly share code, notes, and snippets.

@cjellick
Last active June 30, 2017 21:55
Show Gist options
  • Save cjellick/cf2646316cf895d06e29298b2571f720 to your computer and use it in GitHub Desktop.
Save cjellick/cf2646316cf895d06e29298b2571f720 to your computer and use it in GitHub Desktop.
webhook stuff
# CREATE
curl -i -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
http://192.168.2.8:8080/v1-webhooks/receivers?projectId=1a5 \
-X POST -d '{"name": "scale up 6 by 1", "driver": "scaleService", "scaleServiceConfig": {"action": "up", "amount": 1, "serviceId": "1s6"}}'
# CREATE WITH LOCAL AUTH ENABLE and passed as cookie
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' \
--cookie 'PL=rancher; CSRF=D2ACB843C3; token=<token>' http://138.197.29.231:8080/v1-webhooks/receivers?projectId=1a5 \
-X POST -d '{"name": "scale up 6 by 1", "driver": "scaleService", "scaleServiceConfig": {"action": "up", "amount": 1, "serviceId": "1s6"}}'
# LIST
curl -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
http://192.168.2.8:8080/v1-webhooks/receivers?projectId=1a5 | jq .
# GET (The $1 is the ID of the webhook)
curl -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
http://192.168.2.8:8080/v1-webhooks/receivers/$1?projectId=1a5 | jq .
# DELETE (REVOKE) (The $1 is the ID of the webhook)
curl -i -H 'Accept: application/json' \
-H 'Content-Type: application/json' -X DELETE\
http://192.168.2.8:8080/v1-webhooks/receivers/$1?projectId=1a5
# EXECUTE (invoke the webhook)
curl -i -H 'X-API-Project-Id: 1a5' -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
$1 \
-X POST
# The $1 in this one is the URL field returned as part of the webhook resource
docker run -d -p 8080:8080 -e DEFAULT_CATTLE_WEBHOOK_SERVICE_EXECUTE=true rancher/server:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment