Last active
January 21, 2025 15:26
-
-
Save Integralist/1391150b69eebcaac98984627ba26b7d to your computer and use it in GitHub Desktop.
[xarg parallel processing] #xarg
This file contains 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
# update --cursor value to acquire all the relevant domain data (see batch-identify-domains.sh) | |
fastly domain-v1 list --fqdn=test-tf --cursor=<REDACTED> --limit=100 --json | jq -r .data[].id >> /tmp/delete-domains | |
# now delete all those items | |
cat /tmp/delete-domains | xargs -P "$(sysctl -n hw.ncpu)" -I % fastly domain-v1 delete --domain-id=% |
This file contains 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
#!/bin/bash | |
# Initial cursor value | |
cursor="<STARTING CURSOR>" | |
output_file="/tmp/delete-domains" | |
# Clear the output file before appending data | |
> "$output_file" | |
while true; do | |
# Run the command and capture the output | |
response=$(go run ./cmd/fastly/main.go domain-v1 list --fqdn=tf-test --limit=100 --json --cursor="$cursor") | |
# Extract IDs and append to the output file | |
echo "$response" | jq -r .data[].id >> "$output_file" | |
# Extract the next cursor value from the JSON response | |
next_cursor=$(echo "$response" | jq -r .meta.next_cursor) | |
# Check if there is no next cursor (end of pagination) | |
if [[ -z "$next_cursor" || "$next_cursor" == "null" ]]; then | |
echo "No more data to fetch. Exiting loop." | |
break | |
fi | |
# Update the cursor for the next iteration | |
cursor="$next_cursor" | |
echo "Fetched batch. Next cursor: $cursor" | |
done | |
echo "All data fetched and saved to $output_file." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment