if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"add\":true,\"set\":{\"name\":\"${_sub_domain}\",\"ttl\":120,\"roundRobin\":[{\"value\":\"${txtvalue}\"}]}}]";then
# The TXT record might already exist when working with wildcard certificates. In that case, update the record by adding the new value.
_debug "Search TXT record"
if _constellix_rest GET "domains/${_domain_id}/records/TXT/search?exact=${_sub_domain}";then
ifprintf -- "%s""$response"| grep "{\"errors\":\[\"Requested record was not found\"\]}" >/dev/null;then
_info "Adding TXT record"
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"add\":true,\"set\":{\"name\":\"${_sub_domain}\",\"ttl\":60,\"roundRobin\":[{\"value\":\"${txtvalue}\"}]}}]";then
elifprintf -- "%s""$response"| grep "{\"errors\":\[\"Contents are identical\"\]}" >/dev/null;then
_info "Already exists, no need to update"
return0
else
_err "Error updating TXT record"
fi
fi
fi
fi
fi
return1
}
# Usage: fulldomain txtvalue
@ -61,16 +86,26 @@ dns_constellix_rm() {
return1
fi
_info "Removing TXT record"
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"delete\":true,\"filter\":{\"field\":\"name\",\"op\":\"eq\",\"value\":\"${_sub_domain}\"}}]";then
# The TXT record might have been removed already when working with some wildcard certificates.
_debug "Search TXT record"
if _constellix_rest GET "domains/${_domain_id}/records/TXT/search?exact=${_sub_domain}";then
ifprintf -- "%s""$response"| grep "{\"errors\":\[\"Requested record was not found\"\]}" >/dev/null;then
_info "Removed"
return0
else
_err "Error removing TXT record"
return1
_info "Removing TXT record"
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"delete\":true,\"filter\":{\"field\":\"name\",\"op\":\"eq\",\"value\":\"${_sub_domain}\"}}]";then