# 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"
_info "Adding TXT record"
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"add\":true,\"set\":{\"name\":\"${_sub_domain}\",\"ttl\":120,\"roundRobin\":[{\"value\":\"${txtvalue}\"}]}}]";then
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
# Usage: fulldomain txtvalue
@ -61,6 +86,13 @@ dns_constellix_rm() {
return1
return1
fi
fi
# 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
_info "Removing TXT record"
_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
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"delete\":true,\"filter\":{\"field\":\"name\",\"op\":\"eq\",\"value\":\"${_sub_domain}\"}}]";then