def get(self): """Search edge in collections of kind edge from DB.""" args = pag_collections_arguments.parse_args(request) try: try: page = args.get('page') query = args.get('query') or '[]' per_page = args.get('per_page') collections = args.get('collections').split(',') data = json.loads(query) except JSONDecodeError: raise gmap_exc.SearchException('Parameter query is invalid') else: res = facade.search_collections(collections, data, page, per_page) return res, 200 except gmap_exc.CollectionNotExist as err: api.abort(404, errors=err.message) except ValidationError as error: res = validate(error) api.abort(400, errors=res)
def get(self, graph): """Search traversal.""" args = traversal_arguments.parse_args(request) try: search_dict = { 'graph_name': graph, 'start_vertex': args.get('start_vertex'), 'direction': args.get('direction'), 'item_order': args.get('item_order'), 'strategy': args.get('strategy'), 'order': args.get('order'), 'edge_uniqueness': args.get('edge_uniqueness'), 'vertex_uniqueness': args.get('vertex_uniqueness'), 'max_iter': args.get('max_iter'), 'min_depth': args.get('min_depth'), 'max_depth': args.get('max_depth'), 'init_func': args.get('init_func'), 'sort_func': args.get('sort_func'), 'filter_func': args.get('filter_func'), 'visitor_func': args.get('visitor_func'), 'expander_func': args.get('expander_func') } res = facade.search_traversal(**search_dict) return res, 200 except gmap_exc.GraphNotExist as err: api.abort(404, errors=err.message)
def get(self, key): """Get query by key.""" try: res = facade.get_query(key) return res, 200 except gmap_exc.DocumentNotExist as error: app.logger.warning(error.message) api.abort(404, errors=error.message)
def get(self, edge, key): """Get edge by key.""" try: res = facade.get_edge(edge, key) return res, 200 except gmap_exc.EdgeNotExist as err: api.abort(404, errors=err.message) except gmap_exc.DocumentNotExist as err: api.abort(404, errors=err.message)
def get(self, collection, key): """Get document by key.""" try: res = facade.get_document(collection, key) return res, 200 except gmap_exc.CollectionNotExist as err: api.abort(404, errors=err.message) except gmap_exc.DocumentNotExist as err: api.abort(404, errors=err.message)
def get(self, key): """Get query by key.""" args = query_parsers.execute_query_parser.parse_args(request) variable = args.get('variable') try: res = facade.execute_query(key, variable) return res, 200 except gmap_exc.DocumentNotExist as error: app.logger.warning(error.message) api.abort(404, errors=error.message)
def get(self, collection): """Search documents from collection.""" args = pagination_arguments.parse_args(request) try: try: page = args.get('page') query = args.get('query') or '[]' per_page = args.get('per_page') data = json.loads(query) except JSONDecodeError: raise gmap_exc.SearchException('Parameter query is invalid') else: res = facade.search(collection, data, page, per_page) return res, 200 except gmap_exc.CollectionNotExist as err: api.abort(404, errors=err.message) except ValidationError as error: res = validate(error) api.abort(400, errors=res)