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
}