diff options
author | Giuseppe Lavagetto <lavagetto@gmail.com> | 2014-03-15 00:33:23 +0100 |
---|---|---|
committer | Giuseppe Lavagetto <lavagetto@gmail.com> | 2014-03-15 00:33:23 +0100 |
commit | 2efc46bcccb5240f517b40621fb94d2cf4255013 (patch) | |
tree | 0f82a73dd84f0c5b7b10214793a5d2f4458e814d /src | |
parent | 761301c8137480f32a4668b7534a3141f3853835 (diff) |
Adding the atomic delete parameters support
Diffstat (limited to 'src')
-rw-r--r-- | src/etcd/client.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/etcd/client.py b/src/etcd/client.py index 4dc9fa1..ada1568 100644 --- a/src/etcd/client.py +++ b/src/etcd/client.py @@ -25,7 +25,7 @@ class Client(object): _MDELETE = 'DELETE' _comparison_conditions = ['prevValue', 'prevIndex', 'prevExist'] _read_options = ['recursive', 'wait', 'waitIndex', 'sorted', 'consistent'] - + _del_conditions = ['prevValue', 'prevIndex'] def __init__( self, host='127.0.0.1', @@ -316,15 +316,22 @@ class Client(object): self.key_endpoint + key, self._MGET, params=params, timeout=timeout) return self._result_from_response(response) - def delete(self, key, recursive=None, dir=None): + def delete(self, key, recursive=None, dir=None, **kwdargs): """ Removed a key from etcd. Args: + key (str): Key. + recursive (bool): if we want to recursively delete a directory, set it to true + dir (bool): if we want to delete a directory, set it to true + prevValue (str): compare key to this value, and swap only if corresponding (optional). + + prevIndex (int): modify key only if actual modifiedIndex matches the provided one (optional). + Returns: client.EtcdResult @@ -343,6 +350,10 @@ class Client(object): if dir is not None: kwds['dir'] = dir and "true" or "false" + for key in self._del_conditions: + if key in kwdargs: + kwds[key] = kwdargs[key] + response = self.api_execute( self.key_endpoint + key, self._MDELETE, kwds) return self._result_from_response(response) |