Created
August 3, 2015 15:27
-
-
Save kelapure/8e80e10b06de3c2e0841 to your computer and use it in GitHub Desktop.
Pivotal Network API Download Example
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 | |
set -e | |
export PIVNET_TOKEN=GET_FROM_PIVNET_USER_PROFILE_PAGE | |
export LOCAL_FILE_NAME=pcf-mysql.pivotal | |
export DOWNLOAD_URL=https://network.pivotal.io/api/v2/products/p-mysql/releases/211/product_files/1755/download | |
export OPSMGR_HOST=localhost | |
export OPSMGR_USER=WHATEVER_YOUR_OPSMGR_USER_IS | |
export OPSMGR_PASSWORD=WHATEVER_YOUR_OPSMGR_PASSWORD_IS | |
echo "Attempting download of $LOCAL_FILE_NAME from $DOWNLOAD_URL" | |
wget -O "$LOCAL_FILE_NAME" --post-data="" --header="Authorization: Token $PIVNET_TOKEN" $DOWNLOAD_URL | |
echo "Attempting to upload of $LOCAL_FILE_NAME to $OPSMGR_HOST" | |
curl "https://${OPSMGR_HOST}/api/products" -F "product[file]=@${LOCAL_FILE_NAME}" -X POST -u ${OPSMGR_USER}:${OPSMGR_PASSWORD} -k | |
echo "$LOCAL_FILE_NAME finished uploading to Ops Manager" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kelapure Great stuff 👍 Please correct this
Authorization: Token
toAuthorization: Bearer