From 29a7b1b4a3cb49bfcde1a79e60ae794cb857cdce Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 8 Nov 2024 06:27:51 -0500 Subject: [PATCH] minor updates to portal_utilss for internal use --- dcicutils/portal_utils.py | 16 ++++++++++++++-- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index 9d42c26e9..ce541ddb5 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -210,7 +210,8 @@ def vapp(self) -> Optional[TestApp]: def get(self, url: str, follow: bool = True, raw: bool = False, database: bool = False, - limit: Optional[int] = None, offset: Optional[int] = None, field: Optional[str] = None, + limit: Optional[int] = None, offset: Optional[int] = None, + field: Optional[str] = None, deleted: bool = False, raise_for_status: bool = False, **kwargs) -> OptionalResponse: url = self.url(url, raw, database) if isinstance(limit, int) and (limit >= 0): @@ -228,6 +229,11 @@ def get(self, url: str, follow: bool = True, url += f"&field={field}" else: url += f"?field={field}" + if deleted is True: + if "?" in url: + url += "&status=deleted" + else: + url += "?status=deleted" if not self.vapp: response = requests.get(url, allow_redirects=follow, **self._kwargs(**kwargs)) else: @@ -270,7 +276,8 @@ def post(self, url: str, data: Optional[dict] = None, json: Optional[dict] = Non return response def get_metadata(self, object_id: str, raw: bool = False, database: bool = False, - limit: Optional[int] = None, offset: Optional[int] = None, field: Optional[str] = None, + limit: Optional[int] = None, offset: Optional[int] = None, + field: Optional[str] = None, deleted: bool = False, raise_exception: bool = True) -> Optional[dict]: if isinstance(raw, bool) and raw: add_on = "frame=raw" + ("&datastore=database" if isinstance(database, bool) and database else "") @@ -293,6 +300,11 @@ def get_metadata(self, object_id: str, raw: bool = False, database: bool = False add_on += f"&field={field}" else: add_on += f"field={field}" + if deleted is True: + if add_on: + add_on += "&status=deleted" + else: + add_on += "status=deleted" if raise_exception: return get_metadata(obj_id=object_id, vapp=self.vapp, key=self.key, add_on=add_on) else: diff --git a/pyproject.toml b/pyproject.toml index 04122b38d..7189f1dd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.16.2.1b2" # TOOD: To become 8.16.3 +version = "8.16.2.1b3" # TOOD: To become 8.16.3 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"