Ping endpoint

This commit is contained in:
Honza Kral
2013-07-12 17:25:06 +02:00
parent 4427624766
commit 66561136c2
+10 -1
View File
@@ -1,5 +1,5 @@
from ..transport import Transport
from ..exceptions import NotFoundError
from ..exceptions import NotFoundError, TransportError
from .indices import IndicesClient
from .cluster import ClusterClient
from .utils import query_params, _make_path
@@ -56,6 +56,15 @@ class Elasticsearch(object):
self.indices = IndicesClient(self)
self.cluster = ClusterClient(self)
@query_params()
def ping(self, params=None):
""" Returns True if the cluster is up, False otherwise. """
try:
self.transport.perform_request('HEAD', _make_path(), params=params)
except TransportError:
return False
return True
@query_params()
def info(self, params=None):
""" Get the basic info from the current cluster. """