更新时间:2024-03-14 GMT+08:00

创建Record Set

功能介绍

创建单个Record Set。

URI

POST /v2/zones/{zone_id}/recordsets

参数说明请参见表1
表1 URI格式的参数说明

名称

是否必选

参数类型

说明

zone_id

String

所属zone ID。

公网Zone ID可以通过查询公网Zone列表获取。

内网Zone ID可以通过查询内网Zone列表获取。

请求

  • 参数说明
    表2 请求样例的参数说明

    名称

    是否必选

    参数类型

    说明

    name

    String

    域名,后缀需以zone name结束且为FQDN(即以“.”号结束的完整主机名)。

    域名格式不区分大小写,系统会将输入的大写字母统一转换为小写。

    description

    String

    可选配置,对域名的描述。

    长度不超过255个字符。

    默认值为空。

    type

    String

    Record Set的类型。

    取值范围:A、AAAA、MX、CNAME、TXT、NS(仅限公网Zone)、SRV、PTR(仅限内网Zone)、CAA(仅限公网Zone)。

    详细信息请参见解析记录类型

    ttl

    Integer

    解析记录在本地DNS服务器的缓存时间,以秒为单位。

    如果您的服务地址经常更换,建议TTL值设置相对小些,反之,建议设置相对大些。

    取值范围:

    • 公网解析:1~2147483647。
    • 内网解析:300~2147483647。

    默认值为300s。

    records

    Array of strings

    解析记录的值。不同类型解析记录对应的值的规则不同。

    如Type为AAAA类型,Value是域名对应的IPv6地址列表。

    tags

    Array of object

    资源标签。详细信息请参见表3

    默认值为空。

    表3 tags对象参数说明

    名称

    是否必选

    参数类型

    说明

    key

    String

    键。

    最大长度36个unicode字符。 key不能为空。不能包含“=”、“*”、“<”、“>”、“\”、“,”、“|”和“/”,且首尾字符不能为空格。

    value

    String

    值。

    每个值最大长度43个unicode字符,可以为空字符串。 不能包含“=”、“*”、“<”、“>”、“\”、“,”、“|”和“/”,且首尾字符不能为空格。

  • 请求样例
    为Zone ID为“2c9eb155587194ec01587224c9f90149”域名添加记录集。
    POST https://{DNS_Endpoint}/v2/zones/2c9eb155587194ec01587224c9f90149/recordsets
    • A类型
      {
          "name": "www.example.com.",
          "description": "This is an example record set.",
          "type": "A",
          "ttl": 3600,
          "records": [
              "192.168.10.1",
              "192.168.10.2"
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • AAAA类型
      {
          "name": "www.example.com.",
          "description": "This is an example record set.",
          "type": "AAAA",
          "ttl": 3600,
          "records": [
              "fe80:0:0:0:202:b3ff:fe1e:8329",
              "ff03:0db8:85a3:0:0:8a2e:0370:7334"
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • MX类型
      {
          "name": "www.example.com.",
          "description": "This is an example record set.",
          "type": "MX",
          "ttl": 3600,
          "records": [
              "1 mail.example.com"
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • CNAME类型
      {
          "name": "sale.example.com.",
          "description": "This is an example record set.",
          "type": "CNAME",
          "ttl": 3600,
          "records": [
              "server1.example.com"
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • TXT类型
      {
          "name": "server1.example.com.",
          "description": "This is an example record set.",
          "type": "TXT",
          "ttl": 300,
          "records": [
              "\"This host is used for sale.\""
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • NS类型
      {
          "name": "server1.example.com.",
          "description": "This is an example record set.",
          "type": "NS",
          "ttl": 300,
          "records": [
              "node1.example.com.",
              "node2.example.com."
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • SRV类型
      {
          "name": "_sip._tcp.example.com.",
          "description": "This is an example record set.",
          "type": "SRV",
          "ttl": 300,
          "records": [
              "3 60 2176 sipserver.example.com.",
              "10 100 2176 sipserver.example.com."
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
    • PTR类型
      {
          "name": "1.1.168.192.in-addr.arpa.",
          "description": "This is an example record set.",
          "type": "PTR",
          "ttl": 300,
          "records": [
              "webserver.example.com."
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }
      
    • CAA类型
      {
          "name": "www.example.com.",
          "description": "This is an example record set.",
          "type": "CAA",
          "ttl": 300,
          "records": [
              "0 issue \"example.com\"",
              "0 issuewild \"www.certinomis.com\"",
              "0 iodef \"mailto:xx@example.org\"",
              "0 iodef \"http://iodef.example.com\""
          ],
          "tags": [
              {
                "key": "key1",
                "value": "value1"
              }
          ]
      }

响应

  • 参数说明
    表4 响应样例的参数说明

    名称

    参数类型

    说明

    id

    String

    Record Set的ID。

    name

    String

    Record Set的名称。

    description

    String

    Record Set的描述信息。

    zone_id

    String

    托管该记录的zone_id。

    zone_name

    String

    托管该记录的zone_name。

    type

    String

    记录类型。

    取值范围:A、AAAA、MX、CNAME、TXT、NS(仅限公网Zone)、SRV、PTR(仅限内网Zone)、CAA(仅限公网Zone)。

    详细信息请参见解析记录类型

    ttl

    Integer

    解析记录在本地DNS服务器的缓存时间,缓存时间越长更新生效越慢,以秒为单位。

    如果您的服务地址经常更换,建议TTL值设置相对小些,反之,建议设置相对大些。

    取值范围:

    • 公网解析:1~2147483647。
    • 内网解析:300~2147483647。

    默认值为300s。

    records

    Array of strings

    域名解析后的值。

    create_at

    String

    创建时间。

    格式:yyyy-MM-dd'T'HH:mm:ss.SSS

    update_at

    String

    更新时间。

    格式:yyyy-MM-dd'T'HH:mm:ss.SSS

    status

    String

    资源状态。

    详细信息请参见资源状态

    default

    Boolean

    标识是否由系统默认生成,系统默认生成的Record Set不能删除。

    project_id

    String

    该Record Set所属的项目ID。

    links

    Object

    指向当前资源或者其他资源的链接。当查询需要分页时,需要包含一个next链接指向下一页。

    详细信息请参见表5

    表5 links参数说明

    名称

    参数类型

    说明

    self

    String

    当前资源的链接。

    next

    String

    下一页资源的链接。

  • 响应样例
    {
        "id": "2c9eb155587228570158722b6ac30007",
        "name": "www.example.com.",
        "description": "This is an example record set.",
        "type": "A",
        "ttl": 300,
        "records": [
            "192.168.10.1",
            "192.168.10.2"
        ],
        "status": "PENDING_CREATE",
        "links": {
            "self": "https://Endpoint/v2/zones/2c9eb155587194ec01587224c9f90149/recordsets/2c9eb155587228570158722b6ac30007"
        },
        "zone_id": "2c9eb155587194ec01587224c9f90149",
        "zone_name": "example.com.",
        "create_at": "2016-11-17T12:03:17.827",
        "update_at": null,
        "default": false,
        "project_id": "e55c6f3dc4e34c9f86353b664ae0e70c"
    }
    

返回值

接口正常的返回值为2xx,例如200、202或者204。

返回值含义以及更多返回值请参考状态码