From e6127f8440304428681556bdd98988b5199b4720 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Thu, 30 May 2024 07:55:21 -0400 Subject: [PATCH] added portal_utils.Portal.delete/purge_metadata, for update-portal-object utility script --- dcicutils/portal_utils.py | 16 +++++++++++++++- pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index 005eb400a..daf5264b4 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -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 @@ -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") diff --git a/pyproject.toml b/pyproject.toml index 1a63902a0..1c0bd9c84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT"