Skip to content

Instantly share code, notes, and snippets.

@phact
Created August 4, 2020 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phact/302f9a542b027cd0770bb50131011be0 to your computer and use it in GitHub Desktop.
Save phact/302f9a542b027cd0770bb50131011be0 to your computer and use it in GitHub Desktop.
#!/bin/bash
CLIENT_NAME=
CLIENT_SECRET=
CLIENT_ID=
DB_ID=
TOKEN=$(curl --request POST \
  --url https://api.astra.datastax.com/v2/authenticateServiceAccount \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data "{\"clientName\":\"$CLIENT_NAME\",\"clientSecret\":\"$CLIENT_SECRET\",\"clientId\":\"$CLIENT_ID\"}" | jq -r ".token")
if  [ ! -z "$TOKEN" ]; then
    INTERNAL=$(curl --request POST \
      --url https://api.astra.datastax.com/v2/databases/$DB_ID/secureBundleURL \
      --header 'accept: application/json' \
      --header "authorization: Bearer $TOKEN" | jq -r '.downloadURLInternal')
    EXTERNAL=$(curl --request POST \
      --url https://api.astra.datastax.com/v2/databases/$DB_ID/secureBundleURL \
      --header 'accept: application/json' \
      --header "authorization: Bearer $TOKEN" | jq -r '.downloadURL')
 
    echo $INTERNAL
    echo $EXTERNAL
      curl -L --output internal.zip --url $INTERNAL
      curl -L --output external.zip --url $EXTERNAL
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment