Last active
August 29, 2015 14:04
-
-
Save mrwilson/d189acdcd15d5080605c to your computer and use it in GitHub Desktop.
get_digital_ocean_codes.sh
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
# regions | |
do_regions_sfo1: 3 | |
do_regions_nyc2: 4 | |
do_regions_ams2: 5 | |
do_regions_sgp1: 6 | |
do_regions_lon1: 7 | |
# sizes | |
do_sizes_32gb: 60 | |
do_sizes_16gb: 61 | |
do_sizes_2gb: 62 | |
do_sizes_1gb: 63 | |
do_sizes_4gb: 64 | |
do_sizes_8gb: 65 | |
do_sizes_512mb: 66 | |
do_sizes_64gb: 69 | |
do_sizes_48gb: 70 | |
# images | |
do_images_centos-5-8-x64: 1601 | |
do_images_centos-5-8-x32: 1602 | |
do_images_debian-6-0-x64: 12573 | |
do_images_debian-6-0-x32: 12575 | |
do_images_ubuntu-10-04-x64: 14097 | |
do_images_ubuntu-10-04-x32: 14098 | |
do_images_centos-6-4-x32: 376568 | |
do_images_centos-6-4-x64: 562354 | |
do_images_ubuntu-12-04-x32: 3100616 | |
do_images_ubuntu-12-04-x64: 3101045 | |
do_images_fedora-19-x32: 3102721 | |
do_images_fedora-19-x64: 3102879 | |
do_images_ghost: 3121555 | |
do_images_fedora-20-x32: 3243143 | |
do_images_fedora-20-x64: 3243145 | |
do_images_debian-7-0-x64: 3445812 | |
do_images_debian-7-0-x32: 3445920 | |
do_images_centos-6-5-x64: 3448641 | |
do_images_centos-6-5-x32: 3448674 | |
do_images_django: 3935257 | |
do_images_lamp: 3961756 | |
do_images_mean: 4204318 | |
do_images_ruby-on-rails: 4261622 | |
do_images_node: 4295378 | |
do_images_lemp: 4547332 | |
do_images_gitlab: 4582138 | |
do_images_centos-7-0-x64: 4856048 | |
do_images_docker: 4970653 | |
do_images_dokku: 5099646 | |
do_images_ubuntu-14-04-x64: 5141286 | |
do_images_ubuntu-14-04-x32: 5142677 |
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/sh | |
# Usage: | |
# ./get_digital_ocean_codes.sh <client_id> <api_key> | |
# | |
# Requires: | |
# jq | |
URL=https://api.digitalocean.com/v1 | |
CLIENT_ID=$1 | |
API_KEY=$2 | |
OUTPUT=do_codes.yml | |
> ${OUTPUT} | |
for q in regions sizes images; do | |
echo -n "Calculating ${q} ... " | |
echo "# ${q}" >> ${OUTPUT} | |
curl -X GET --silent "${URL}/${q}?client_id=${CLIENT_ID}&api_key=${API_KEY}" | \ | |
jq ".${q}[] | \"do_${q}_\(.slug): \(.id)\"" | \ | |
sed -e 's/\"//g' | \ | |
sed -e '/null/d' >> ${OUTPUT} | |
echo >> ${OUTPUT} | |
echo "done" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This creates the error when parsing a YAML file:
Unable to look up a name or access an attribute in template string. Make sure your variable name does not contain invalid characters like '-'.
Perhaps the images codes should turn
-
into_
?