def get(self): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) objts = dao.get_obstacles_summary() dao.close() resp = make_response(json_serialize(objts, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def post(self, name): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) dao.generate_vulnerability(name) dao.close() resp_dict = {'message': 'Vulnerability successfully generated'} resp = make_response(json_serialize(resp_dict), OK) resp.headers['Content-type'] = 'application/json' return resp
def post(self,name): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) dao.generate_vulnerability(name) dao.close() resp_dict = {'message': 'Vulnerability successfully generated'} resp = make_response(json_serialize(resp_dict), OK) resp.headers['Content-type'] = 'application/json' return resp
def get(self, environment): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) goals = dao.get_obstacle_names(environment=environment) dao.close() resp = make_response(json_serialize(goals, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def get(self, name): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) found_obstacle = dao.get_obstacle_by_name(name) dao.close() resp = make_response(json_serialize(found_obstacle, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def get(self, name): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) found_obstacle = dao.get_obstacle_by_name(name) dao.close() resp = make_response( json_serialize(found_obstacle, 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 = ObstacleDAO(session_id) obstacles = dao.get_obstacles(constraint_id=constraint_id) dao.close() resp = make_response(json_serialize(obstacles, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def delete(self, name): session_id = get_session_id(session, request) dao = ObstacleDAO(session_id) dao.delete_obstacle(name) dao.close() resp_dict = {'message': 'Obstacle 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 = ObstacleDAO(session_id) upd_obs = dao.from_json(request) dao.update_obstacle(upd_obs, name) dao.close() resp_dict = {'message': 'Obstacle 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 = ObstacleDAO(session_id) new_obstacle = dao.from_json(request) new_obstacle_id = dao.add_obstacle(new_obstacle) dao.close() resp_dict = {'message': 'Obstacle successfully added'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp
def get(self, environment, obstacle): session_id = get_session_id(session, request) model_generator = get_model_generator() dao = ObstacleDAO(session_id) if obstacle == 'all': obstacle = '' dot_code = dao.get_obstacle_model(environment,obstacle) dao.close() resp = make_response(model_generator.generate(dot_code, model_type='obstacle',renderer='dot'), OK) accept_header = request.headers.get('Accept', 'image/svg+xml') if accept_header.find('text/plain') > -1: resp.headers['Content-type'] = 'text/plain' else: resp.headers['Content-type'] = 'image/svg+xml' return resp
def get(self, environment, obstacle): session_id = get_session_id(session, request) model_generator = get_model_generator() dao = ObstacleDAO(session_id) if obstacle == 'all': obstacle = '' dot_code = dao.get_obstacle_model(environment, obstacle) dao.close() resp = make_response( model_generator.generate(dot_code, model_type='obstacle', renderer='dot'), OK) accept_header = request.headers.get('Accept', 'image/svg+xml') if accept_header.find('text/plain') > -1: resp.headers['Content-type'] = 'text/plain' else: resp.headers['Content-type'] = 'image/svg+xml' return resp