def create_task(): r = request.get_json(force=True) if not r: abort(400) task = cxt.dao.task.create(name=r['name'], kind=r['kind'], description=r['description']) r = cxt.scheme.task.dump(task).data return mjsonify(r), 201
def create_web(): r = request.get_json(force=True) if not r: abort(400) task = cxt.dao.task.get_by_id(r['task_id']) web = cxt.dao.web.create_with_task(r.get('url', None), r.get('http_status', None), r.get('title', None), r.get('host', None), r.get('kind', None), task) rs = cxt.scheme.web.dump(web).data return mjsonify(rs), 201
def create_file(): r = request.get_json(force=True) if not r: abort(400) task = cxt.dao.task.get_by_id(r['task_id']) web = cxt.dao.web.get_by_id(r['web_id']) file = cxt.dao.file.create_with_task_web(r.get("name", None), r.get("uri", None), r.get("kind", None), task, web) rs = cxt.scheme.file.dump(file).data return mjsonify(rs), 201
def create_web(): r = request.get_json(force=True) if not r: abort(400) task = cxt.dao.task.get_by_id(r['task_id']) web = cxt.dao.web.create_with_task( r.get('url', None), r.get('http_status', None), r.get('title', None), r.get('host', None), r.get('kind', None), task ) rs = cxt.scheme.web.dump(web).data return mjsonify(rs), 201
def create_file(): r = request.get_json(force=True) if not r: abort(400) task = cxt.dao.task.get_by_id(r['task_id']) web = cxt.dao.web.get_by_id(r['web_id']) file = cxt.dao.file.create_with_task_web( r.get("name", None), r.get("uri", None), r.get("kind", None), task, web ) rs = cxt.scheme.file.dump(file).data return mjsonify(rs), 201
def get_file(id): file = cxt.dao.file.get_by_id(id) if not file: abort(404) rs = cxt.scheme.file.dump(file).data return mjsonify(rs)
def list_files(): files = cxt.dao.file.get_list() rs = cxt.scheme.files.dump(files).data return mjsonify(rs)
def get_visit(id): visit = cxt.dao.visit.get_by_id(id) rs = cxt.scheme.visit.dump(visit).data return mjsonify(rs)
def get_visits(): visits = cxt.dao.visit.get_list() rs = cxt.scheme.visits.dump(visits).data return mjsonify(rs)
def get_user(id): user = cxt.dao.user.get_by_id(id) rs = cxt.scheme.user.dump(user).data return mjsonify(rs)
def get_status(): d = dict(status='up') return mjsonify(d)
def get_web(id): web = cxt.dao.web.get_by_id(id) if not web: abort(404) rs = cxt.scheme.web.dump(web).data return mjsonify(rs)
def list_webs(): webs = cxt.dao.web.get_list() rs = cxt.scheme.webs.dump(webs).data return mjsonify(rs)
def get_task(id): task = cxt.dao.task.get_by_id(id) if not task: abort(404) r = cxt.scheme.task.dump(task).data return mjsonify(r)
def get_users(): users = cxt.dao.user.get_list() rs = cxt.scheme.users.dump(users).data return mjsonify(rs)
def list_tasks(): tasks = cxt.dao.task.get_list() r = cxt.scheme.tasks.dump(tasks).data return mjsonify(r)