def edges(self, request, parent_lookup_workspace__name: str, name: str): # Doesn't use the Network.edges method, in order to do proper pagination. workspace: Workspace = get_object_or_404( Workspace, name=parent_lookup_workspace__name) network: Network = get_object_or_404(Network, workspace=workspace, name=name) pagination = ArangoPagination() query = ArangoQuery.from_collections(workspace.get_arango_db(), network.edge_tables()) paginated_query = pagination.paginate_queryset(query, request) return pagination.get_paginated_response(paginated_query)
def get_rows(self, request, parent_lookup_workspace__name: str, name: str): workspace: Workspace = get_object_or_404(Workspace, name=parent_lookup_workspace__name) table: Table = get_object_or_404(Table, workspace=workspace, name=name) pagination = ArangoPagination() query = ArangoQuery.from_collections(workspace.get_arango_db(), [table.name]) # Attempt filtering try: query = query.filter(json.loads(request.query_params.get('filter', '{}'))) except json.JSONDecodeError as e: return Response( {'filter': [str(e)]}, status=status.HTTP_400_BAD_REQUEST, ) paginated_query = pagination.paginate_queryset(query, request) return pagination.get_paginated_response(paginated_query)
def edges(self, limit: int = 0, offset: int = 0) -> Cursor: return (ArangoQuery.from_collections(self.workspace.get_arango_db(), self.edge_tables()).paginate( limit=limit, offset=offset).execute())