Metadata-Version: 2.0
Name: etcd3-py
Version: 0.1.2
Summary: Python client for etcd v3 (Using gRPC-JSON-Gateway)
Home-page: https://github.com/revolution1/etcd3-py
Author: Renjie Cai
Author-email: revol.cai@gmail.com
License: Apache Software License 2.0
Keywords: etcd3
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Requires-Python: >=2.7
Requires-Dist: enum34 (>=1.1.6)
Requires-Dist: six (>=1.11.0)
Requires-Dist: requests (>=2.10.0)
Requires-Dist: semantic-version (>=2.6.0)
Requires-Dist: aiohttp; python_version >= "3.5"

etcd3-py
========


.. image:: https://img.shields.io/pypi/v/etcd3-py.svg
   :target: https://pypi.python.org/pypi/etcd3-py
   :alt: pypi


.. image:: https://travis-ci.org/Revolution1/etcd3-py.svg?branch=master
   :target: https://travis-ci.org/Revolution1/etcd3-py
   :alt: travis


.. image:: https://codecov.io/gh/Revolution1/etcd3-py/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/Revolution1/etcd3-py
   :alt: codecov


.. image:: https://readthedocs.org/projects/etcd3-py/badge/?version=latest
   :target: http://etcd3-py.readthedocs.io/en/latest/?badge=latest
   :alt: doc


.. image:: https://pyup.io/repos/github/Revolution1/etcd3-py/shield.svg
   :target: https://pyup.io/repos/github/Revolution1/etcd3-py/
   :alt: updates


.. image:: https://pyup.io/repos/github/Revolution1/etcd3-py/python-3-shield.svg
   :target: https://pyup.io/repos/github/Revolution1/etcd3-py/
   :alt: python3


Python client for etcd v3 (Using gRPC-JSON-Gateway)


* Free software: Apache Software License 2.0
* Source Code: https://github.com/Revolution1/etcd3-py
* Documentation: https://etcd3-py.readthedocs.io.

Notice: The authentication header through gRPC-JSON-Gateway only supported in `etcd v3.3+ <https://github.com/coreos/etcd/pull/7999>`_

Features
--------


* [x] Support python2.7 and python3.5+
* [x] Sync client based on requests
* [x] Async client based on aiohttp
* [x] Support etcd3 gRPC-JSON-Gateway including stream
* [x] Response modelizing based on etcd3's swagger spec
* [x] Generate code from swagger spec
* [ ] TLS Connection
* [x] support APIs

  * [x] Auth
  * [x] KV
  * [x] Watch
  * [x] Cluster
  * [x] Lease
  * [x] Maintenance
  * [x] Extra APIs

* [ ] stateful utilities

  * [x] Watch
  * [x] Lease
  * [x] Transaction
  * [ ] Lock

Quick Start
-----------

**Install**

.. code-block:: bash

   $ pip install etcd3-py

----

**Sync Client**

.. code-block:: python

   >>> from etcd3 import Client
   >>> client = Client('127.0.0.1', 2379)
   >>> client.version()
   EtcdVersion(etcdserver='3.3.0-rc.4', etcdcluster='3.3.0')
   >>> client.put('foo', 'bar')
   etcdserverpbPutResponse(header=etcdserverpbResponseHeader(cluster_id=11588568905070377092, member_id=128088275939295631, revision=15433, raft_term=4))
   >>> client.range('foo').kvs
   [mvccpbKeyValue(key=b'foo', create_revision=15429, mod_revision=15433, version=5, value=b'bar')]

**Async Client (Python3.5+)**

.. code-block:: python

   >>> import asyncio
   >>> from etcd3 import AioClient
   >>> client = AioClient('127.0.0.1', 2379)
   >>> async def getFoo():
   ...     await client.put('foo', 'bar')
   ...     r = await client.range('foo')
   ...     print('key:', r.kvs[0].key, 'value:', r.kvs[0].value)
   >>> loop = asyncio.get_event_loop()
   >>> loop.run_until_complete(getFoo())
   key: b'foo' value: b'bar'

**Transaction Util**

.. code-block:: python

   >>> from etcd3 import Client
   >>> txn = Client().Txn()
   >>> txn.compare(txn.key('foo').value == 'bar')
   >>> txn.success(txn.put('foo', 'bra'))
   >>> txn.commit()
   etcdserverpbTxnResponse(header=etcdserverpbResponseHeader(cluster_id=11588568905070377092, member_id=128088275939295631, revision=15656, raft_term=4), succeeded=True, responses=[etcdserverpbResponseOp(response_put=etcdserverpbPutResponse(header=etcdserverpbResponseHeader(revision=15656)))])

**Lease Util**

.. code-block:: python

   >>> from etcd3 import Client
   >>> client = Client()
   >>> with client.Lease(ttl=5) as lease:
   ...     client.put('foo', 'bar', lease=lease.ID)
   ...     client.put('fizz', 'buzz', lease=lease.ID)
   ...     r = lease.time_to_live(keys=True)
   ...     assert set(r.keys) == {b'foo', b'fizz'}
   ...     assert lease.alive()

**Watch Util**

.. code-block:: python

   >>> from etcd3 import Client
   >>> client = Client()
   >>> watcher=c.Watcher(all=True, progress_notify=True, prev_kv=True)
   >>> w.onEvent('f.*', lambda e: print(e.key, e.value))
   >>> w.runDaemon()
   >>> # etcdctl put foo bar
   >>> # etcdctl put foz bar
   b'foo' b'bar'
   b'foz' b'bar'
   >>> w.stop()

TODO
----


* [ ] benchmark
* [ ] python-etcd(etcd v2) compatible client
* [ ] etcd browser



=======
History
=======

0.0.1 (2018-01-26)
------------------

* First release on PyPI.


