Difference between revisions of "DNS API"

From CMU ITSC Network
Line 1: Line 1:
 
== Authentication ==
 
== Authentication ==
Authenticate with CMU Oauth to get authorization key then use as "bearer token" in "Authorization" Header on every request.
+
Authenticate with [https://oauth.cmu.ac.th CMU OAuth] to get access token then use as "bearer token" in "Authorization" Header on every request.
  
== End Point ==
+
== REST API ==
 +
'''https://dns-api.cmu.ac.th'''
 +
== Method ==
 
=== List domain ===
 
=== List domain ===
 
List domain that authenticated user has permission.<br>
 
List domain that authenticated user has permission.<br>
Line 24: Line 26:
 
     }
 
     }
 
]
 
]
 +
</syntaxhighlight>
 +
 +
=== List records in domain ===
 +
'''Request'''
 +
<syntaxhighlight>
 +
GET /domains/:domain HTTP/1.1
 +
Host: dns-api.cmu.ac.th
 +
Authorization: Bearer hKm1BTuXj4U7rGChx1eWKSb8bc6Wx1uz
 +
</syntaxhighlight>
 +
'''Response'''
 +
<syntaxhighlight>
 +
[
 +
    {
 +
        "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>
 +
'''Parameter'''
 +
<syntaxhighlight>
 +
:domain = domain name e.g. cnoc.cmu.ac.th
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 09:38, 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
    }
]

Parameter

:domain = domain name e.g. cnoc.cmu.ac.th