From c7fdeb3e468b8e270159a9ce1e394065a7fff4c9 Mon Sep 17 00:00:00 2001 From: cat-bro Date: Thu, 29 Feb 2024 16:36:59 +1100 Subject: [PATCH] Add view, keys, limit and offset to get_histories --- bioblend/_tests/TestGalaxyHistories.py | 8 ++++++ bioblend/galaxy/histories/__init__.py | 34 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/bioblend/_tests/TestGalaxyHistories.py b/bioblend/_tests/TestGalaxyHistories.py index 6dff33588..556e98799 100644 --- a/bioblend/_tests/TestGalaxyHistories.py +++ b/bioblend/_tests/TestGalaxyHistories.py @@ -85,6 +85,14 @@ def test_get_histories(self): ) assert len(old_histories) == 0 + # Test detailed view: check for presence of "size" field + histories_detailed = self.gi.histories.get_histories(view="detailed") + assert "size" in histories_detailed[0] + + # Test keys + histories_with_keys = self.gi.histories.get_histories(keys=["id", "user_id", "size"]) + assert set([key for key in histories_with_keys[0]]) == set(["id", "user_id", "size"]) + # TODO: check whether deleted history is returned correctly # At the moment, get_histories() returns only not-deleted histories # and get_histories(deleted=True) returns only deleted histories, diff --git a/bioblend/galaxy/histories/__init__.py b/bioblend/galaxy/histories/__init__.py index 4fac2b195..52a5b76d4 100644 --- a/bioblend/galaxy/histories/__init__.py +++ b/bioblend/galaxy/histories/__init__.py @@ -93,6 +93,10 @@ def _get_histories( create_time_max: Optional[str] = None, update_time_min: Optional[str] = None, update_time_max: Optional[str] = None, + view: Optional[str] = "summary", + keys: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, all: Optional[bool] = False, ) -> List[Dict[str, Any]]: """ @@ -124,6 +128,14 @@ def _get_histories( params.setdefault("qv", []).append(update_time_max) if all: params["all"] = True + if view: + params["view"] = view + if keys: + params["keys"] = ",".join(keys) + if limit: + params["limit"] = limit + if offset: + params["offset"] = offset url = "/".join((self._make_url(), "published")) if get_all_published else None histories = self._get(url=url, params=params) @@ -143,6 +155,10 @@ def get_histories( create_time_max: Optional[str] = None, update_time_min: Optional[str] = None, update_time_max: Optional[str] = None, + view: Optional[str] = 'summary', + keys: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, all: Optional[bool] = False, ) -> List[Dict[str, Any]]: """ @@ -187,6 +203,20 @@ def get_histories( parameter works only on Galaxy 20.01 or later and can be specified only if the user is a Galaxy admin. + :type view: str + :param view: Options are 'summary' or 'detailed'. This defaults to 'summary'. + Setting view to 'detailed' results in a larger number of fields returned. + + :type keys: List[str] + :param keys: List of fields to return + + :type limit: int + :param limit: How many items to return (upper bound). + + :type offset: int + :param offset: skip the first ( offset - 1 ) items and begin returning + at the Nth item. + :rtype: list :return: List of history dicts. @@ -205,6 +235,10 @@ def get_histories( get_all_published=False, slug=slug, all=all, + view=view, + keys=keys, + limit=limit, + offset=offset, create_time_min=create_time_min, create_time_max=create_time_max, update_time_min=update_time_min,