summaryrefslogtreecommitdiffstats
path: root/lib/cac.sh
blob: 83f17635fc0cc019d0895a1349e6503559d1b935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
. ./lib/url.sh

_cac_exec() {
  if test -z "${cac_via-}"; then
    (exec "$@")
  else
    ssh -q "$cac_via" -t "$@"
  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_get_api_v1 listservers
}

cac_listtasks() {
  _cac_get_api_v1 listtasks
}