removed zone verification
zone verification not needed, instead check for 404 response on del api call
This commit is contained in:
parent
9e6deb7a2a
commit
c1be3a004e
|
@ -56,25 +56,15 @@ if [[ -z $type ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# first query to see if zone already exists
|
data="{\"rrsets\":[{\"name\":\"$name\",\"type\":\"$type\",\"changetype\":\"DELETE\",\"records\":[]}]}"
|
||||||
zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone?rrsets=false")
|
|
||||||
|
|
||||||
if [[ $zone_status = 200 ]]; then
|
# delete record(s)
|
||||||
# verified zone exists, delete record
|
zone_status=$(/usr/bin/curl --silent --request PATCH --output /dev/null --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone")
|
||||||
|
|
||||||
data="{\"rrsets\":[{\"name\":\"$name\",\"type\":\"$type\",\"changetype\":\"DELETE\",\"records\":[]}]}"
|
if [[ $zone_status = 204 ]]; then
|
||||||
|
|
||||||
# delete record(s)
|
|
||||||
zone_status=$(/usr/bin/curl --silent --request PATCH --output /dev/null --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone")
|
|
||||||
|
|
||||||
if [[ $zone_status = 204 ]]; then
|
|
||||||
echo "Success. Record(s) for $zone deleted."
|
echo "Success. Record(s) for $zone deleted."
|
||||||
else
|
|
||||||
echo "Error. http response deleting record(s) for $zone was: $zone_status"
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ $zone_status = 404 ]]; then
|
elif [[ $zone_status = 404 ]]; then
|
||||||
echo "Zone $zone does not exist, can't delete record."
|
echo "Zone $zone does not exist, can't delete record."
|
||||||
else
|
else
|
||||||
echo "Unexpected http response checking for Zone $zone: $zone_status"
|
echo "Error. http response deleting record(s) for $zone was: $zone_status"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user