Skip to content

DeletionOperations

Access via client.deletions. Anyone who may request deletion of a record files a request with a reason; platform administrators review it. delete() removes a record directly and is for administrators only.

request = client.deletions.request(dataset_mfid, reason="Superseded dataset")
client.deletions.get(request["id"])

crucible.resources.deletion.DeletionOperations

Operations for the soft-deletion approval workflow.

request(resource_mfid, reason=None)

Submit a deletion request for a dataset or sample.

The resource is immediately hidden from list results (status: pending) until an admin approves or rejects the request.

Parameters:

Name Type Description Default
resource_mfid str

The unique_id (MFID) of the dataset or sample to delete.

required
reason Optional[str]

Optional explanation for why deletion is requested.

None

Returns:

Name Type Description
Dict Dict

The created DeletionRequest record.

list(status=None, limit=DEFAULT_LIMIT, offset=0, scope=None, project_mfid=None, sort=None, direction=None, cursor=None)

List deletion requests.

Parameters:

Name Type Description Default
status Optional[str]

Filter by status — "pending", "approved", or "rejected". Omit to return all requests.

None
limit int

Maximum number of results to return (default: 100)

DEFAULT_LIMIT
offset int

Starting position in the full result set (default: 0)

0
cursor str

Continuation token from a previous result's next_cursor; the listing resumes there.

None
scope Optional[str]

One of crucible.constants.DELETION_REQUEST_SCOPES. The server defaults to "accessible"; "submitted" returns only the caller's own requests and "reviewable" only those the caller may act on.

None
project_mfid Optional[str]

Limit to resources assigned to this project MFID.

None
sort Optional[str]

One of crucible.constants.DELETION_REQUEST_SORTS.

None
direction Optional[str]

"asc" or "desc".

None

Returns:

Type Description
List[Dict]

List[Dict]: Matching DeletionRequest records.

get(request_id)

Fetch a single deletion request by ID. Admin only.

Parameters:

Name Type Description Default
request_id int

Integer ID of the DeletionRequest row.

required

Returns:

Name Type Description
Dict Dict

The DeletionRequest record.

approve(request_id, reviewer_notes=None)

Approve a pending deletion request. Admin only.

The resource will remain hidden (deletion_status: approved).

Parameters:

Name Type Description Default
request_id int

Integer ID of the DeletionRequest to approve.

required
reviewer_notes Optional[str]

Optional notes explaining the decision.

None

Returns:

Name Type Description
Dict Dict

The updated DeletionRequest record.

reject(request_id, reviewer_notes=None)

Reject a pending deletion request. Admin only.

The resource is restored to active (deletion_status set back to None).

Parameters:

Name Type Description Default
request_id int

Integer ID of the DeletionRequest to reject.

required
reviewer_notes Optional[str]

Optional notes explaining the decision.

None

Returns:

Name Type Description
Dict Dict

The updated DeletionRequest record.

list_deleted(resource_mfid=None, requester_id=None, reviewer_id=None, limit=DEFAULT_LIMIT, scope=None, project_id=None, project_mfid=None, direction=None, offset=0, cursor=None)

List hard-deletion audit log entries.

Returns a permanent record of every resource that was hard-deleted, ordered by deletion time descending. Audit entries survive even after the original DeletionRequest and Resource rows are gone.

Parameters:

Name Type Description Default
resource_mfid Optional[str]

Filter by resource MFID.

None
requester_id Optional[str]

Filter by the ORCID of who requested deletion.

None
reviewer_id Optional[str]

Filter by the ORCID of who approved deletion.

None
limit int

Maximum number of results.

DEFAULT_LIMIT
offset int

Starting position in the full result set (default: 0).

0
cursor Optional[str]

Continuation token from a previous result's next_cursor; the listing resumes there.

None
scope Optional[str]

One of crucible.constants.DELETION_AUDIT_SCOPES. Defaults to "all" (the platform-wide administrator audit) for callers who can elevate and "submitted" (the caller's own deletions) for everyone else.

None
project_id Optional[str]

Project slug captured at deletion time.

None
project_mfid Optional[str]

Project MFID captured at deletion time. Entries predating project MFID snapshots will not match.

None
direction Optional[str]

"asc" or "desc" on deletion time.

None

Returns:

Type Description
List[Dict]

List[Dict]: DeletionAuditLog records.

get_deleted(audit_id)

Get a single hard-deletion audit log entry by ID. Admin only.

Parameters:

Name Type Description Default
audit_id int

Integer primary key of the audit log entry.

required

Returns:

Name Type Description
Dict Dict

DeletionAuditLog record.

Raises:

Type Description
HTTPError 404

Audit entry not found.

delete(resource_mfid, force=False)

Permanently delete a resource. Admin only.

By default requires an existing approved deletion request (409 if none). Use force=True to bypass the workflow and hard-delete immediately.

Parameters:

Name Type Description Default
resource_mfid str

MFID of the dataset or sample to permanently delete.

required
force bool

If True, skip the deletion request check and delete immediately.

False

Returns:

Name Type Description
Dict Dict

{"detail": "Resource {id} permanently deleted"}

Raises:

Type Description
HTTPError 409

No approved deletion request exists (only when force=False).

HTTPError 404

Resource not found.