lib/cac.sh: add _cac_get_api_v1
This commit is contained in:
parent
c75cc77194
commit
a3f87cec68
27
lib/cac.sh
27
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user