Add local params and other minor api fixes

This commit is contained in:
Honza Král
2014-01-20 18:51:19 +01:00
parent 705d5d75cc
commit 8a18ef67f5
4 changed files with 40 additions and 14 deletions
+1 -1
View File
@@ -577,7 +577,7 @@ class Elasticsearch(object):
return data return data
@query_params('ignore_indices', 'preference', 'routing', 'source') @query_params('ignore_indices', 'preference', 'routing', 'source')
def suggest(self, index=None, body=None, params=None): def suggest(self, body, index=None, params=None):
""" """
The suggest feature suggests similar looking terms based on a provided The suggest feature suggests similar looking terms based on a provided
text by using a suggester. text by using a suggester.
+4 -1
View File
@@ -23,13 +23,16 @@ class ClusterClient(NamespacedClient):
params=params) params=params)
return data return data
@query_params() @query_params('local', 'master_timeout')
def pending_tasks(self, params=None): def pending_tasks(self, params=None):
""" """
The pending cluster tasks API returns a list of any cluster-level The pending cluster tasks API returns a list of any cluster-level
changes (e.g. create index, update mapping, allocate or fail shard) changes (e.g. create index, update mapping, allocate or fail shard)
which have not yet been executed. which have not yet been executed.
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-pending.html>`_ `<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-pending.html>`_
:arg local: Return local information, do not retrieve the state from master node (default: false)
:arg master_timeout: Specify timeout for connection to master
""" """
_, data = self.transport.perform_request('GET', '/_cluster/pending_tasks', _, data = self.transport.perform_request('GET', '/_cluster/pending_tasks',
params=params) params=params)
+32 -11
View File
@@ -117,13 +117,14 @@ class IndicesClient(NamespacedClient):
return data return data
@query_params('timeout', 'master_timeout') @query_params('timeout', 'master_timeout')
def close(self, index=None, params=None): def close(self, index, params=None):
""" """
Close an index to remove it's overhead from the cluster. Closed index Close an index to remove it's overhead from the cluster. Closed index
is blocked for read/write operations. is blocked for read/write operations.
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>`_ `<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>`_
:arg index: The name of the index :arg index: A comma-separated list of indices to delete; use `_all` or
'*' to delete all indices
:arg master_timeout: Specify timeout for connection to master :arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout :arg timeout: Explicit operation timeout
""" """
@@ -146,13 +147,15 @@ class IndicesClient(NamespacedClient):
params=params) params=params)
return data return data
@query_params() @query_params('local')
def exists(self, index, params=None): def exists(self, index, params=None):
""" """
Return a boolean indicating whether given index exists. Return a boolean indicating whether given index exists.
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-indices-exists.html>`_ `<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-indices-exists.html>`_
:arg index: A list of indices to check :arg index: A list of indices to check
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
try: try:
self.transport.perform_request('HEAD', _make_path(index), params=params) self.transport.perform_request('HEAD', _make_path(index), params=params)
@@ -160,7 +163,8 @@ class IndicesClient(NamespacedClient):
return False return False
return True return True
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable') @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable',
'local')
def exists_type(self, index, doc_type, params=None): def exists_type(self, index, doc_type, params=None):
""" """
Check if a type/types exists in an index/indices. Check if a type/types exists in an index/indices.
@@ -178,6 +182,8 @@ class IndicesClient(NamespacedClient):
ignore `missing` ones (default: none) ignore `missing` ones (default: none)
:arg ignore_unavailable: Whether specified concrete indices should be ignored :arg ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed) when unavailable (missing or closed)
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
try: try:
self.transport.perform_request('HEAD', _make_path(index, doc_type), params=params) self.transport.perform_request('HEAD', _make_path(index, doc_type), params=params)
@@ -312,7 +318,8 @@ class IndicesClient(NamespacedClient):
params=params, body=body) params=params, body=body)
return data return data
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable') @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable',
'local')
def exists_alias(self, name, index=None, params=None): def exists_alias(self, name, index=None, params=None):
""" """
Return a boolean indicating whether given alias exists. Return a boolean indicating whether given alias exists.
@@ -329,6 +336,8 @@ class IndicesClient(NamespacedClient):
ignore `missing` ones (default: none) ignore `missing` ones (default: none)
:arg ignore_unavailable: Whether specified concrete indices should be ignored :arg ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed) when unavailable (missing or closed)
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
try: try:
self.transport.perform_request('HEAD', _make_path(index, '_alias', name), self.transport.perform_request('HEAD', _make_path(index, '_alias', name),
@@ -337,7 +346,7 @@ class IndicesClient(NamespacedClient):
return False return False
return True return True
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable') @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable', 'local')
def get_alias(self, index=None, name=None, params=None): def get_alias(self, index=None, name=None, params=None):
""" """
Retrieve a specified alias. Retrieve a specified alias.
@@ -354,12 +363,14 @@ class IndicesClient(NamespacedClient):
ignore `missing` ones, default u'none' ignore `missing` ones, default u'none'
:arg ignore_unavailable: Whether specified concrete indices should be ignored :arg ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed) when unavailable (missing or closed)
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
_, data = self.transport.perform_request('GET', _make_path(index, '_alias', name), _, data = self.transport.perform_request('GET', _make_path(index, '_alias', name),
params=params) params=params)
return data return data
@query_params('timeout') @query_params('local', 'timeout')
def get_aliases(self, index=None, name=None, params=None): def get_aliases(self, index=None, name=None, params=None):
""" """
Retrieve specified aliases Retrieve specified aliases
@@ -367,6 +378,8 @@ class IndicesClient(NamespacedClient):
:arg index: A comma-separated list of index names to filter aliases :arg index: A comma-separated list of index names to filter aliases
:arg name: A comma-separated list of alias names to filter :arg name: A comma-separated list of alias names to filter
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg timeout: Explicit operation timeout :arg timeout: Explicit operation timeout
""" """
_, data = self.transport.perform_request('GET', _make_path(index, '_aliases', name), _, data = self.transport.perform_request('GET', _make_path(index, '_aliases', name),
@@ -423,13 +436,15 @@ class IndicesClient(NamespacedClient):
params=params, body=body) params=params, body=body)
return data return data
@query_params() @query_params('local')
def exists_template(self, name, params=None): def exists_template(self, name, params=None):
""" """
Return a boolean indicating whether given template exists. Return a boolean indicating whether given template exists.
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>`_ `<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html>`_
:arg name: The name of the template :arg name: The name of the template
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
try: try:
self.transport.perform_request('HEAD', _make_path('_template', name), self.transport.perform_request('HEAD', _make_path('_template', name),
@@ -438,7 +453,7 @@ class IndicesClient(NamespacedClient):
return False return False
return True return True
@query_params('flat_settings') @query_params('flat_settings', 'local')
def get_template(self, name=None, params=None): def get_template(self, name=None, params=None):
""" """
Retrieve an index template by its name. Retrieve an index template by its name.
@@ -446,6 +461,8 @@ class IndicesClient(NamespacedClient):
:arg name: The name of the template :arg name: The name of the template
:arg flat_settings: Return settings in flat format (default: false) :arg flat_settings: Return settings in flat format (default: false)
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
_, data = self.transport.perform_request('GET', _make_path('_template', name), _, data = self.transport.perform_request('GET', _make_path('_template', name),
params=params) params=params)
@@ -465,7 +482,7 @@ class IndicesClient(NamespacedClient):
params=params) params=params)
return data return data
@query_params('flat_settings') @query_params('flat_settings', 'local')
def get_settings(self, index=None, name=None, params=None): def get_settings(self, index=None, name=None, params=None):
""" """
Retrieve settings for one or more (or all) indices. Retrieve settings for one or more (or all) indices.
@@ -475,6 +492,8 @@ class IndicesClient(NamespacedClient):
string to perform the operation on all indices string to perform the operation on all indices
:arg name: The name of the settings that should be included :arg name: The name of the settings that should be included
:arg flat_settings: Return settings in flat format (default: false) :arg flat_settings: Return settings in flat format (default: false)
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
_, data = self.transport.perform_request('GET', _make_path(index, '_settings', name), _, data = self.transport.perform_request('GET', _make_path(index, '_settings', name),
params=params) params=params)
@@ -517,7 +536,7 @@ class IndicesClient(NamespacedClient):
params=params, body=body) params=params, body=body)
return data return data
@query_params() @query_params('local')
def get_warmer(self, index=None, doc_type=None, name=None, params=None): def get_warmer(self, index=None, doc_type=None, name=None, params=None):
""" """
Retreieve an index warmer. Retreieve an index warmer.
@@ -528,6 +547,8 @@ class IndicesClient(NamespacedClient):
:arg doc_type: A comma-separated list of document types to restrict the :arg doc_type: A comma-separated list of document types to restrict the
operation; leave empty to perform the operation on all types operation; leave empty to perform the operation on all types
:arg name: The name of the warmer (supports wildcards); leave empty to get all warmers :arg name: The name of the warmer (supports wildcards); leave empty to get all warmers
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
_, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_warmer', name), params=params) _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_warmer', name), params=params)
return data return data
+3 -1
View File
@@ -64,7 +64,7 @@ class SnapshotClient(NamespacedClient):
_make_path('_snapshot', repository), params=params) _make_path('_snapshot', repository), params=params)
return data return data
@query_params('master_timeout') @query_params('local', 'master_timeout')
def get_repository(self, repository=None, params=None): def get_repository(self, repository=None, params=None):
""" """
Return information about registered repositories. Return information about registered repositories.
@@ -73,6 +73,8 @@ class SnapshotClient(NamespacedClient):
:arg repository: A comma-separated list of repository names :arg repository: A comma-separated list of repository names
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg local: Return local information, do not retrieve the state from
master node (default: false)
""" """
_, data = self.transport.perform_request('GET', _make_path('_snapshot', _, data = self.transport.perform_request('GET', _make_path('_snapshot',
repository), params=params) repository), params=params)