Skip to content

Instantly share code, notes, and snippets.

@mvxt
Last active April 29, 2022 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvxt/37d92e83f2aab265dcb23b486c705a06 to your computer and use it in GitHub Desktop.
Save mvxt/37d92e83f2aab265dcb23b486c705a06 to your computer and use it in GitHub Desktop.
Example scripts for purging parts of FireHydrant's Service Catalog

Purge FireHydrant Services

This script shows an example of tapping the FireHydrant API to fetch the UUIDs of all services in the catalog and then making additional API calls to delete them.

This was tested on macOS Monterey v12.3.1 on a 2021 14" MacBook Pro with an M1 Pro chip. Since it's UNIX, there may be some incompatibilies with the curl and jq commands on other operating systems like Linux or Windows. Beware!!

#!/bin/bash
functionality_ids=( $(curl --request GET --url https://api.firehydrant.io/v1/functionalities --header 'Authorization: REPLACE_BOT_TOKEN_HERE' --header 'Content-Type: application/json' | jq -r '.data | .[] | .id') )
for id in "${functionality_ids[@]}"; do
echo "Deleting service with ID $id"
curl --request DELETE \
--url https://api.firehydrant.io/v1/functionalities/"$id" \
--header 'Authorization: REPLACE_BOT_TOKEN_HERE' \
--header 'Content-Type: application/json'
echo "...done"
done
#!/bin/bash
service_ids=( $(curl --request GET --url https://api.firehydrant.io/v1/services --header 'Authorization: REPLACE_BOT_TOKEN_HERE' --header 'Content-Type: application/json' | jq -r '.data | .[] | .id') )
for id in "${service_ids[@]}"; do
echo "Deleting service with ID $id"
curl --request DELETE \
--url https://api.firehydrant.io/v1/services/"$id" \
--header 'Authorization: REPLACE_BOT_TOKEN_HERE' \
--header 'Content-Type: application/json'
echo "...done"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment