diff options
author | tv <tv@krebsco.de> | 2015-05-20 19:47:54 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2015-05-20 19:47:54 +0200 |
commit | f104b3711309770f06a881248cb71fd625827dc6 (patch) | |
tree | 6df119e2660ed5a9ca5588f6b0057df696e3c776 /lib/cac.sh | |
parent | 8b9b6f2a051a7b6695491a6f17d58203f823bdc9 (diff) |
lib/cac.sh: add _cac_get_api_v1
Diffstat (limited to 'lib/cac.sh')
-rw-r--r-- | lib/cac.sh | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -1,3 +1,5 @@ +. ./lib/url.sh + _cac_exec() { if test -z "${cac_via-}"; then (exec "$@") @@ -6,20 +8,21 @@ _cac_exec() { fi } +_cac_get_api_v1() { + _cac_exec curl -fsS \ + $(shift + set -- "$@" login="$cac_login" key="$cac_key" + for arg; do + echo -d $(printf '%s' "$arg" | url_encode) + done + ) \ + -G "https://panel.cloudatcost.com/api/v1/$1.php" +} + cac_listservers() { - _cac_exec \ - curl -fsS \ - -G \ - --data-urlencode key="$cac_key" \ - --data-urlencode login="$cac_login" \ - 'https://panel.cloudatcost.com/api/v1/listservers.php' + _cac_get_api_v1 listservers } cac_listtasks() { - _cac_exec \ - curl -fsS \ - -G \ - --data-urlencode key="$cac_key" \ - --data-urlencode login="$cac_login" \ - 'https://panel.cloudatcost.com/api/v1/listtasks.php' + _cac_get_api_v1 listtasks } |