Skip to content

Commit

Permalink
added portal_utils.Portal.delete/purge_metadata, for update-portal-ob…
Browse files Browse the repository at this point in the history
…ject utility script
  • Loading branch information
dmichaels-harvard committed May 30, 2024
1 parent f43932a commit e6127f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion dcicutils/portal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from webtest.app import TestApp, TestResponse
from wsgiref.simple_server import make_server as wsgi_make_server
from dcicutils.common import APP_SMAHT, OrchestratedApp, ORCHESTRATED_APPS
from dcicutils.ff_utils import get_metadata, get_schema, patch_metadata, post_metadata
from dcicutils.ff_utils import delete_metadata, get_metadata, get_schema, patch_metadata, post_metadata, purge_metadata
from dcicutils.misc_utils import to_camel_case, VirtualApp
from dcicutils.schema_utils import get_identifying_properties
from dcicutils.tmpfile_utils import temporary_file
Expand Down Expand Up @@ -280,6 +280,20 @@ def post_metadata(self, object_type: str, data: dict, check_only: bool = False)
add_on="check_only=True" if check_only else "")
return self.post(f"/{object_type}{'?check_only=True' if check_only else ''}", data).json()

def delete_metadata(self, object_id: str) -> Optional[dict]:
if isinstance(object_id, str) and object_id:
if self.key:
return delete_metadata(obj_id=object_id, key=self.key)
else:
return self.patch_metadata(object_id, {"status": "deleted"})
return None

def purge_metadata(self, object_id: str) -> Optional[dict]:
if isinstance(object_id, str) and object_id:
if self.key:
return purge_metadata(obj_id=object_id, key=self.key)
return None

def get_health(self) -> OptionalResponse:
return self.get("/health")

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.9.0.1b1" # TODO: To become 8.10.0
version = "8.9.0.1b2" # TODO: To become 8.10.0
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 e6127f8

Please sign in to comment.