Difference between revisions of "DNS API"

From CMU ITSC Network
Line 8: Line 8:
 
List domain that authenticated user has permission.<br>
 
List domain that authenticated user has permission.<br>
 
'''Request'''
 
'''Request'''
<syntaxhighlight>
+
<syntaxhighlight lang=html>
 
GET /domains HTTP/1.1
 
GET /domains HTTP/1.1
 
Host: dns-api.cmu.ac.th
 
Host: dns-api.cmu.ac.th
Line 14: Line 14:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
'''Response'''
 
'''Response'''
<syntaxhighlight>
+
<syntaxhighlight lang=json>
 
[
 
[
 
     {
 
     {
Line 30: Line 30:
 
=== List records in domain ===
 
=== List records in domain ===
 
'''Request'''
 
'''Request'''
<syntaxhighlight>
+
<syntaxhighlight lang=html>
 
GET /domains/:domain HTTP/1.1
 
GET /domains/:domain HTTP/1.1
 
Host: dns-api.cmu.ac.th
 
Host: dns-api.cmu.ac.th
Line 36: Line 36:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
'''Response'''
 
'''Response'''
<syntaxhighlight>
+
<syntaxhighlight lang=json>
 
[
 
[
 
     {
 
     {
Line 91: Line 91:
 
     }
 
     }
 
]
 
]
</syntaxhighlight>
+
</syntaxhighlight lang=html>
 
'''Parameter'''
 
'''Parameter'''
 
<syntaxhighlight>
 
<syntaxhighlight>
 
:domain = domain name e.g. cnoc.cmu.ac.th
 
:domain = domain name e.g. cnoc.cmu.ac.th
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 10:47, 6 May 2018

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