def get_all_webhooks(self, ctx, all_tenants): LOG.info("List all webhooks") if all_tenants and ctx.get(TenantProps.IS_ADMIN, False): res = self.db_conn.webhooks.query() else: res = self.db_conn.webhooks.query( project_id=ctx.get(TenantProps.TENANT, "")) LOG.info(res) webhooks = [db_row_to_dict(webhook) for webhook in res] return webhooks
def add_webhook(self, ctx, url, headers=None, regex_filter=None): res = self._check_valid_webhook(url, headers, regex_filter) if not res.is_valid: LOG.exception("Failed to create webhook: %s" % res.message) return res.message try: db_row = self._webhook_to_db_row(url, headers, regex_filter, ctx) self.db_conn.webhooks.create(db_row) return db_row_to_dict(db_row) except Exception as e: LOG.exception("Failed to add webhook to DB") return {"ERROR": str(e)}
def _load_webhooks(self): db_webhooks = self._db.webhooks.query() return [ webhook_utils.db_row_to_dict(webhook) for webhook in db_webhooks ]