mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 12:52:13 +00:00
feat(ingest/cli): add undo soft delete command (#11740)
This commit is contained in:
parent
95f361ab44
commit
1f02c84480
@ -213,6 +213,17 @@ def references(urn: str, dry_run: bool, force: bool) -> None:
|
|||||||
logger.info(f"Deleted {references_count} references to {urn}")
|
logger.info(f"Deleted {references_count} references to {urn}")
|
||||||
|
|
||||||
|
|
||||||
|
@delete.command()
|
||||||
|
@click.option("--urn", required=True, type=str, help="the urn of the entity")
|
||||||
|
def undo_by_filter(urn: str) -> None:
|
||||||
|
"""
|
||||||
|
Undo a soft deletion of an entity
|
||||||
|
"""
|
||||||
|
graph = get_default_graph()
|
||||||
|
logger.info(f"Using {graph}")
|
||||||
|
graph.set_soft_delete_status(urn=urn, delete=False)
|
||||||
|
|
||||||
|
|
||||||
@delete.command(no_args_is_help=True)
|
@delete.command(no_args_is_help=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--urn",
|
"--urn",
|
||||||
|
@ -1241,14 +1241,29 @@ class DataHubGraph(DatahubRestEmitter):
|
|||||||
Args:
|
Args:
|
||||||
urn: The urn of the entity to soft-delete.
|
urn: The urn of the entity to soft-delete.
|
||||||
"""
|
"""
|
||||||
|
self.set_soft_delete_status(
|
||||||
|
urn=urn, run_id=run_id, deletion_timestamp=deletion_timestamp, delete=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_soft_delete_status(
|
||||||
|
self,
|
||||||
|
urn: str,
|
||||||
|
delete: bool,
|
||||||
|
run_id: str = _GRAPH_DUMMY_RUN_ID,
|
||||||
|
deletion_timestamp: Optional[int] = None,
|
||||||
|
) -> None:
|
||||||
|
"""Change status of soft-delete an entity by urn.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
urn: The urn of the entity to soft-delete.
|
||||||
|
"""
|
||||||
assert urn
|
assert urn
|
||||||
|
|
||||||
deletion_timestamp = deletion_timestamp or int(time.time() * 1000)
|
deletion_timestamp = deletion_timestamp or int(time.time() * 1000)
|
||||||
self.emit(
|
self.emit(
|
||||||
MetadataChangeProposalWrapper(
|
MetadataChangeProposalWrapper(
|
||||||
entityUrn=urn,
|
entityUrn=urn,
|
||||||
aspect=StatusClass(removed=True),
|
aspect=StatusClass(removed=delete),
|
||||||
systemMetadata=SystemMetadataClass(
|
systemMetadata=SystemMetadataClass(
|
||||||
runId=run_id, lastObserved=deletion_timestamp
|
runId=run_id, lastObserved=deletion_timestamp
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user