From 38bb0aafbdc933a9a67dfb289850d27c36de5d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Tue, 8 Dec 2015 22:19:07 +0100 Subject: [PATCH] Have transport.perform_request only return data --- elasticsearch/client/__init__.py | 91 +++++++++------------------ elasticsearch/client/cat.py | 54 ++++++---------- elasticsearch/client/cluster.py | 21 +++---- elasticsearch/client/indices.py | 105 +++++++++++-------------------- elasticsearch/client/nodes.py | 10 +-- elasticsearch/client/snapshot.py | 28 +++------ elasticsearch/transport.py | 2 +- 7 files changed, 103 insertions(+), 208 deletions(-) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index b7275c93..84ea9455 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -216,8 +216,7 @@ class Elasticsearch(object): Get the basic info from the current cluster. ``_ """ - _, data = self.transport.perform_request('GET', '/', params=params) - return data + return self.transport.perform_request('GET', '/', params=params) @query_params('consistency', 'parent', 'refresh', 'routing', 'timeout', 'timestamp', 'ttl', 'version', 'version_type') @@ -275,9 +274,8 @@ class Elasticsearch(object): for param in (index, doc_type, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('POST' if id in SKIP_IN_PATH else 'PUT', + return self.transport.perform_request('POST' if id in SKIP_IN_PATH else 'PUT', _make_path(index, doc_type, id), params=params, body=body) - return data @query_params('parent', 'preference', 'realtime', 'refresh', 'routing') def exists(self, index, doc_type, id, params=None): @@ -342,9 +340,8 @@ class Elasticsearch(object): for param in (index, doc_type, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id), params=params) - return data @query_params('_source', '_source_exclude', '_source_include', 'parent', 'preference', 'realtime', 'refresh', 'routing', 'version', @@ -379,9 +376,8 @@ class Elasticsearch(object): for param in (index, doc_type, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id, '_source'), params=params) - return data @query_params('_source', '_source_exclude', '_source_include', 'fields', 'preference', 'realtime', 'refresh') @@ -411,9 +407,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_mget'), params=params, body=body) - return data @query_params('consistency', 'detect_noop', 'fields', 'lang', 'parent', 'refresh', 'retry_on_conflict', 'routing', 'script', 'script_id', @@ -456,9 +451,8 @@ class Elasticsearch(object): for param in (index, doc_type, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, doc_type, id, '_update'), params=params, body=body) - return data @query_params('_source', '_source_exclude', '_source_include', 'allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', @@ -544,9 +538,8 @@ class Elasticsearch(object): if doc_type and not index: index = '_all' - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_search'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local', 'preference', 'routing') @@ -575,9 +568,8 @@ class Elasticsearch(object): performed on (default: random) :arg routing: Specific routing value """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_search_shards'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'preference', 'routing', 'scroll', 'search_type') @@ -609,9 +601,8 @@ class Elasticsearch(object): 'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch', 'count', 'scan' """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_search', 'template'), params=params, body=body) - return data @query_params('_source', '_source_exclude', '_source_include', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'fields', @@ -654,9 +645,8 @@ class Elasticsearch(object): for param in (index, doc_type, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id, '_explain'), params=params, body=body) - return data @query_params('scroll') def scroll(self, scroll_id=None, body=None, params=None): @@ -676,9 +666,8 @@ class Elasticsearch(object): elif scroll_id: params['scroll_id'] = scroll_id - _, data = self.transport.perform_request('GET', '/_search/scroll', + return self.transport.perform_request('GET', '/_search/scroll', params=params, body=body) - return data @query_params() def clear_scroll(self, scroll_id=None, body=None, params=None): @@ -691,9 +680,8 @@ class Elasticsearch(object): :arg body: A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter """ - _, data = self.transport.perform_request('DELETE', _make_path('_search', + return self.transport.perform_request('DELETE', _make_path('_search', 'scroll', scroll_id), params=params, body=body) - return data @query_params('consistency', 'parent', 'refresh', 'routing', 'timeout', 'version', 'version_type') @@ -718,9 +706,8 @@ class Elasticsearch(object): for param in (index, doc_type, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', _make_path(index, + return self.transport.perform_request('DELETE', _make_path(index, doc_type, id), params=params) - return data @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', @@ -764,9 +751,8 @@ class Elasticsearch(object): if doc_type and not index: index = '_all' - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_count'), params=params, body=body) - return data @query_params('consistency', 'fields', 'refresh', 'routing', 'timeout') def bulk(self, body, index=None, doc_type=None, params=None): @@ -791,9 +777,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, doc_type, '_bulk'), params=params, body=self._bulk_body(body)) - return data @query_params('search_type') def msearch(self, body, index=None, doc_type=None, params=None): @@ -812,9 +797,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_msearch'), params=params, body=self._bulk_body(body)) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'preference', 'routing') @@ -842,9 +826,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_suggest'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'percolate_format', 'percolate_index', 'percolate_preference', @@ -892,9 +875,8 @@ class Elasticsearch(object): for param in (index, doc_type): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id, '_percolate'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable') def mpercolate(self, body, index=None, doc_type=None, params=None): @@ -921,9 +903,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_mpercolate'), params=params, body=self._bulk_body(body)) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'percolate_index', 'percolate_type', 'preference', 'routing', 'version', @@ -965,9 +946,8 @@ class Elasticsearch(object): for param in (index, doc_type): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id, '_percolate', 'count'), params=params, body=body) - return data @query_params('dfs', 'field_statistics', 'fields', 'offsets', 'parent', 'payloads', 'positions', 'preference', 'realtime', 'routing', @@ -1014,9 +994,8 @@ class Elasticsearch(object): for param in (index, doc_type): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, id, '_termvectors'), params=params, body=body) - return data @query_params('field_statistics', 'fields', 'ids', 'offsets', 'parent', 'payloads', 'positions', 'preference', 'realtime', 'routing', @@ -1067,9 +1046,8 @@ class Elasticsearch(object): :arg version_type: Specific version type, valid choices are: 'internal', 'external', 'external_gte', 'force' """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_mtermvectors'), params=params, body=body) - return data @query_params('op_type', 'version', 'version_type') def put_script(self, lang, id, body, params=None): @@ -1089,9 +1067,8 @@ class Elasticsearch(object): for param in (lang, id, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_scripts', + return self.transport.perform_request('PUT', _make_path('_scripts', lang, id), params=params, body=body) - return data @query_params('version', 'version_type') def get_script(self, lang, id, params=None): @@ -1108,9 +1085,8 @@ class Elasticsearch(object): for param in (lang, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path('_scripts', + return self.transport.perform_request('GET', _make_path('_scripts', lang, id), params=params) - return data @query_params('version', 'version_type') def delete_script(self, lang, id, params=None): @@ -1127,9 +1103,8 @@ class Elasticsearch(object): for param in (lang, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', + return self.transport.perform_request('DELETE', _make_path('_scripts', lang, id), params=params) - return data @query_params('op_type', 'version', 'version_type') def put_template(self, id, body, params=None): @@ -1148,9 +1123,8 @@ class Elasticsearch(object): for param in (id, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_search', + return self.transport.perform_request('PUT', _make_path('_search', 'template', id), params=params, body=body) - return data @query_params('version', 'version_type') def get_template(self, id, params=None): @@ -1165,9 +1139,8 @@ class Elasticsearch(object): """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - _, data = self.transport.perform_request('GET', _make_path('_search', + return self.transport.perform_request('GET', _make_path('_search', 'template', id), params=params) - return data @query_params('version', 'version_type') def delete_template(self, id, params=None): @@ -1182,9 +1155,8 @@ class Elasticsearch(object): """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - _, data = self.transport.perform_request('DELETE', _make_path('_search', + return self.transport.perform_request('DELETE', _make_path('_search', 'template', id), params=params) - return data @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', @@ -1261,9 +1233,8 @@ class Elasticsearch(object): level or on a cluster wide level, default 'cluster', valid choices are: 'indices', 'cluster' """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_field_stats'), params=params, body=body) - return data @query_params() def render_search_template(self, id=None, body=None, params=None): @@ -1273,7 +1244,5 @@ class Elasticsearch(object): :arg id: The id of the stored search template :arg body: The search definition template and its params """ - _, data = self.transport.perform_request('GET', _make_path('_render', + return self.transport.perform_request('GET', _make_path('_render', 'template', id), params=params, body=body) - return data - diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index 092ce300..d900c1b4 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -16,9 +16,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'aliases', name), params=params) - return data @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v') def allocation(self, node_id=None, params=None): @@ -39,9 +38,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'allocation', node_id), params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def count(self, index=None, params=None): @@ -60,9 +58,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'count', index), params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'ts', 'v') def health(self, params=None): @@ -80,9 +77,8 @@ class CatClient(NamespacedClient): :arg ts: Set to false to disable timestamping, default True :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/health', + return self.transport.perform_request('GET', '/_cat/health', params=params) - return data @query_params('help') def help(self, params=None): @@ -92,8 +88,7 @@ class CatClient(NamespacedClient): :arg help: Return help information, default False """ - _, data = self.transport.perform_request('GET', '/_cat', params=params) - return data + return self.transport.perform_request('GET', '/_cat', params=params) @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'pri', 'v') def indices(self, index=None, params=None): @@ -115,9 +110,8 @@ class CatClient(NamespacedClient): False :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'indices', index), params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def master(self, params=None): @@ -133,9 +127,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/master', + return self.transport.perform_request('GET', '/_cat/master', params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def nodes(self, params=None): @@ -151,9 +144,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/nodes', + return self.transport.perform_request('GET', '/_cat/nodes', params=params) - return data @query_params('bytes', 'h', 'help', 'master_timeout', 'v') def recovery(self, index=None, params=None): @@ -171,9 +163,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'recovery', index), params=params) - return data @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v') def shards(self, index=None, params=None): @@ -193,9 +184,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'shards', index), params=params) - return data @query_params('bytes', 'h', 'help', 'v') def segments(self, index=None, params=None): @@ -211,9 +201,8 @@ class CatClient(NamespacedClient): :arg help: Return help information, default False :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'segments', index), params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def pending_tasks(self, params=None): @@ -231,9 +220,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/pending_tasks', + return self.transport.perform_request('GET', '/_cat/pending_tasks', params=params) - return data @query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'v') def thread_pool(self, params=None): @@ -250,9 +238,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/thread_pool', + return self.transport.perform_request('GET', '/_cat/thread_pool', params=params) - return data @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v') def fielddata(self, fields=None, params=None): @@ -272,9 +259,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'fielddata', fields), params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def plugins(self, params=None): @@ -290,9 +276,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/plugins', + return self.transport.perform_request('GET', '/_cat/plugins', params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def nodeattrs(self, params=None): @@ -307,9 +292,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/nodeattrs', + return self.transport.perform_request('GET', '/_cat/nodeattrs', params=params) - return data @query_params('h', 'help', 'local', 'master_timeout', 'v') def repositories(self, params=None): @@ -324,9 +308,8 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', '/_cat/repositories', + return self.transport.perform_request('GET', '/_cat/repositories', params=params) - return data @query_params('h', 'help', 'master_timeout', 'v') def snapshots(self, repository=None, params=None): @@ -341,6 +324,5 @@ class CatClient(NamespacedClient): node :arg v: Verbose mode. Display column headers, default False """ - _, data = self.transport.perform_request('GET', _make_path('_cat', + return self.transport.perform_request('GET', _make_path('_cat', 'snapshots', repository), params=params) - return data diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index 2f9e0631..ee626262 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -26,9 +26,8 @@ class ClusterClient(NamespacedClient): :arg wait_for_status: Wait until cluster is in a specific state, default None, valid choices are: 'green', 'yellow', 'red' """ - _, data = self.transport.perform_request('GET', _make_path('_cluster', + return self.transport.perform_request('GET', _make_path('_cluster', 'health', index), params=params) - return data @query_params('local', 'master_timeout') def pending_tasks(self, params=None): @@ -42,9 +41,8 @@ class ClusterClient(NamespacedClient): master node (default: false) :arg master_timeout: Specify timeout for connection to master """ - _, data = self.transport.perform_request('GET', + return self.transport.perform_request('GET', '/_cluster/pending_tasks', params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', 'ignore_unavailable', 'local', 'master_timeout') @@ -71,9 +69,8 @@ class ClusterClient(NamespacedClient): """ if index and not metric: metric = '_all' - _, data = self.transport.perform_request('GET', _make_path('_cluster', + return self.transport.perform_request('GET', _make_path('_cluster', 'state', metric, index), params=params) - return data @query_params('flat_settings', 'human', 'timeout') def stats(self, node_id=None, params=None): @@ -95,8 +92,7 @@ class ClusterClient(NamespacedClient): url = '/_cluster/stats' if node_id: url = _make_path('_cluster/stats/nodes', node_id) - _, data = self.transport.perform_request('GET', url, params=params) - return data + return self.transport.perform_request('GET', url, params=params) @query_params('dry_run', 'explain', 'master_timeout', 'metric', 'timeout') def reroute(self, body=None, params=None): @@ -116,9 +112,8 @@ class ClusterClient(NamespacedClient): 'metadata', 'nodes', 'routing_table', 'master_node', 'version' :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('POST', '/_cluster/reroute', + return self.transport.perform_request('POST', '/_cluster/reroute', params=params, body=body) - return data @query_params('flat_settings', 'master_timeout', 'timeout') def get_settings(self, params=None): @@ -131,9 +126,8 @@ class ClusterClient(NamespacedClient): node :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('GET', '/_cluster/settings', + return self.transport.perform_request('GET', '/_cluster/settings', params=params) - return data @query_params('flat_settings', 'master_timeout', 'timeout') def put_settings(self, body=None, params=None): @@ -148,7 +142,6 @@ class ClusterClient(NamespacedClient): node :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('PUT', '/_cluster/settings', + return self.transport.perform_request('PUT', '/_cluster/settings', params=params, body=body) - return data diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 55dad3c2..87b9a16c 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -25,9 +25,8 @@ class IndicesClient(NamespacedClient): request body is not used) :arg tokenizer: The name of the tokenizer to use for the analysis """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_analyze'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'force', 'ignore_unavailable', 'operation_threading') @@ -50,9 +49,8 @@ class IndicesClient(NamespacedClient): ignored when unavailable (missing or closed) :arg operation_threading: TODO: ? """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_refresh'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'force', 'ignore_unavailable', 'wait_if_ongoing') @@ -82,9 +80,8 @@ class IndicesClient(NamespacedClient): to be thrown on the shard level if another flush operation is already running. """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_flush'), params=params) - return data @query_params('master_timeout', 'timeout', 'update_all_types') def create(self, index, body=None, params=None): @@ -101,9 +98,8 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('PUT', _make_path(index), + return self.transport.perform_request('PUT', _make_path(index), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', 'human', 'ignore_unavailable', 'local') @@ -128,9 +124,8 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, feature), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'master_timeout', 'timeout') @@ -153,9 +148,8 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_open'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'master_timeout', 'timeout') @@ -179,9 +173,8 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_close'), params=params) - return data @query_params('master_timeout', 'timeout') def delete(self, index, params=None): @@ -196,9 +189,8 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('DELETE', _make_path(index), + return self.transport.perform_request('DELETE', _make_path(index), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') @@ -287,9 +279,8 @@ class IndicesClient(NamespacedClient): for param in (doc_type, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path(index, + return self.transport.perform_request('PUT', _make_path(index, '_mapping', doc_type), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') @@ -311,9 +302,8 @@ class IndicesClient(NamespacedClient): :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_mapping', doc_type), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'include_defaults', 'local') @@ -340,9 +330,8 @@ class IndicesClient(NamespacedClient): """ if fields in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'fields'.") - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_mapping', doc_type, 'field', fields), params=params) - return data @query_params('master_timeout', 'timeout') def put_alias(self, index, name, body=None, params=None): @@ -361,9 +350,8 @@ class IndicesClient(NamespacedClient): for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path(index, + return self.transport.perform_request('PUT', _make_path(index, '_alias', name), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') @@ -412,9 +400,8 @@ class IndicesClient(NamespacedClient): :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_alias', name), params=params) - return data @query_params('local', 'timeout') def get_aliases(self, index=None, name=None, params=None): @@ -428,9 +415,8 @@ class IndicesClient(NamespacedClient): master node (default: false) :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_aliases', name), params=params) - return data @query_params('master_timeout', 'timeout') def update_aliases(self, body, params=None): @@ -444,9 +430,8 @@ class IndicesClient(NamespacedClient): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('POST', '/_aliases', + return self.transport.perform_request('POST', '/_aliases', params=params, body=body) - return data @query_params('master_timeout', 'timeout') def delete_alias(self, index, name, params=None): @@ -465,9 +450,8 @@ class IndicesClient(NamespacedClient): for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', _make_path(index, + return self.transport.perform_request('DELETE', _make_path(index, '_alias', name), params=params) - return data @query_params('create', 'flat_settings', 'master_timeout', 'order', 'timeout') @@ -490,9 +474,8 @@ class IndicesClient(NamespacedClient): for param in (name, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_template', + return self.transport.perform_request('PUT', _make_path('_template', name), params=params, body=body) - return data @query_params('local', 'master_timeout') def exists_template(self, name, params=None): @@ -528,9 +511,8 @@ class IndicesClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - _, data = self.transport.perform_request('GET', _make_path('_template', + return self.transport.perform_request('GET', _make_path('_template', name), params=params) - return data @query_params('master_timeout', 'timeout') def delete_template(self, name, params=None): @@ -544,9 +526,8 @@ class IndicesClient(NamespacedClient): """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - _, data = self.transport.perform_request('DELETE', + return self.transport.perform_request('DELETE', _make_path('_template', name), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', 'human', 'ignore_unavailable', 'local') @@ -572,9 +553,8 @@ class IndicesClient(NamespacedClient): :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_settings', name), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', 'ignore_unavailable', 'master_timeout') @@ -599,9 +579,8 @@ class IndicesClient(NamespacedClient): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('PUT', _make_path(index, + return self.transport.perform_request('PUT', _make_path(index, '_settings'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'master_timeout', 'request_cache') @@ -636,9 +615,8 @@ class IndicesClient(NamespacedClient): for param in (name, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path(index, + return self.transport.perform_request('PUT', _make_path(index, doc_type, '_warmer', name), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') @@ -664,9 +642,8 @@ class IndicesClient(NamespacedClient): :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_warmer', name), params=params) - return data @query_params('master_timeout') def delete_warmer(self, index, name, params=None): @@ -686,9 +663,8 @@ class IndicesClient(NamespacedClient): for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', _make_path(index, + return self.transport.perform_request('DELETE', _make_path(index, '_warmer', name), params=params) - return data @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', 'human', 'level', 'types') @@ -715,9 +691,8 @@ class IndicesClient(NamespacedClient): :arg types: A comma-separated list of document types for the `indexing` index metric """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_stats', metric), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'human', 'ignore_unavailable', 'operation_threading') @@ -740,9 +715,8 @@ class IndicesClient(NamespacedClient): ignored when unavailable (missing or closed) :arg operation_threading: TODO: ? """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_segments'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flush', 'ignore_unavailable', 'max_num_segments', 'only_expunge_deletes', @@ -772,9 +746,8 @@ class IndicesClient(NamespacedClient): :arg wait_for_merge: Specify whether the request should block until the merge process is finished (default: true) """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_optimize'), params=params) - return data @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'expand_wildcards', 'explain', @@ -816,9 +789,8 @@ class IndicesClient(NamespacedClient): :arg rewrite: Provide a more detailed explanation showing the actual Lucene query that will be executed. """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, doc_type, '_validate', 'query'), params=params, body=body) - return data @query_params('allow_no_indices', 'expand_wildcards', 'field_data', 'fielddata', 'fields', 'ignore_unavailable', 'query', 'recycler', @@ -845,9 +817,8 @@ class IndicesClient(NamespacedClient): :arg recycler: Clear the recycler cache :arg request: Clear request cache """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_cache', 'clear'), params=params) - return data @query_params('active_only', 'detailed', 'human') def recovery(self, index=None, params=None): @@ -866,9 +837,8 @@ class IndicesClient(NamespacedClient): :arg human: Whether to return time and byte values in human-readable format., default False """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_recovery'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'only_ancient_segments', 'wait_for_completion') @@ -892,9 +862,8 @@ class IndicesClient(NamespacedClient): :arg wait_for_completion: Specify whether the request should block until the all segments are upgraded (default: false) """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_upgrade'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'human', 'ignore_unavailable') @@ -916,9 +885,8 @@ class IndicesClient(NamespacedClient): :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_upgrade'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable') def flush_synced(self, index=None, params=None): @@ -937,9 +905,8 @@ class IndicesClient(NamespacedClient): :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_flush', 'synced'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'operation_threading', 'status') @@ -962,9 +929,8 @@ class IndicesClient(NamespacedClient): to get store information for, valid choices are: 'green', 'yellow', 'red', 'all' """ - _, data = self.transport.perform_request('GET', _make_path(index, + return self.transport.perform_request('GET', _make_path(index, '_shard_stores'), params=params) - return data @query_params('allow_no_indices', 'expand_wildcards', 'flush', 'ignore_unavailable', 'max_num_segments', 'only_expunge_deletes', @@ -993,6 +959,5 @@ class IndicesClient(NamespacedClient): :arg wait_for_merge: Specify whether the request should block until the merge process is finished (default: true) """ - _, data = self.transport.perform_request('POST', _make_path(index, + return self.transport.perform_request('POST', _make_path(index, '_forcemerge'), params=params) - return data diff --git a/elasticsearch/client/nodes.py b/elasticsearch/client/nodes.py index b81fcf65..6adc61d1 100644 --- a/elasticsearch/client/nodes.py +++ b/elasticsearch/client/nodes.py @@ -19,9 +19,8 @@ class NodesClient(NamespacedClient): format., default False :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('GET', _make_path('_nodes', + return self.transport.perform_request('GET', _make_path('_nodes', node_id, metric), params=params) - return data @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', 'human', 'level', 'timeout', 'types') @@ -56,9 +55,8 @@ class NodesClient(NamespacedClient): :arg types: A comma-separated list of document types for the `indexing` index metric """ - _, data = self.transport.perform_request('GET', _make_path('_nodes', + return self.transport.perform_request('GET', _make_path('_nodes', node_id, 'stats', metric, index_metric), params=params) - return data @query_params('doc_type', 'ignore_idle_threads', 'interval', 'snapshots', 'threads', 'timeout') @@ -85,7 +83,5 @@ class NodesClient(NamespacedClient): # avoid python reserved words if params and 'type_' in params: params['type'] = params.pop('type_') - _, data = self.transport.perform_request('GET', _make_path('_cluster', + return self.transport.perform_request('GET', _make_path('_cluster', 'nodes', node_id, 'hotthreads'), params=params) - return data - diff --git a/elasticsearch/client/snapshot.py b/elasticsearch/client/snapshot.py index 321580e0..edcffb1c 100644 --- a/elasticsearch/client/snapshot.py +++ b/elasticsearch/client/snapshot.py @@ -18,9 +18,8 @@ class SnapshotClient(NamespacedClient): for param in (repository, snapshot): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_snapshot', + return self.transport.perform_request('PUT', _make_path('_snapshot', repository, snapshot), params=params, body=body) - return data @query_params('master_timeout') def delete(self, repository, snapshot, params=None): @@ -36,9 +35,8 @@ class SnapshotClient(NamespacedClient): for param in (repository, snapshot): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', + return self.transport.perform_request('DELETE', _make_path('_snapshot', repository, snapshot), params=params) - return data @query_params('master_timeout') def get(self, repository, snapshot, params=None): @@ -54,9 +52,8 @@ class SnapshotClient(NamespacedClient): for param in (repository, snapshot): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('GET', _make_path('_snapshot', + return self.transport.perform_request('GET', _make_path('_snapshot', repository, snapshot), params=params) - return data @query_params('master_timeout', 'timeout') def delete_repository(self, repository, params=None): @@ -71,9 +68,8 @@ class SnapshotClient(NamespacedClient): """ if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - _, data = self.transport.perform_request('DELETE', + return self.transport.perform_request('DELETE', _make_path('_snapshot', repository), params=params) - return data @query_params('local', 'master_timeout') def get_repository(self, repository=None, params=None): @@ -87,9 +83,8 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - _, data = self.transport.perform_request('GET', _make_path('_snapshot', + return self.transport.perform_request('GET', _make_path('_snapshot', repository), params=params) - return data @query_params('master_timeout', 'timeout', 'verify') def create_repository(self, repository, body, params=None): @@ -107,9 +102,8 @@ class SnapshotClient(NamespacedClient): for param in (repository, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_snapshot', + return self.transport.perform_request('PUT', _make_path('_snapshot', repository), params=params, body=body) - return data @query_params('master_timeout', 'wait_for_completion') def restore(self, repository, snapshot, body=None, params=None): @@ -128,9 +122,8 @@ class SnapshotClient(NamespacedClient): for param in (repository, snapshot): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('POST', _make_path('_snapshot', + return self.transport.perform_request('POST', _make_path('_snapshot', repository, snapshot, '_restore'), params=params, body=body) - return data @query_params('master_timeout') def status(self, repository=None, snapshot=None, params=None): @@ -145,9 +138,8 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - _, data = self.transport.perform_request('GET', _make_path('_snapshot', + return self.transport.perform_request('GET', _make_path('_snapshot', repository, snapshot, '_status'), params=params) - return data @query_params('master_timeout', 'timeout') def verify_repository(self, repository, params=None): @@ -163,7 +155,5 @@ class SnapshotClient(NamespacedClient): """ if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - _, data = self.transport.perform_request('POST', _make_path('_snapshot', + return self.transport.perform_request('POST', _make_path('_snapshot', repository, '_verify'), params=params) - return data - diff --git a/elasticsearch/transport.py b/elasticsearch/transport.py index ad2c9021..c1935590 100644 --- a/elasticsearch/transport.py +++ b/elasticsearch/transport.py @@ -351,7 +351,7 @@ class Transport(object): self.connection_pool.mark_live(connection) if data: data = self.deserializer.loads(data, headers.get('content-type')) - return status, data + return data def close(self): """