def create_webhook(): """ create a hook to a specific event, uses message above as the data sent :return: """ response = requests.put(kp.server + ':8000/v2/accounts/' + kp.get_acc_id() + '/webhooks', headers=headers, data=ws.jsonify(message2)) return response
import websockets as w import asyncio import json as j from websockets import ConnectionClosed import kazoo_put as kp """ Makes second connection to kazoo for user creation """ # Global Variables HOST = '18.218.219.1' auth_token = kp.get_auth_token() acc_id = kp.get_acc_id() def jsonify(d): """ jsonify a message :param d: a dict to turn into a json file """ jsonfied = j.dumps(d) return jsonfied # subscription message to crossbar with single binding message = { 'action': 'subscribe', 'auth_token': auth_token, 'request_id': acc_id,
from configparser import ConfigParser from kazoo_put import get_headers, get_auth_token, get_acc_id KAZOO_HOST = '18.218.219.1' KAZOO_SERVER = 'http://18.218.219.1' WEBHOOKS_SERVER = '' AUTH_TOKEN = get_auth_token() HEADERS = get_headers(AUTH_TOKEN) ACC_ID = get_acc_id() DOC_CREATE_WEBHOOKS = { "data": { "name": "Destroy2", "uri": WEBHOOKS_SERVER, "http_verb": "post", "hook": "object", "action": "doc_created", "type": "account", "retries": 3, "custom_data": { "type": "user", "action": "doc_created" } } } DOC_CREATED_WEBHOOKS = { "data": { "name": "account3", "uri": WEBHOOKS_SERVER, "http_verb": "post",