Browse Source

Add POST request support to API client

pull/1/head
Luke Childs 5 years ago
parent
commit
e4bb70835a
  1. 20
      checkvolumesize

20
checkvolumesize

@ -70,9 +70,25 @@ log "BUFFER = ${BUFFER}"
log
digital_ocean_api () {
api="https://api.digitalocean.com/v2"
endpoint=$1
curl --silent -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "${api}/${endpoint}"
post_data=$2
method="GET"
if [[ $post_data ]]; then
method="POST"
fi
args=()
args+=("--silent")
args+=("-X" $method)
args+=("-H" "Content-Type: application/json")
args+=("-H" "Authorization: Bearer ${TOKEN}")
if [[ $post_data ]]; then
args+=("-d" $post_data)
fi
args+=("https://api.digitalocean.com/v2/${endpoint}")
curl "${args[@]}"
}
main () {

Loading…
Cancel
Save