Example #1
0
def update_soa_serial(server, token, soa_content):
    """Update SOA serial

    Argument:

        server:      TonicDNS API server
        token:       TonicDNS API authentication token
        soa_content: SOA record data

    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/' + soa_content.get('domain')
    cur_soa, new_soa = connect.tonicdns_client(uri,
                                               method,
                                               token,
                                               data=False,
                                               keyword='serial',
                                               content=soa_content)
    # set JSON

    domain = soa_content.get('domain')
    cur_o = JSONConverter(domain)
    new_o = JSONConverter(domain)
    cur_o.records = [cur_soa]
    new_o.records = [new_soa]
    cur_o.generata_data(False)
    new_o.generata_data(True)

    # Create new SOA record
    uri = 'https://' + server + '/zone/' + domain
    method = 'PUT'
    connect.tonicdns_client(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'
    connect.tonicdns_client(uri, method, token, cur_o.dict_records[0])
Example #2
0
def update_soa_serial(server, token, soa_content):
    """Update SOA serial

    Argument:

        server:      TonicDNS API server
        token:       TonicDNS API authentication token
        soa_content: SOA record data

    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/' + soa_content.get('domain')
    cur_soa, new_soa = connect.tonicdns_client(
        uri, method, token, data=False, keyword='serial', content=soa_content)
    # set JSON

    domain = soa_content.get('domain')
    cur_o = JSONConverter(domain)
    new_o = JSONConverter(domain)
    cur_o.records = [cur_soa]
    new_o.records = [new_soa]
    cur_o.generata_data(False)
    new_o.generata_data(True)

    # Create new SOA record
    uri = 'https://' + server + '/zone/' + domain
    method = 'PUT'
    connect.tonicdns_client(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'
    connect.tonicdns_client(uri, method, token, cur_o.dict_records[0])