Events end point.

This commit is contained in:
Arik Fraimovich 2014-04-10 12:29:21 +03:00
parent 718577f565
commit c84f18449b
2 changed files with 19 additions and 0 deletions

View File

@ -17,6 +17,7 @@ from flask.ext.restful import Resource, abort
from flask_login import current_user, login_user, logout_user
import sqlparse
import events
from permissions import require_permission
from redash import settings, utils
from redash import data
@ -129,6 +130,16 @@ class BaseResource(Resource):
return current_user._get_current_object()
class EventAPI(BaseResource):
def post(self):
events_list = request.get_json(force=True)
for event in events_list:
events.record_event(event)
api.add_resource(EventAPI, '/api/events', endpoint='events')
class DataSourceListAPI(BaseResource):
def get(self):
data_sources = [ds.to_dict() for ds in models.DataSource.select()]

8
redash/events.py Normal file
View File

@ -0,0 +1,8 @@
import logging
import json
logger = logging.getLogger("events")
def record_event(event):
logger.info(json.dumps(event))