Example #1
0
def deleteRecords(server, token, data):
    # ContentType: application/json
    # x-authentication-token: token
    method = 'DELETE'
    uri = 'https://' + server + '/zone'
    for i in data:
        conn.tonicDNSClient(uri, method, token, i)
Example #2
0
def createRecords(server, token, domain, data):
    # ContentType: application/json
    # x-authentication-token: token
    method = 'PUT'
    uri = 'https://' + server + '/zone/' + domain
    for i in data:
        conn.tonicDNSClient(uri, method, token, i)
Example #3
0
def updateSerial(server, token, domain):
    # x-authentication-token: token

    # Get SOA record
    # `cur_soa` is current SOA record.
    # `new_soa` is incremental serial SOA record.
    method = 'GET'
    uri = 'https://' + server + '/zone/' + domain
    cur_soa, new_soa = conn.tonicDNSClient(uri, method, token, data=False,
                                           keyword='serial', domain=domain)
    # set JSON
    from converter import JSONConvert
    cur_o = JSONConvert(domain)
    new_o = JSONConvert(domain)
    cur_o.records = [cur_soa]
    new_o.records = [new_soa]
    cur_o.genData(False)
    new_o.genData(True)

    # Create new SOA record
    uri = 'https://' + server + '/zone/' + domain
    method = 'PUT'
    conn.tonicDNSClient(uri, method, token, new_o.dict_records[0])

    # Delete current SOA record why zone has only one SOA record.
    method = 'DELETE'
    uri = 'https://' + server + '/zone'
    conn.tonicDNSClient(uri, method, token, cur_o.dict_records[0])
Example #4
0
def createZoneRecords(server, token, domain, data, identifier):
    # ContentType: application/json
    # x-authentication-token: token
    method = 'PUT'
    uri = 'https://' + server + '/zone'

    for i, v in enumerate(data):

        if i == 0:
            from converter import JSONConvert
            obj = JSONConvert(domain)
            zone = obj.generateZone(domain, identifier, v)
            conn.tonicDNSClient(uri, method, token, zone)

        else:
            # method: PUT
            uri = 'https://' + server + '/zone/' + domain
            conn.tonicDNSClient(uri, method, token, v)
Example #5
0
def updateTemplate(server, token, identifier, template):
    # ContentType: application/json
    # x-authentication-token: token
    method = 'POST'
    uri = 'https://' + server + '/template/' + identifier
    conn.tonicDNSClient(uri, method, token, data=template)
Example #6
0
def getAllZone(server, token):
    # x-authentication-token: token
    method = 'GET'
    uri = 'https://' + server + '/zone'
    conn.tonicDNSClient(uri, method, token, data=False)
Example #7
0
def getZone(server, token, domain, keyword=''):
    # x-authentication-token: token
    method = 'GET'
    uri = 'https://' + server + '/zone/' + domain
    conn.tonicDNSClient(uri, method, token, data=False, keyword=keyword)
Example #8
0
def getTemplate(server, token, template):
    # x-authentication-token: token
    method = 'GET'
    uri = 'https://' + server + '/template/' + template
    conn.tonicDNSClient(uri, method, token, data=False)
Example #9
0
 def getToken(self):
     method = 'PUT'
     import connect as conn
     self.token = conn.tonicDNSClient(self.uri, method,
                                      self.token, data=self.setInfo())