coreos/etcd — pull request #136 by emilisto (2013-08-20 21:04:21+00:00)
Title: Delete directories

I've modified the DELETE command to support deletion of an directory and all keys under it.

Example:

```
$ curl -L http://127.0.0.1:4001/v1/keys/deep/down/thehole/queen -d value="Headchopper" -d ttl=60
$ curl -L http://127.0.0.1:4001/v1/keys/deep/down/thehole/caterpillar -d value="Hookasmoker"
$ curl -L http://127.0.0.1:4001/v1/keys/deep/down/thehole/logicandproportion -d value="Deadfallen"
$ curl -L http://127.0.0.1:4001/v1/keys | python -m json.tool
[
{
"action": "GET",
"dir": true,
"index": 8,
"key": "/_etcd"
},
{
"action": "GET",
"dir": true,
"index": 8,
"key": "/deep"
}
]
# Delete the whole /deep directory and all keys under it
$ curl -L http://127.0.0.1:4001/v1/keys/deep -X DELETE
{
"action": "DELETE",
"index": 13,
"key": "/deep"
}
$ curl -L http://127.0.0.1:4001/v1/keys | python -m json.tool
[
{
"action": "GET",
"dir": true,
"index": 5,
"key": "/_etcd"
}
]
```

This also solves @tobstarr's issue #115 — since the Tree.delete function `emptyNode`'s now accepts keys that point to directories. In the example above, if we had deleted `/deep/down` first, `/deep` would remain, but issuing a delete on it would delete it instead of saying _Key not found_.

I'm a bit unsure about the response to the delete command: should we still return a `prevValue` in the response, and if so, what should that be?