umorpha-boxes/bin/vultr-api

19 lines
409 B
Plaintext
Raw Normal View History

2023-11-03 23:15:57 +00:00
#!/usr/bin/env bash
# Copyright (C) 2023 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
2023-11-09 08:20:55 +00:00
if out="$(curl \
2023-11-03 23:15:57 +00:00
--no-progress-meter \
2023-11-04 04:16:34 +00:00
--fail-with-body \
2023-11-03 23:15:57 +00:00
-H "Authorization: Bearer ${VULTR_API_KEY:-$(cat secrets/vultr-api-key.txt)}" \
-H "Content-Type: application/json" \
2023-11-09 08:20:55 +00:00
"https://api.vultr.com/v2/$@")"
then
2023-11-10 06:39:29 +00:00
if [[ -n "$out" ]]; then
printf '%s\n' "$out"
fi
2023-11-09 08:20:55 +00:00
else
jq <<<"$out" >&2
2023-11-10 06:39:29 +00:00
exit 1
2023-11-09 08:20:55 +00:00
fi