def get(self, name): session_id = get_session_id(session, request) dao = ExternalDocumentDAO(session_id) found_edoc = dao.get_external_document(name) dao.close() resp = make_response(json_serialize(found_edoc, 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 = ExternalDocumentDAO(session_id) edocs = dao.get_external_documents(constraint_id=constraint_id) dao.close() resp = make_response(json_serialize(edocs, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def delete(self, name): session_id = get_session_id(session, request) dao = ExternalDocumentDAO(session_id) dao.delete_external_document(name) dao.close() resp_dict = {'message': 'External Document successfully deleted'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def put(self, name): session_id = get_session_id(session, request) dao = ExternalDocumentDAO(session_id) upd_edoc = dao.from_json(request) dao.update_external_document(upd_edoc, name) dao.close() resp_dict = {'message': 'External Document successfully updated'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def post(self): session_id = get_session_id(session, request) dao = ExternalDocumentDAO(session_id) new_edoc = dao.from_json(request) dao.add_external_document(new_edoc) dao.close() resp_dict = {'message': 'External Document successfully added'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp