diff --git a/bioblend/_tests/TestGalaxyHistories.py b/bioblend/_tests/TestGalaxyHistories.py index 6dff33588..a088916fb 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: check that fields requested are returned + histories_with_keys = self.gi.histories.get_histories(keys=["id", "user_id", "size"]) + assert {key for key in histories_with_keys[0]} >= {"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..bcad72e74 100644 --- a/bioblend/galaxy/histories/__init__.py +++ b/bioblend/galaxy/histories/__init__.py @@ -94,6 +94,10 @@ def _get_histories( update_time_min: Optional[str] = None, update_time_max: Optional[str] = None, all: Optional[bool] = False, + view: Optional[Literal["summary", "detailed"]] = None, + keys: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, ) -> List[Dict[str, Any]]: """ Hidden method to be used by both get_histories() and get_published_histories() @@ -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) @@ -144,6 +156,10 @@ def get_histories( update_time_min: Optional[str] = None, update_time_max: Optional[str] = None, all: Optional[bool] = False, + view: Optional[Literal["summary", "detailed"]] = None, + keys: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, ) -> List[Dict[str, Any]]: """ Get all histories, or select a subset by specifying optional arguments @@ -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, @@ -282,6 +316,7 @@ def show_history( visible: Optional[bool] = None, details: Optional[str] = None, types: Optional[List[str]] = None, + keys: Optional[List[str]] = None, ) -> List[Dict[str, Any]]: ... # Fallback in case the caller provides a regular bool as contents @@ -294,6 +329,7 @@ def show_history( visible: Optional[bool] = None, details: Optional[str] = None, types: Optional[List[str]] = None, + keys: Optional[List[str]] = None, ) -> Union[Dict[str, Any], List[Dict[str, Any]]]: pass @@ -305,6 +341,7 @@ def show_history( visible: Optional[bool] = None, details: Optional[str] = None, types: Optional[List[str]] = None, + keys: Optional[List[str]] = None, ) -> Union[Dict[str, Any], List[Dict[str, Any]]]: """ Get details of a given history. By default, just get the history meta @@ -340,6 +377,9 @@ def show_history( ``['dataset_collection']``, return only dataset collections. If not set, no filtering is applied. + :type keys: List[str] + :param keys: List of fields to return + :rtype: dict or list of dicts :return: details of the given history or list of dataset info @@ -359,6 +399,8 @@ def show_history( params["visible"] = visible if types is not None: params["types"] = types + if keys: + params["keys"] = ",".join(keys) return self._get(id=history_id, contents=contents, params=params) def delete_dataset(self, history_id: str, dataset_id: str, purge: bool = False) -> None: