The etcd3gw.client
Module¶
-
class
etcd3gw.client.
Etcd3Client
(host='localhost', port=2379, protocol='http', ca_cert=None, cert_key=None, cert_cert=None, timeout=None)[source]¶ Bases:
object
-
create
(key, value)[source]¶ Atomically create the given key only if the key doesn’t exist.
This verifies that the create_revision of a key equales to 0, then creates the key with the value. This operation takes place in a transaction.
-
delete
(key, **kwargs)[source]¶ DeleteRange deletes the given range from the key-value store.
A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key.
- Parameters
key –
kwargs –
- Returns
-
get
(key, metadata=False, sort_order=None, sort_target=None, **kwargs)[source]¶ Range gets the keys in the range from the key-value store.
- Parameters
key –
metadata –
sort_order – ‘ascend’ or ‘descend’ or None
sort_target – ‘key’ or ‘version’ or ‘create’ or ‘mod’ or ‘value’
kwargs –
- Returns
-
get_all
(sort_order=None, sort_target='key')[source]¶ Get all keys currently stored in etcd.
- Returns
sequence of (value, metadata) tuples
-
get_prefix
(key_prefix, sort_order=None, sort_target=None)[source]¶ Get a range of keys with a prefix.
- Parameters
sort_order – ‘ascend’ or ‘descend’ or None
key_prefix – first key in range
- Returns
sequence of (value, metadata) tuples
-
get_url
(path)[source]¶ Construct a full url to the v3alpha API given a specific path
- Parameters
path –
- Returns
url
-
lease
(ttl=30)[source]¶ Create a Lease object given a timeout
- Parameters
ttl – timeout
- Returns
Lease object
-
lock
(id=None, ttl=30)[source]¶ Create a Lock object given an ID and timeout
- Parameters
id – ID for the lock, creates a new uuid if not provided
ttl – timeout
- Returns
Lock object
-
post
(*args, **kwargs)[source]¶ helper method for HTTP POST
- Parameters
args –
kwargs –
- Returns
json response
-
put
(key, value, lease=None)[source]¶ Put puts the given key into the key-value store.
A put request increments the revision of the key-value store and generates one event in the event history.
- Parameters
key –
value –
lease –
- Returns
boolean
-
replace
(key, initial_value, new_value)[source]¶ Atomically replace the value of a key with a new value.
This compares the current value of a key, then replaces it with a new value if it is equal to a specified value. This operation takes place in a transaction.
-
transaction
(txn)[source]¶ Txn processes multiple requests in a single transaction.
A txn request increments the revision of the key-value store and generates events with the same revision for every completed request. It is not allowed to modify the same key several times within one txn.
- Parameters
txn –
- Returns
-
watch
(key, **kwargs)[source]¶ Watch a key.
- Parameters
key – key to watch
- Returns
tuple of
events_iterator
andcancel
. Useevents_iterator
to get the events of key changes andcancel
to cancel the watch request
-
watch_once
(key, timeout=None, **kwargs)[source]¶ Watch a key and stops after the first event.
- Parameters
key – key to watch
timeout – (optional) timeout in seconds.
- Returns
event
-