diff options
author | tv <tv@shackspace.de> | 2015-05-20 19:47:54 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-05-20 19:47:54 +0200 |
commit | a3f87cec68f581b5495d8c6c0dc604b241a659b2 (patch) | |
tree | 6df119e2660ed5a9ca5588f6b0057df696e3c776 | |
parent | c75cc771944738248a3d4c158539cb308253a240 (diff) |
lib/cac.sh: add _cac_get_api_v1
-rw-r--r-- | lib/cac.sh | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/cac.sh b/lib/cac.sh index 48a711cd0..83f17635f 100644 --- a/lib/cac.sh +++ b/lib/cac.sh @@ -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 } |