GoDaddy 使用 Bash/Shell 脚本通过 API 删除单个 DNS 记录

GoDaddy Deleting a single DNS record through the API using Bash/Shell script

我想通过 CURL 或任何其他 Shell/Bash 命令通过 API 删除单个 DNS 记录(A 记录)。

我也尝试访问 GoDaddy 的网站,但不幸的是它不再存在并且 returns 404。

https://www.godaddy.com/community/Managing-Domains/Deleting-a-single-DNS-record-through-the-API/td-p/108003

可以吗,我该怎么做?

编辑原来的答案好像过时了

GoDaddy 已添加相应的 endpoint 以删除单个条目。所以现在你可以做

DELETE /v1/domains/{domain}/records/A/{name}

原回答

不幸的是,godaddy 的 api 不提供在单个调用中删除单个域记录的端点。所以你必须

  1. GET /v1/domains/{domain}/records/A 首先获取域的所有 A-records (https://developer.godaddy.com/doc/endpoint/domains#/v1/recordGet)
  2. 从结果列表中删除要删除的记录
  3. PUT /v1/domains/{domain}/records/A 修改后的记录集,用给定的记录列表 (https://developer.godaddy.com/doc/endpoint/domains#/)
  4. 替换域的所有 A-records

作为 API 端点 return/expect JSON 数据,您可能需要一些额外的工具来操作 json 数据。您可能会在这个答案中找到一些东西 Parsing JSON with Unix tools

您可能会想使用 PUT /v1/domains/{domain}/records/A/{recordname} 将所有具有给定名称的 A-records 替换为提供的记录列表 (https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceTypeName),使用正文中的空记录列表.我上次试过,没用。