def on_get(self, req: Request, resp: Response): # limit = safe_int(req.params.get('limit', 0)) # offset = safe_int(req.params.get('offset', 0)) # sortby = req.params.get('sortby') if req.params.get('sortby') in SORT_ATTRIBUTES else 'created' # order = True if req.params.get('order') == 'desc' else False # datasets = self._dataset_manager.datasets(limit=limit, offset=offset, sortby=sortby, order=order) query = get_params_to_query(req, SORT_ATTRIBUTES, 'created', 'desc') datasets = self._dataset_manager.datasets(query) resp.body = f"[{','.join(map(lambda ds: ds.json(), datasets))}]"
def on_get(self, req: Request, resp: Response): query = get_params_to_query(req, SORT_ATTRIBUTES, 'created', 'desc') methods = self._method_manager.list_methods(query=query) if isinstance(methods, Exception): resp.body = json.dumps(dict(error=str(methods))) resp.status = falcon.HTTP_500 else: resp.body = f"[{','.join(map(lambda x: x.json(), methods))}]" resp.status = falcon.HTTP_201
def on_get(self, req: Request, resp: Response, model_id: UUID = None, git_commit_id: str = None): query = get_params_to_query(req, SORT_ATTRIBUTES, 'created', 'desc') if model_id and git_commit_id: snapshots = self._snapshot_manager.list_snapshots_filtered(model_id=model_id, git_commit_id=git_commit_id, query=query) else: snapshots = self._snapshot_manager.list_snapshots(query=query) if isinstance(snapshots, Exception): resp.body = json.dumps(dict(error=str(snapshots))) resp.status = falcon.HTTP_500 else: resp.body = json.dumps(dict(count=self._snapshot_manager.snapshot_count())) resp.status = falcon.HTTP_201
def on_get(self, req: Request, resp: Response, dataset_id: UUID): query = get_params_to_query(req, SORT_ATTRIBUTES, 'created', 'desc') print(f'query: {query}') versions = self._dataset_manager.versions(dataset_id, query) resp.body = f"[{','.join(map(lambda v: v.json(), versions))}]"