Commit 2b27fdba authored by Alexandre Moevi's avatar Alexandre Moevi

add(route): get all the webhooks

parent 83381a49
......@@ -30,7 +30,19 @@ from canopsis.webcore.utils import (gen_json, gen_json_error,
def exports(ws):
webhook_manager = WebhookManager(WebhookManager.default_collection())
@ws.application.get(
'/api/v2/webhook'
)
def get_webhook_list():
try:
document = webhook_manager.get_webhook_list()
except PyMongoError:
return gen_json_error(
{"description": "Can not retrieve the webhooks list from "
"database, contact your administrator."},
HTTP_ERROR)
return gen_json(document)
@ws.application.get(
'/api/v2/webhook/<webhook_id>'
......
......@@ -46,6 +46,9 @@ class WebhookManager(object):
collection = store.get_collection(name=cls.COLLECTION)
return MongoCollection(collection)
def get_webhook_list(self):
return list(self.__collection.find({}))
def get_webhook_by_id(self, wid):
return self.__collection.find_one({'_id': wid})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment