Created
July 11, 2019 16:00
-
-
Save matthewpoer/a12feb6393f594cb7f7da585c9370458 to your computer and use it in GitHub Desktop.
Acknowledge (Clear) all Heroku Connect notifications for a given Connection
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 | |
CONNECTION_ID="" # grab from URL for a given HC Connection | |
TOKEN="" # grab from web requests within Heroku Connect | |
page=1 | |
keepGoing=1 | |
while [ $keepGoing -gt 0 ] | |
do | |
notice_url="https://connect-us.heroku.com/api/v3/connections/${CONNECTION_ID}/notifications?page=${page}" | |
echo ${notice_url} | |
notifications=$(curl -s "${notice_url}" -H "Authorization: Bearer ${TOKEN}") | |
list_ids=`echo ${notifications} | jq .results[].id` | |
count=`echo ${notifications} | jq .count` | |
echo "will clear ${count} notifications" | |
while read -r id; do | |
cleanId="${id%\"}" | |
cleanId="${cleanId#\"}" | |
ackUrl="https://connect-us.heroku.com/api/v3/notifications/${cleanId}/actions/acknowledge" | |
clearedResult=$(curl -s "${ackUrl}" -X POST -H "Authorization: Bearer ${TOKEN}") | |
done <<< "$list_ids" | |
echo " -- cleared" | |
next_page=`echo ${notifications} | jq .next` | |
echo "next page url: ${next_page}" | |
if [ $next_page == null ]; then | |
keepGoing=0 | |
else | |
page=$[$page+1] | |
keepGoing=1 | |
fi | |
done | |
echo "done" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment