本作品采用知识共享署名 3.0 非移植许可协议授权。 http://creativecommons.org/licenses/by/3.0/legalcode

暴露记录集端点

https://blueprints.launchpad.net/designate/+spec/expose-recordsets-api

问题描述

目前,/recordsets 端点是 /zones 的子资源。但存在一种需求,即能够通过单个 API 调用列出租户的所有记录,以便更容易地对租户下的所有记录进行过滤。

提议的变更

Designate 将拥有一个新的 API 端点 /v2/recordsets

  • 可以通过向 /v2/recordsets/{recordset_id} 发送 GET 请求来检索单个记录集,该请求会返回 301 并重定向到规范位置 /v2/zones/{zone_id}/recordsets/{recordset_id}。响应体中的“self”链接也指向该位置。

  • 可以通过向 /v2/recordsets 发送 GET 请求来列出属于租户的所有区域中的所有记录集,在这种情况下,如果需要,响应将被分页。

  • 将支持对租户下的所有记录集进行过滤,例如 /v2/recordsets?name=foo

API 变更

API 更改主要在于在控制器中暴露新的 API 端点。

示例单个记录集检索请求

GET /v2/recordsets/f7b10e9b-0cae-4a91-b162-562bc6096648 HTTP/1.1
Host: 127.0.0.1:9001
Accept: application/json
Content-Type: application/json

{
  "description": "This is an example recordset.",
  "links": {
      "self": "https://127.0.0.1:9001/v2/zones/2150b1bf-dee2-4221-9d85-11f7886fb15f/recordsets/f7b10e9b-0cae-4a91-b162-562bc6096648"
  },
  "updated_at": null,
  "records": [
      "10.1.0.2"
  ],
  "ttl": 3600,
  "id": "f7b10e9b-0cae-4a91-b162-562bc6096648",
  "name": "www.example.org.",
  "zone_id": "2150b1bf-dee2-4221-9d85-11f7886fb15f",
  "zone_name": "example.org.",
  "created_at": "2014-10-24T19:59:44.000000",
  "version": 1,
  "type": "A"
}

示例租户所有记录集检索请求

GET /v2/recordsets HTTP/1.1
Host: 127.0.0.1:9001
Accept: application/json
Content-Type: application/json

{
  "recordsets": [
      {
          "description": null,
          "links": {
              "self": "https://127.0.0.1:9001/v2/zones/2150b1bf-dee2-4221-9d85-11f7886fb15f/recordsets/65ee6b49-bb4c-4e52-9799-31330c94161f"
          },
          "updated_at": null,
          "records": [
              "ns1.devstack.org."
          ],
          "action": "NONE",
          "ttl": null,
          "status": "ACTIVE",
          "id": "65ee6b49-bb4c-4e52-9799-31330c94161f",
          "name": "example.org.",
          "zone_id": "2150b1bf-dee2-4221-9d85-11f7886fb15f",
          "zone_name": "example.org.",
          "created_at": "2014-10-24T19:59:11.000000",
          "version": 1,
          "type": "NS"
      },
      {
          "description": null,
          "links": {
              "self": "https://127.0.0.1:9001/v2/zones/2150b1bf-dee2-4221-9d85-11f7886fb15f/recordsets/14500cf9-bdff-48f6-b06b-5fc7491ffd9e"
          },
          "updated_at": "2014-10-24T19:59:46.000000",
          "records": [
              "ns1.devstack.org. jli.ex.com. 1458666091 3502 600 86400 3600"
          ],
          "action": "NONE",
          "ttl": null,
          "status": "ACTIVE",
          "id": "14500cf9-bdff-48f6-b06b-5fc7491ffd9e",
          "name": "example.org.",
          "zone_id": "2150b1bf-dee2-4221-9d85-11f7886fb15f",
          "zone_name": "example.org.",
          "created_at": "2014-10-24T19:59:12.000000",
          "version": 1,
          "type": "SOA"
      },
      {
          "name": "jjli.com.",
          "id": "12caacfd-f0fc-4bcb-aa24-c42769897822",
          "type": "SOA",
          "zone_name": "jjli.com.",
          "action": "NONE",
          "ttl": null,
          "status": "ACTIVE",
          "description": null,
          "links": {
              "self": "http://127.0.0.1:9001/v2/zones/b8d7eaf1-e5c7-4b15-be6e-4b2809f47ec3/recordsets/12caacfd-f0fc-4bcb-aa24-c42769897822"
          },
          "created_at": "2016-03-22T16:12:35.000000",
          "updated_at": "2016-03-22T17:01:31.000000",
          "records": [
              "ns1.devstack.org. jli.ex.com. 1458666091 3502 600 86400 3600"
          ],
          "zone_id": "b8d7eaf1-e5c7-4b15-be6e-4b2809f47ec3",
          "version": 2
      },
      {
          "name": "jjli.com.",
          "id": "f39c51d1-ec2c-48a8-b9f7-877d56b7b82a",
          "type": "NS",
          "zone_name": "jjli.com.",
          "action": "NONE",
          "ttl": null,
          "status": "ACTIVE",
          "description": null,
          "links": {
              "self": "http://127.0.0.1:9001/v2/zones/b8d7eaf1-e5c7-4b15-be6e-4b2809f47ec3/recordsets/f39c51d1-ec2c-48a8-b9f7-877d56b7b82a"
          },
          "created_at": "2016-03-22T16:12:35.000000",
          "updated_at": null,
          "records": [
              "ns1.devstack.org."
          ],
          "zone_id": "b8d7eaf1-e5c7-4b15-be6e-4b2809f47ec3",
          "version": 1
       },
  ],
  "metadata": {
    "total_count": 4
  },
  "links": {
      "self": "https://127.0.0.1:9001/v2/recordsets"
  }
}

示例记录集过滤请求

GET /v2/recordsets?data=192.168* HTTP/1.1
Host: 127.0.0.1:9001
Accept: application/json
Content-Type: application/json

{
  "metadata": {
    "total_count": 2
  },
  "links": {
    "self": "http://127.0.0.1:9001/v2/recordsets?data=192.168%2A"
  },
  "recordsets": [
    {
      "name": "ohoh.uyudbbgxdf.com.",
      "id": "a48588c5-5093-4585-b0fc-3e399d169c01",
      "type": "A",
      "zone_name": "uyudbbgxdf.com.",
      "action": "NONE",
      "ttl": null,
      "status": "ACTIVE",
      "description": null,
      "links": {
        "self": "http://127.0.0.1:9001/v2/zones/601a25f0-5c4d-4058-8d9c-e6a78f5ffbb8/recordsets/a48588c5-5093-4585-b0fc-3e399d169c01"
      },
      "created_at": "2016-04-04T20:11:08.000000",
      "updated_at": null,
      "records": [
        "192.168.0.1"
      ],
      "zone_id": "601a25f0-5c4d-4058-8d9c-e6a78f5ffbb8",
      "version": 1
    },
    {
      "name": "jli-1.uyudbbgxdf.com.",
      "id": "f2c7a0f6-8ec7-4d14-b8ec-2a55a8129160",
      "type": "A",
      "zone_name": "uyudbbgxdf.com.",
      "action": "NONE",
      "ttl": null,
      "status": "ACTIVE",
      "description": null,
      "links": {
        "self": "http://127.0.0.1:9001/v2/zones/601a25f0-5c4d-4058-8d9c-e6a78f5ffbb8/recordsets/f2c7a0f6-8ec7-4d14-b8ec-2a55a8129160"
      },
      "created_at": "2016-04-04T22:21:03.000000",
      "updated_at": null,
      "records": [
        "192.168.6.6"
      ],
      "zone_id": "601a25f0-5c4d-4058-8d9c-e6a78f5ffbb8",
      "version": 1
    }
  ]
}

Central 变更

中心更改包括更改 central.service 中从存储中查找记录集的功能,以支持来自 api 层的相应调用。

Storage 变更

相应的更改以支持 API 更改。

其他变更

替代方案

实现

负责人

里程碑

newton-1

工作项

  • 对 api、central 和 storage 进行代码更改

  • 添加单元和功能测试。

依赖项