(redata, jdata, logger)
This method performs the heavy lifting
This method performs the heavy lifting
This method performs the heavy lifting
def run_reaction(redata, jdata, logger):
    ''' This method performs the heavy lifting '''
    rec_data = {
        'name' : redata['data']['rec_name'],
        'type' : redata['data']['rec_type'],
        'content' : redata['data']['content']
    }
    zoneid = cloudflare.get_zoneid(
          redata['data']['email'],
          redata['data']['apikey'],
          redata['data']['domain'],
          logger)
    if zoneid is not None:
        check = cloudflare.get_recs(
            redata['data']['email'],
            redata['data']['apikey'],
            zoneid,
            logger,
            page=1,
            search=rec_data,
            )
        logger.debug("cloudflare-rec-add: Got Records " + json.dumps(check))
        if len(check) == 0:
            logger.debug("cloudflare-rec-add: Found " + str(len(check)) + " matching records")
            rec_data['ttl'] = redata['data']['ttl']
            if "true" in redata['data']['proxied']:
                rec_data['proxied'] = True
            else:
                rec_data['proxied'] = False
            result = cloudflare.add_rec(
                redata['data']['email'],
                redata['data']['apikey'],
                zoneid,
                logger,
                rec_data)
            if result:
                logger.info("cloudflare-rec-add: Successfully added record for monitor " + redata['id'])
                return True
            else:
                logger.debug("cloudflare-rec-add: Failed to add record for monitor " + redata['id']) 
                return False
        else:
            logger.debug("cloudflare-rec-add: Found " + str(len(check)) + " matching records")
            return None
    else:
        logger.debug("cloudflare-rec-add: Could not pull zone id for domain " + redata['data']['domain'] + " for monitor  " + redata['id'])
        return False
def run_reaction ( redata , jdata , logger ) : rec_data = { 'name' : redata [ 'data' ] [ 'rec_name' ] , 'type' : redata [ 'data' ] [ 'rec_type' ] , 'content' : redata [ 'data' ] [ 'content' ] } zoneid = cloudflare . get_zoneid ( redata [ 'data' ] [ 'email' ] , redata [ 'data' ] [ 'apikey' ] , redata [ 'data' ] [ 'domain' ] , logger ) if zoneid is not None : check = cloudflare . get_recs ( redata [ 'data' ] [ 'email' ] , redata [ 'data' ] [ 'apikey' ] , zoneid , logger , page = 1 , search = rec_data , ) logger . debug ( "cloudflare-rec-add: Got Records " + json . dumps ( check ) ) if len ( check ) == 0 : logger . debug ( "cloudflare-rec-add: Found " + str ( len ( check ) ) + " matching records" ) rec_data [ 'ttl' ] = redata [ 'data' ] [ 'ttl' ] if "true" in redata [ 'data' ] [ 'proxied' ] : rec_data [ 'proxied' ] = True else : rec_data [ 'proxied' ] = False result = cloudflare . add_rec ( redata [ 'data' ] [ 'email' ] , redata [ 'data' ] [ 'apikey' ] , zoneid , logger , rec_data ) if result : logger . info ( "cloudflare-rec-add: Successfully added record for monitor " + redata [ 'id' ] ) return True else : logger . debug ( "cloudflare-rec-add: Failed to add record for monitor " + redata [ 'id' ] ) return False else : logger . debug ( "cloudflare-rec-add: Found " + str ( len ( check ) ) + " matching records" ) return None else : logger . debug ( "cloudflare-rec-add: Could not pull zone id for domain " + redata [ 'data' ] [ 'domain' ] + " for monitor  " + redata [ 'id' ] ) return False