(email, key, domain, logger, start_time, end_time)
Grab Analytics from CloudFlares API for desired zone
Grab Analytics from CloudFlares API for desired zone
Grab Analytics from CloudFlares API for desired zone
def get_zone_analytics(email, key, domain, logger, start_time, end_time):
    ''' Grab Analytics from CloudFlares API for desired zone '''
    headers = {
        'X-Auth-Email' : email,
        'X-Auth-Key' : key,
        'Content-Type' : 'application/json'
    }
    zoneid = get_zoneid(email, key, domain, logger)
    url = "%s/zones/%s/analytics/dashboard" % (baseurl, zoneid)
    url = "%s?since=%s&until=%s&exclude_series=false" % (url,
                                                        start_time, end_time)
    logger.debug("cloudflare: Grabbing analytics from url " + url)
    try:
        req = requests.get(url=url, headers=headers)
        if validate_response(req, logger):
            metrics = json.loads(req.text)
            return metrics
        else:
            return None
    except:
        return None
def get_zone_analytics ( email , key , domain , logger , start_time , end_time ) : headers = { 'X-Auth-Email' : email , 'X-Auth-Key' : key , 'Content-Type' : 'application/json' } zoneid = get_zoneid ( email , key , domain , logger ) url = "%s/zones/%s/analytics/dashboard" % ( baseurl , zoneid ) url = "%s?since=%s&until=%s&exclude_series=false" % ( url , start_time , end_time ) logger . debug ( "cloudflare: Grabbing analytics from url " + url ) try : req = requests . get ( url = url , headers = headers ) if validate_response ( req , logger ) : metrics = json . loads ( req . text ) return metrics else : return None except : return None