Skip to content

Commit

Permalink
minor updates to portal_utilss for internal use
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Nov 8, 2024
1 parent 2a8f384 commit 29a7b1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions dcicutils/portal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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 "")
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 29a7b1b

Please sign in to comment.