#!/usr/bin/env bash
# Generate region codes for all non-US Commercial Azure regions

regions=(
  "belgiumcentral:bc"
  "brazilsouth:bs"
  "brazilsoutheast:bse"
  "canadacentral:cc"
  "canadaeast:ce"
  "centralindia:ci"
  "chilecentral:chc"
  "eastasia:ea"
  "francecentral:fc"
  "francesouth:fs"
  "germanynorth:gn"
  "germanywestcentral:gwc"
  "indonesiacentral:ic"
  "israelcentral:ilc"
  "italynorth:in"
  "japaneast:je"
  "japanwest:jw"
  "jioindiacentral:jic"
  "jioindiawest:jiw"
  "koreacentral:kc"
  "koreasouth:ks"
  "malaysiawest:mw"
  "mexicocentral:mc"
  "newzealandnorth:nzn"
  "northeurope:ne"
  "norwayeast:no"
  "norwaywest:nw"
  "polandcentral:pc"
  "qatarcentral:qc"
  "southafricanorth:san"
  "southafricawest:saw"
  "southeastasia:sea"
  "southindia:si"
  "spaincentral:sc"
  "swedencentral:swc"
  "switzerlandnorth:sn"
  "switzerlandwest:sw"
  "uaecentral:uac"
  "uaenorth:uan"
  "uksouth:uks"
  "ukwest:ukw"
  "westeurope:we"
  "westindia:wi"
)

echo "# Region code mapping for all non-US Commercial Azure regions"
echo "region_codes = {"
for region in "${regions[@]}"; do
  location="${region%%:*}"
  code="${region##*:}"
  printf "    %-25s = \"%s\"\n" "$location" "$code"
done
echo "  }"
