Browse Source
Support account id configuration for dnsimple
pull/3578/head
vin01
4 years ago
No known key found for this signature in database
GPG Key ID: 885C28C3B043329D
1 changed files with
16 additions and
11 deletions
-
dnsapi/dns_dnsimple.sh
|
|
|
@ -123,21 +123,26 @@ _get_root() { |
|
|
|
# returns _account_id |
|
|
|
_get_account_id() { |
|
|
|
_debug "retrive account id" |
|
|
|
if ! _dnsimple_rest GET "whoami"; then |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if _contains "$response" "\"account\":null"; then |
|
|
|
_err "no account associated with this token" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
if [ -n "$DNSimple_ACCOUNT_ID" ]; then |
|
|
|
_account_id="$DNSimple_ACCOUNT_ID" |
|
|
|
else |
|
|
|
if ! _dnsimple_rest GET "whoami"; then |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if _contains "$response" "timeout"; then |
|
|
|
_err "timeout retrieving account id" |
|
|
|
return 1 |
|
|
|
if _contains "$response" "\"account\":null"; then |
|
|
|
_err "no account associated with this token" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if _contains "$response" "timeout"; then |
|
|
|
_err "timeout retrieving account id" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
_account_id=$(printf "%s" "$response" | _egrep_o "\"id\":[^,]*,\"email\":" | cut -d: -f2 | cut -d, -f1) |
|
|
|
fi |
|
|
|
|
|
|
|
_account_id=$(printf "%s" "$response" | _egrep_o "\"id\":[^,]*,\"email\":" | cut -d: -f2 | cut -d, -f1) |
|
|
|
_debug _account_id "$_account_id" |
|
|
|
|
|
|
|
return 0 |
|
|
|
|