DNS API

From CMU ITSC Network
Revision as of 10:47, 6 May 2018 by Supawit (talk | contribs)

Authentication

Authenticate with CMU OAuth to get access token then use as "bearer token" in "Authorization" Header on every request.

REST API

https://dns-api.cmu.ac.th

Method

List domain

List domain that authenticated user has permission.
Request

GET /domains HTTP/1.1
Host: dns-api.cmu.ac.th
Authorization: Bearer hKm1BTuXj4U7rGChx1eWKSb8bc6Wx1uz

Response

[
    {
        "domain": "cnoc.cmu.ac.th"
    },
    {
        "domain": "eng.cmu.ac.th"
    },
    {
        "domain": "reg.cmu.ac.th"
    }
]

List records in domain

Request

GET /domains/:domain HTTP/1.1
Host: dns-api.cmu.ac.th
Authorization: Bearer hKm1BTuXj4U7rGChx1eWKSb8bc6Wx1uz

Response

[
    {
        "id": 110,
        "domain_id": 1,
        "name": "cnoc.cmu.ac.th",
        "type": "A",
        "content": "202.28.249.45",
        "ttl": 3600,
        "prio": 0,
        "change_date": null,
        "disabled": 0,
        "ordername": null,
        "auth": 1
    },
    {
        "id": 1707,
        "domain_id": 1,
        "name": "xxx.cnoc.cmu.ac.th",
        "type": "A",
        "content": "5.6.7.8",
        "ttl": 3600,
        "prio": 0,
        "change_date": null,
        "disabled": 0,
        "ordername": null,
        "auth": 1
    },
    {
        "id": 1708,
        "domain_id": 1,
        "name": "xxx1.cnoc.cmu.ac.th",
        "type": "A",
        "content": "9.0.43.2",
        "ttl": 3600,
        "prio": 0,
        "change_date": null,
        "disabled": 0,
        "ordername": null,
        "auth": 1
    },
    {
        "id": 1709,
        "domain_id": 1,
        "name": "yyy.cnoc.cmu.ac.th",
        "type": "A",
        "content": "2.8.6.3",
        "ttl": 3600,
        "prio": 0,
        "change_date": null,
        "disabled": 0,
        "ordername": null,
        "auth": 1
    }
]
</syntaxhighlight lang=html>
'''Parameter'''
<syntaxhighlight>
:domain = domain name e.g. cnoc.cmu.ac.th