Last active
April 16, 2024 00:37
-
-
Save DinoChiesa/d9b3714f983e99aa8e3d0c6f27ba2aec to your computer and use it in GitHub Desktop.
Fetch an API Proxy from Apigee X or hybrid, and unzip the bundle in the local filesystem
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
#!/bin/bash | |
# -*- mode:shell-script; coding:utf-8; -*- | |
# | |
# Works with Apigee X/hybrid. | |
# | |
proxyname="$1" | |
[[ -z "$proxyname" ]] && printf "specify a proxy name as argument\n" && exit 1 | |
MISSING_ENV_VARS=() | |
[[ -z "$APIGEE_TOKEN" ]] && MISSING_ENV_VARS+=('APIGEE_TOKEN') | |
[[ -z "$APIGEE_PROJECT" ]] && MISSING_ENV_VARS+=('APIGEE_PROJECT') | |
[[ ${#MISSING_ENV_VARS[@]} -ne 0 ]] && { | |
printf -v joined '%s,' "${MISSING_ENV_VARS[@]}" | |
printf "You must set these environment variables: %s\n" "${joined%,}" | |
exit 1 | |
} | |
cliout=($(apigeecli apis fetch -n "$proxyname" --token "$APIGEE_TOKEN" --org "$APIGEE_PROJECT")) | |
zipname=${cliout[1]} | |
pair=(${zipname//./ }) | |
shortpname=${pair[0]} | |
outdir=${shortpname}-unzipped | |
rm -fr $outdir | |
unzip ${zipname} -d ${outdir} >/dev/null 2>&1 | |
rm "${zipname}" | |
echo "directory: $outdir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment