We'd like to have a consistent and safe way for study designers (almost always the implementers, so people with the DEVELOPER role) to delete and remove things as they set up a study. Often our delete APIs remove things from the database, and so those calls are only accessible to administrators for test clean-up.

Here's how we'll support both through our rest API:

class Apple

boolean deleted - this flag should be part of the public API of the object.

GET /apples?includeDeleted=boolean

Tests

GET /apples/id

Tests

POST /apples

POST /apples/id

Tests

DELETE /apples/id or DELETE /apples?id=x

Tests

DELETE /applies/id?physical=true or DELETE /apples?id=x&physical=true

Tests

Dependent Objects

Objects that cannot be deleted because they would leave other objects with referential integrity problems:

Tests

NameWhat we should test
getAppleIncludesLogicallyDeletedThe get apple call returns logically deleted apples
getApplesIncludes/ExcludesLogicallyDeletedThe apple collection calls include or exclude logically deleted apples based on the flag
createAppleCannotBeDeletedCreating an apple with deleted=true just creates the apple with deleted=false
updateLogicallyDeletedAppleThrowsCannot update if saved and updated apple are both deleted=true
updateCanUndeleteApplesaved apple deleted=true, updated apple deleted=false works
updateCanDeleteApplesaved apple deleted=false, updated apple deleted=true works (no reason to prevent it)
deleteLogicallyDeletedAppleThrowsCannot delete an apple that is already deleted
deleteAppleCan logically delete an apple
deleteAppleMissingAppleThrowsTrying to logically delete a logically deleted apple throws
deleteApplePermanentlyCan permanently delete an apple
deletePermanentlyLogicallyDeletedAppleCan physically delete an apple that is logically deleted (rather than getting a 404)
deletePermanentlyMissingAppleThrows
includeDeletedInRequestParamsRequests that take this parameter should return the value in the request params
physicalInRequestParamsRequests that take this parameter should return the value in the request params