def get(self, name): session_id = get_session_id(session, request) dao = RoleDAO(session_id) props = dao.get_role_props(name) dao.close() resp = make_response(json_serialize(props, session_id=session_id), OK) resp.contenttype = 'application/json' return resp
def get(self, name): session_id = get_session_id(session, request) dao = RoleDAO(session_id) found_role = dao.get_role_by_name(name) dao.close() resp = make_response(json_serialize(found_role, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def get(self): session_id = get_session_id(session, request) constraint_id = request.args.get('constraint_id', -1) dao = RoleDAO(session_id) roles = dao.get_roles(constraint_id) dao.close() resp = make_response(json_serialize(roles, session_id=session_id)) resp.contenttype = "application/json" return resp
def delete(self, name): session_id = get_session_id(session, request) dao = RoleDAO(session_id) dao.delete_role(name=name) dao.close() resp_dict = {'message': 'Role successfully deleted'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp
def post(self): session_id = get_session_id(session, request) dao = RoleDAO(session_id) new_role = dao.from_json(request) role_id = dao.add_role(new_role) dao.close() resp_dict = {'role_id': role_id} resp = make_response(json_serialize(resp_dict, session_id=session_id), httplib.OK) resp.contenttype = 'application/json' return resp
def put(self, name): session_id = get_session_id(session, request) dao = RoleDAO(session_id) upd_role = dao.from_json(request) dao.update_role(upd_role, name=name) dao.close() resp_dict = {'message': 'Update successful'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp
def post(self): session_id = get_session_id(session, request) dao = RoleDAO(session_id) new_role = dao.from_json(request) dao.add_role(new_role) dao.close() resp_dict = {'message': 'Add successful'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp