DNS records

Get a list of DNS records

Description

Gets the list of DNS records for the specified paging.

URI

GET /admin-api/dns/{id}/record

URI Parameters

  • detail

    type: integer

    required: no

    description: Get detailed DNS application information

  • page

    type: integer

    required: no

    description: Results page (default 1)

  • page_size

    type: integer

    required: no

    description: Results page size (default 20)

Example Request

Shell

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

Example Response

Status: 200 OK
{
    "status": 0,
    "data": {
        "meta": {
            "count": 2  // Number of results
        },
        "data": [
            {
                "ttl": 5,
                "type": "A",
                "_modified_unix": 1614829316.766,
                "priority": 1,
                "id": 15,
                "_created_unix": 1614829316.766,
                "is_master": true,
                "unit": "min",
                "disabled": false,
                "sub_domain": "abc",
                "line": 0,
                "gateway": 1
            },
            {
                "ttl": 5,
                "type": "A",
                "_modified_unix": 1614829311.0838,
                "priority": 1,
                "id": 14,
                "_created_unix": 1614829311.0838,
                "is_master": true,
                "unit": "min",
                "disabled": false,
                "sub_domain": "www",
                "line": 0,
                "gateway": 1
            }
        ]
    }
}

Add a DNS record

Description

Add a DNS record.

URI

POST /admin-api/dns/{id}/record

JSON Body Parameters

  • sub_domain

    type: string

    required: yes

    description: Sub-domain

  • type

    type: string

    required: yes

    description: Sub-domain type, optional values: A/AAAA/CNAME/MX/TXT/NS/CAA/SRV

  • disabled

    type: boolean

    required: no

    description: Disable or not

  • ttl

    type: integer

    required: no

    description: Time To Live

  • unit

    type: string

    required: no

    description: Units of Time To Live

  • priority

    type: integer

    required: no

    description: Priority

  • weight

    type: integer

    required: no

    description: Weight

  • port

    type: integer

    required: no

    description: Port

  • is_master

    type: boolean

    required: yes

    description: Decide whether it is a master record

  • cidr

    type: string

    required: no

    description: The IP address that matches this CIDR will resolve this record. (either with line)

  • line

    type: integer

    required: no

    description: The IP address matching this network type will resolve this record (either with cidr)

  • ip

    type: string

    required: no

    description: DNS Response content, can be used for A/AAAA record.

  • domain

    type: string

    required: no

    description: DNS Response content, can be used for CNAME record.

  • gateway

    type: integer

    required: no

    description: DNS Response content, can be used for A/AAAA record.

  • enable_checker

    type: boolean

    required: no

    description: Whether to enable health checks

  • checker_port

    type: integer

    required: yes

    description: Port for health check (mandatory when enable_checker = true)

  • checker_timeout

    type: integer

    required: yes

    description: Health check timeout (mandatory when enable_checker = true)

  • checker_fail_times

    type: integer

    required: yes

    description: Number of failed health checks, after this number is reached, it will be marked as unhealthy (mandatory when enable_checker = true)

Example Request

Shell

curl -X POST https://{admin-site}/admin-api/dns/{id}/record -d '
{
    "line": 0,
    "disabled": false,
    "type": "A",
    "sub_domain": "abc",
    "ttl": 5,
    "unit": "min",
    "priority": 1,
    "is_master": true,
    "enable_checker": true,
    "checker_port": 80,
    "checker_timeout": 3,
    "checker_fail_times": 3,
    "gateway": 1,
    "ip": null
}'

Example Response

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

Modify a DNS record

Description

Modify a DNS record.

URI

PUT /admin-api/dns/{id}/record

JSON Body Parameters

  • sub_domain

    type: string

    required: yes

    description: Sub-domain

  • type

    type: string

    required: yes

    description: Sub-domain type, optional values: A/AAAA/CNAME/MX/TXT/NS/CAA/SRV

  • disabled

    type: boolean

    required: no

    description: Disable or not

  • ttl

    type: integer

    required: no

    description: Time To Live

  • unit

    type: string

    required: no

    description: Units of Time To Live

  • priority

    type: integer

    required: no

    description: Priority

  • weight

    type: integer

    required: no

    description: Weight

  • port

    type: integer

    required: no

    description: Port

  • is_master

    type: boolean

    required: yes

    description: Is it the master record?

  • cidr

    type: string

    required: no

    description: The IP address that matches this CIDR will resolve this record. (either with line)

  • line

    type: integer

    required: no

    description: The IP address matching this network type will resolve this record (either with cidr)

  • ip

    type: string

    required: no

    description: DNS Response content, can be used for A/AAAA record.

  • domain

    type: string

    required: no

    description: DNS Response content, can be used for CNAME record.

  • gateway

    type: integer

    required: no

    description: DNS Response content, can be used for A/AAAA record.

  • enable_checker

    type: boolean

    required: no

    description: Whether to enable health checks

  • checker_port

    type: integer

    required: yes

    description: Port for health check (mandatory when enable_checker = true)

  • checker_timeout

    type: integer

    required: yes

    description: Health check timeout (mandatory when enable_checker = true)

  • checker_fail_times

    type: integer

    required: yes

    description: Number of failed health checks, after this number is reached, it will be marked as unhealthy (mandatory when enable_checker = true)

  • backup

    type: object

    required: no

    description: Old configuration

Example Request

Shell

curl -X PUT https://{admin-site}/admin-api/dns/{id}/record/{id} -d '
{
    "line": 1,
    "ttl": 5,
    "type": "A",
    "_modified_unix": 1614828677.1785,
    "id": 13,
    "_created_unix": 1614828677.1785,
    "is_master": true,
    "disabled": false,
    "sub_domain": "www",
    "unit": "sec",
    "backup": {
        "ttl": 5,
        "type": "A",
        "_modified_unix": 1614828677.1785,
        "id": 13,
        "_created_unix": 1614828677.1785,
        "is_master": true,
        "disabled": false,
        "ip": "11.11.11.11",
        "sub_domain": "www",
        "line": 1,
        "unit": "min",
        "isSwitchingMaster": false,
        "isSwitchingDisabled": false,
        "isSelected": false,
        "errors": false,
        "saved": false,
        "value": null,
        "domain": null,
        "text": null,
        "cidr": null,
        "gateway": null,
        "isEdited": false,
        "errorTitle": null,
        "errorContent": null
    },
    "ip": "11.11.11.11",
    "gateway": null
}'

Example Response

Status: 200 OK
{
    "status": 0
}

Delete a DNS record

Description

Delete a DNS record。

URI

DELETE /admin-api/dns/{id}/record/{id}

Example Request

Shell

curl -X DELETE https://{admin-site}/admin-api/dns/{id}/record/{id}

Example Response

Status: 200 OK
{
    "status": 0
}

Description

Calculate recommended configurations.

URI

GET /admin-api/dns-util/recommend

URI Parameters

  • sub_domain

    type: string

    required: yes

    description: Sub-domain

  • app_id

    type: integer

    required: yes

    description: ID of the DNS application

Example Request

Shell

curl https://{admin-site}/admin-api/dns-util/recommend?sub_domain=www&app_id=4

Example Response

Status: 200 OK
{
    "time": 1614829925,
    "status": 0,
    "data": [
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 0,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 1,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 2,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 3,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 4,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 5,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 6,
            "gateway": 1
        }
    ]
}