Last active
April 4, 2023 23:03
-
-
Save foospidy/c93149f206c3bd25a7be8a13152a625c to your computer and use it in GitHub Desktop.
Update/replace integration configuration in Signal Sciences
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################### | |
# Signal Sciences helper script: | |
# sigsci-integration-replace.sh | |
# For a given configuration, the script will delete all instances based on type and url, | |
# it will then recreate the configuration with the specified events. | |
# Requires: | |
# - pysigsci (https://pypi.org/project/pysigsci/) | |
# - jq (https://stedolan.github.io/jq/) | |
# Edit these varables to specify your config. | |
INTEGRATION_TYPE="slack" | |
INTEGRATION_URL="https://example.slack.com/webhook_url" | |
INTEGRATION_EVENTS='"agentAlert", "flag"' | |
for identifier in `pysigsci --get integrations --all-sites | jq ".data[] | { type: .type, id: .id, url: .url } | select(.type == \"${INTEGRATION_TYPE}\") | select(.url == \"${INTEGRATION_URL}\") | .id"`; | |
do | |
id=`echo ${identifier} | tr '"' '\ '` | |
for site in `pysigsci --get corp-sites | jq ".data[] | .name"`; | |
do | |
site_name=`echo ${site} | tr '"' '\ '` | |
pysigsci --delete integration --site ${site_name} --id ${id} | grep "successful"; | |
done; | |
done; | |
pysigsci --add integration --all-sites --data "{\"url\": \"${INTEGRATION_URL}\", \"type\": \"${INTEGRATION_TYPE}\", \"events\": [${INTEGRATION_EVENTS}]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Teach me