DNS

获取 DNS 应用列表

URI

GET /admin-api/dns/

URI 参数

  • detail

    type: integer

    required: no

    description: 获取详细的 DNS 应用信息

  • page

    type: integer

    required: no

    description: 第几页,从 1 开始

  • page_size

    type: integer

    required: no

    description: 每页大小,默认 20

请求示例

Shell

curl http://{admin-site}/admin-api/dns/?page=1&page_size=20&detail=1

响应示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "meta": {
            "count": 1
        },
        "data": [
            {
                "zone": "test.com",
                "record": [
                    {
                        "is_healthy": true,   // 健康状态
                        "ttl": 5,
                        "type": "A",
                        "_modified_unix": 1614749852.6159,
                        "checker_port": 80,
                        "disabled": false,
                        "checker_fail_times": 3,
                        "id": 1,  // 记录 ID
                        "enable_checker": true,
                        "sub_domain": "foo",
                        "checker_timeout": 1,
                        "ip": "2.1.1.2",
                        "_created_unix": 1614749491.5138,
                        "line": 0,
                        "unit": "min"
                    }
                ],
                "id": 1,
                "nameserver": [
                    {
                        "ttl": 1,
                        "unit": "day",
                        "id": 1,
                        "domain": "n1.test.com"
                    },
                    {
                        "ttl": 1,
                        "unit": "day",
                        "id": 2,
                        "domain": "n2.test.com"
                    }
                ],
                "creator": 1,   // 创建者 ID
                "soa_email": "admin.test.com",
                "_created_unix": 1614749488.792,
                "_modified_unix": 1614749490.4672
            }
        ]
    }
}

获取指定 ID 的 DNS 应用的配置

URI

GET /admin-api/dns/{id}

URI参数

  • detail

    type: integer

    required: no

    description: 获取详细的 DNS 应用信息

请求示例

Shell

curl http://{admin-site}/admin-api/dns/1?detail=1

响应示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "zone": "test.com",
        "record": [
            {
                "is_healthy": true,
                "ttl": 5,
                "type": "A",
                "_modified_unix": 1614749852.6159,
                "checker_port": 80,
                "disabled": false,
                "checker_fail_times": 3,
                "id": 1,
                "enable_checker": true,
                "sub_domain": "foo",
                "checker_timeout": 1,
                "ip": "2.1.1.2",
                "_created_unix": 1614749491.5138,
                "line": 0,
                "unit": "min"
            }
        ],
        "id": 1,
        "nameserver": [
            {
                "ttl": 1,
                "unit": "day",
                "id": 1,
                "domain": "n1.test.com"
            },
            {
                "ttl": 1,
                "unit": "day",
                "id": 2,
                "domain": "n2.test.com"
            }
        ],
        "creator": 1,
        "soa_email": "admin@test.com",
        "_created_unix": 1614749488.792,
        "_modified_unix": 1614825469.4997
    }
}

创建 DNS 应用

URI

POST /admin-api/dns/

JSON Body 参数

  • zone

    type: string

    required: yes

    description: DNS 域

  • soa_email

    type: string

    required: no

    description: 响应中的 SOA 记录的邮箱

  • gid

    type: array

    required: no

    description: 拥有访问权限的用户组

  • nameserver

    type: array

    required: yes

    description: 权威域名服务器

请求示例

Shell

curl -X POST http://{admin-site}/admin-api/dns/ -d
'{
    "zone": "openresty.com",
    "nameserver": [
        {
            "domain": "ns1.openresty.com",
            "ttl": 1,
            "unit": "day"
        }
    ],
    "soa_email": "support@openresty.com",
    "gid": [
        2,
        3
    ]
}'

响应示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "id": 3
    }
}

修改 DNS 应用配置

URI

PUT /admin-api/dns/{id}

JSON Body 参数

  • zone

    type: string

    required: yes

    description: DNS 域

  • soa_email

    type: string

    required: no

    description: 响应中的 SOA 记录的邮箱

  • gid

    type: array

    required: no

    description: 拥有访问权限的用户组

  • nameserver

    type: array

    required: yes

    description: 权威域名服务器

请求示例

Shell

curl -X PUT http://{admin-site}/admin-api/dns/ -d
'{
    "id": 1,
    "zone": "openresty.com",
    "nameserver": [
        {
            "domain": "ns1.openresty.com",
            "ttl": 1,
            "unit": "day"
        }
    ],
    "soa_email": "support@openresty.com",
    "gid": [
        2,
        3
    ]
}'

响应示例

Status: 200 OK
{
    "status": 0
}

删除 DNS 应用

URI

DELETE /admin-api/dns/{id}

请求示例

Shell

curl -X DELETE http://{admin-site}/admin-api/dns/1

响应示例

Status: 200 OK
{
    "status": 0
}