def fill_webhook_history(step): db = dbmanager.DB(lib.world.config['connections']['mysql']) lib.world.webhook_history = {} for record in step.hashes: record['history_id'] = uuid.UUID(strip(record.get('history_id', "'%s'" % lib.generate_history_id()))).hex.upper() record['webhook_id'] = uuid.UUID(strip(record.get('webhook_id', "'%s'" % lib.generate_webhook_id()))).hex.upper() record['endpoint_id'] = uuid.UUID(strip(record.get('endpoint_id', "'%s'" % lib.generate_endpoint_id()))).hex.upper() record['event_id'] = record.get('event_id', "%s" % lib.generate_id()) record['status'] = record.get('status', 0) record['payload'] = record.get('payload', "'This is text'") query = ( "INSERT INTO webhook_history " "(history_id, webhook_id, endpoint_id, event_id, status, payload) " "VALUES (UNHEX('{history_id}'), UNHEX('{webhook_id}'), UNHEX('{endpoint_id}'), " "{event_id}, {status}, {payload})" ).format(**record) db.execute(query) query = "SELECT * FROM webhook_history where history_id=UNHEX('%s')" \ % strip(record['webhook_id']).replace('-', '') webhook = db.execute(query)[0] lib.world.webhook_history[strip(record['webhook_id'])] = webhook
def fill_webhook_history(step): db = dbmanager.DB(lib.world.config["connections"]["mysql"]) lib.world.webhook_history = {} for record in step.hashes: record["history_id"] = uuid.UUID( strip(record.get("history_id", "'%s'" % lib.generate_history_id())) ).hex.upper() record["webhook_id"] = uuid.UUID( strip(record.get("webhook_id", "'%s'" % lib.generate_webhook_id())) ).hex.upper() record["endpoint_id"] = uuid.UUID( strip(record.get("endpoint_id", "'%s'" % lib.generate_endpoint_id())) ).hex.upper() record["event_id"] = record.get("event_id", "%s" % lib.generate_id()) record["status"] = record.get("status", 0) record["payload"] = record.get("payload", "'This is text'") query = ( "INSERT INTO webhook_history " "(history_id, webhook_id, endpoint_id, event_id, status, payload) " "VALUES (UNHEX('{history_id}'), UNHEX('{webhook_id}'), UNHEX('{endpoint_id}'), " "{event_id}, {status}, {payload})" ).format(**record) db.execute(query) query = "SELECT * FROM webhook_history where history_id=UNHEX('%s')" % strip(record["webhook_id"]).replace( "-", "" ) webhook = db.execute(query)[0] lib.world.webhook_history[strip(record["webhook_id"])] = webhook
def fill_webhook_history(step): db = dbmanager.DB(lib.world.config['connections']['mysql']) lib.world.webhook_history = {} for record in step.hashes: record['history_id'] = record.get( 'history_id', "'%s'" % lib.generate_history_id()).replace('-', '').upper() record['webhook_id'] = record.get( 'webhook_id', "'%s'" % lib.generate_webhook_id()).replace('-', '').upper() record['endpoint_id'] = record.get( 'endpoint_id', "'%s'" % lib.generate_endpoint_id()).replace('-', '').upper() record['event_id'] = record.get('event_id', "'%s'" % lib.generate_id()) record['status'] = record.get('status', 0) record['payload'] = record.get('payload', "'This is text'") query = ( "INSERT INTO webhook_history " "(history_id, webhook_id, endpoint_id, event_id, status, payload) " "VALUES (UNHEX({history_id}), UNHEX({webhook_id}), UNHEX({endpoint_id}), " "{event_id}, {status}, {payload})").format(**record) db.execute(query) query = "SELECT * FROM webhook_history where history_id=UNHEX('%s')" \ % strip(record['webhook_id']).replace('-', '') webhook = db.execute(query)[0] lib.world.webhook_history[strip(record['webhook_id'])] = webhook
def fill_webhook_endpoints(step): db = dbmanager.DB(lib.world.config["connections"]["mysql"]) lib.world.webhook_endpoints = {} for record in step.hashes: record["endpoint_id"] = record.get("endpoint_id", "'%s'" % lib.generate_endpoint_id()).replace("-", "") record["url"] = record.get("url", "http://localhost") query = ( "INSERT INTO webhook_endpoints " "(endpoint_id, url) " "VALUES (UNHEX('{endpoint_id}'), {url})" ).format(**record) db.execute(query) query = "SELECT * FROM webhook_endpoints where endpoint_id=UNHEX('%s')" % strip(record["endpoint_id"]).replace( "-", "" ) endpoint = db.execute(query)[0] lib.world.webhook_endpoints[endpoint["endpoint_id"]] = endpoint
def fill_webhook_endpoints(step): db = dbmanager.DB(lib.world.config['connections']['mysql']) lib.world.webhook_endpoints = {} for record in step.hashes: record['endpoint_id'] = record.get( 'endpoint_id', "'%s'" % lib.generate_endpoint_id()).replace('-', '') record['url'] = record.get('url', 'http://localhost') query = ("INSERT INTO webhook_endpoints " "(endpoint_id, url) " "VALUES (UNHEX({endpoint_id}), {url})").format(**record) db.execute(query) query = "SELECT * FROM webhook_endpoints where endpoint_id=UNHEX('%s')" \ % strip(record['endpoint_id']).replace('-', '') endpoint = db.execute(query)[0] lib.world.webhook_endpoints[endpoint['endpoint_id']] = endpoint
def fill_webhook_endpoints(step): db = dbmanager.DB(lib.world.config['connections']['mysql']) lib.world.webhook_endpoints = {} for record in step.hashes: record['endpoint_id'] = record.get('endpoint_id', "'%s'" % lib.generate_endpoint_id()).replace('-', '') record['url'] = record.get('url', 'http://localhost') query = ( "INSERT INTO webhook_endpoints " "(endpoint_id, url) " "VALUES (UNHEX('{endpoint_id}'), {url})" ).format(**record) db.execute(query) query = "SELECT * FROM webhook_endpoints where endpoint_id=UNHEX('%s')" \ % strip(record['endpoint_id']).replace('-', '') endpoint = db.execute(query)[0] lib.world.webhook_endpoints[endpoint['endpoint_id']] = endpoint