4. Description of requests to API for DNS master services
4.5 Working with resource records
4.5.1 Adding resource record
The format of the request for adding resource record has the following look:
PUT https://api.nic.ru/dns-master/services/<service>/zones/<zone>/records Authorization: Bearer <token>
<?xml version="1.0" encoding="UTF-8" ?>
Settings submitted in request:
<service>
- service identifier;
<zone>
- zone name;
<token>
- access token
(<rr>...</rr>)+
resource records in the request should be transferred as XML data ;
+
- one and more repetitions.
Request example:
PUT https://api.nic.ru/dns-master/services/TESTSERVICE/zones/TEST.RU/records Authorization: Bearer 123123123123
<?xml version="1.0" encoding="UTF-8" ?>
<request>
</request>
If the request is successful, HTTP code 200 will be returned in the response. Request body contains created records and has the following look:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>success</status>
<data>
<zone admin="123/NIC-REG" has-changes="true" id="228095" idn-name="test.ru" name="test.ru" service="testservice">
<rr id="210076"><name>@</name><idn-name>@</idn-name><type>NS</type><ns><name>ns4-l2.nic.ru.</name><idn-name>ns4-l2.nic.ru.</idn-name></ns></rr>
<rr id="210077"><name>@</name><idn-name>@</idn-name><type>NS</type><ns><name>ns8-l2.nic.ru.</name><idn-name>ns8-l2.nic.ru.</idn-name></ns></rr>
</zone>
</data>
</response>
If any errors occurred, HTTP with the error code will be returned in the response and the response body will have the following look:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>fail</status>
<errors>
<error code="4097">Access token expired or not found</error>
</errors>
</response>
4.5.2 Obtaining records list in zone
Request format for records obtaining in zone:
GET https://api.nic.ru/dns-master/services/<service>/zones/<zone>/records Authorization: Bearer <token>
The second request option:
GET https://api.nic.ru/dns-master/services/<service>/zones/<zone>/records?token=<token>
Settings submitted in request:
<service>
- service identifier;
<zone>
- zone name;
<token>
- access token
<rr_id>
- record identifier Request example:
GET https://api.nic.ru/services/MYSERVICE/zones/TEST.RU/records?token=1223123
If the request is successful, HTTP code 200 will be returned in the response. The response body contains resource records which are already created in the zone file and have the following look:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>success</status>
<data>
<zone admin="123/NIC-REG" has-changes="true" id="228095" idn-name="test.ru" name="test.ru" service="myservice">
<rr id="210074"><name>@</name><idn-name>@</idn-name><type>SOA</type><soa><mname><name>ns3-l2.nic.ru.</name><idn-
name>ns3-l2.nic.ru.</idn-name></mname><rname><name>dns.nic.ru.</name><idn-name>dns.nic.ru.</idn-name></rname><serial>2011112002</serial><refresh>1440</refresh><retry>3600</retry><expire>2592000</expire><minimum>600</m inimum></soa></rr>
<rr id="210075"><name>@</name><idn-name>@</idn-name><type>NS</type><ns><name>ns3-l2.nic.ru.</name><idn-name>ns3-l2.nic.ru.</idn-name></ns></rr>
<rr id="210076"><name>@</name><idn-name>@</idn-name><type>NS</type><ns><name>ns4-l2.nic.ru.</name><idn-name>ns4-l2.nic.ru.</idn-name></ns></rr>
<rr id="210077"><name>@</name><idn-name>@</idn-name><type>NS</type><ns><name>ns8-l2.nic.ru.</name><idn-name>ns8-l2.nic.ru.</idn-name></ns></rr>
</zone>
</data>
</response>
If any errors occurred, HTTP with the error code will be returned in the response and the response body will have the following look:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>fail</status>
<errors>
<error code="4097">Access token expired or not found</error>
</errors>
</response>
4.5.3 Deleting resource record
The request format for deleting resource record has the following look:
DELETE https://api.nic.ru/dns-master/services/<service>/zones/<zone>/records/<rr_id>
Authorization: Bearer <token>
Settings submitted in request:
<service>
- service identifier;
<zone>
- zone name;
<token>
- access token
<rr_id>
- record identifier
Request example:
DELETE https://api.nic.ru/dns-master/services/MYSERVICE/zones/TEST.RU/records/210075 Authorization: Bearer 123123123123
If the request is successful, HTTP code 200 will be returned in the response.
If any errors occurred, HTTP with the error code will be returned in the response and the response body will have the following look:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>fail</status>
<errors>
<error code="4097">Access token expired or not found</error>
</errors>
</response>