From 0eafdab2e88dd6f8ef12f044759da17933dcc77c Mon Sep 17 00:00:00 2001 From: Honza Kral Date: Sat, 1 Jun 2013 16:59:07 +0200 Subject: [PATCH] Added namespacing to the client --- elasticsearch/client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/elasticsearch/client.py b/elasticsearch/client.py index 89de0f94..0dd85e54 100644 --- a/elasticsearch/client.py +++ b/elasticsearch/client.py @@ -64,6 +64,20 @@ def query_params(*es_query_params): return _wrapper +class NamespacedClient(object): + def __init__(self, client): + self.client = client + + @property + def transport(self): + return self.client.transport + +class ClusterClient(NamespacedClient): + pass + +class InidicesClient(NamespacedClient): + pass + class Elasticsearch(object): """ Elasticsearch low-level client. Provides a straightforward mapping from @@ -84,4 +98,7 @@ class Elasticsearch(object): """ self.transport = Transport(_normalize_hosts(hosts), **kwargs) + # namespaced clients for compatibility with API names + self.indices = InidicesClient(self) + self.cluster = ClusterClient(self)