(email, key, zoneid, logger, page=1, search={})
Return a dictionary of records that match searchstring or zoneid
Return a dictionary of records that match searchstring or zoneid
Return a dictionary of records that match searchstring or zoneid
def get_recs(email, key, zoneid, logger, page=1, search={}):
    ''' Return a dictionary of records that match searchstring or zoneid '''
    return_data = {}
    headers = {
        'X-Auth-Email' : email,
        'X-Auth-Key' : key,
        'Content-Type' : 'application/json'
    }
    url = "%s/zones/%s/dns_records?per_page=100" % (baseurl, str(zoneid))
    for param in search.keys():
        url = "%s&%s=%s" % (url, param, search[param])
    if page > 1:
        url = "%s&page=%s" % (url, str(page))
    logger.debug('cloudflare: Requesting url ' + url)
    try:
        req = requests.get(url=url, headers=headers)
        if validate_response(req, logger):
            data = json.loads(req.text)
            if data['result_info']['total_pages'] > page:
                newpage = page + 1
                newdata = get_recs(email, key, zoneid, logger, page=newpage, search=search)
                for new in newdata.keys():
                    return_data[new] = newdata[new]
            for rec in data['result']:
                return_data[rec['id']] = rec
        return return_data
    except:
        return return_data
def get_recs ( email , key , zoneid , logger , page = 1 , search = { } ) : return_data = { } headers = { 'X-Auth-Email' : email , 'X-Auth-Key' : key , 'Content-Type' : 'application/json' } url = "%s/zones/%s/dns_records?per_page=100" % ( baseurl , str ( zoneid ) ) for param in search . keys ( ) : url = "%s&%s=%s" % ( url , param , search [ param ] ) if page > 1 : url = "%s&page=%s" % ( url , str ( page ) ) logger . debug ( 'cloudflare: Requesting url ' + url ) try : req = requests . get ( url = url , headers = headers ) if validate_response ( req , logger ) : data = json . loads ( req . text ) if data [ 'result_info' ] [ 'total_pages' ] > page : newpage = page + 1 newdata = get_recs ( email , key , zoneid , logger , page = newpage , search = search ) for new in newdata . keys ( ) : return_data [ new ] = newdata [ new ] for rec in data [ 'result' ] : return_data [ rec [ 'id' ] ] = rec return return_data except : return return_data