I'm in the process of designing an HTTP API, hopefully making it as RESTful as possible.
There are some actions which functionality spreads over a few resources, and sometime needs to be undone.
I thought to myself, this sounds like a command pattern, but how can I model it into a resource?
I will introduce a new resource named XXAction, like DepositAction, which will be created through something like this
POST /card/{card-id}/account/{account-id}/Deposit
AmountToDeposit=100, different parameters...
this will actually create a new DepositAction and activate it's Do/Execute method. In this case, returning a 201 Created HTTP status means the action has been executed successfully.
Later if a client wishes to look at the action details he can
GET /action/{action-id}
Update/PUT should be blocked I guess, because it is not relevant here.
And in order to Undo the action, I thought of using
DELETE /action/{action-id}
which will actually call the Undo method of the relevant object, and change it's status.
Let's say I'm happy with only one Do-Undo, I don't need to Redo.
Is this approach ok?
Are there any pitfalls, reasons not to use it?
Is this understood from the POV of the clients?