Skip to content

Commit 7c305f1

Browse files
committed
Fixes for Elasticsearch 5.0
1 parent b83df5e commit 7c305f1

File tree

5 files changed

+67
-57
lines changed

5 files changed

+67
-57
lines changed

elasticsearch/client/__init__.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ def mtermvectors(self, index=None, doc_type=None, body=None, params=None):
10481048
return self.transport.perform_request('GET', _make_path(index,
10491049
doc_type, '_mtermvectors'), params=params, body=body)
10501050

1051-
@query_params('op_type', 'version', 'version_type')
1051+
@query_params()
10521052
def put_script(self, lang, id, body, params=None):
10531053
"""
10541054
Create a script in given language with specified ID.
@@ -1057,100 +1057,78 @@ def put_script(self, lang, id, body, params=None):
10571057
:arg lang: Script language
10581058
:arg id: Script ID
10591059
:arg body: The document
1060-
:arg op_type: Explicit operation type, default 'index', valid choices
1061-
are: 'index', 'create'
1062-
:arg version: Explicit version number for concurrency control
1063-
:arg version_type: Specific version type, valid choices are: 'internal',
1064-
'external', 'external_gte', 'force'
10651060
"""
10661061
for param in (lang, id, body):
10671062
if param in SKIP_IN_PATH:
10681063
raise ValueError("Empty value passed for a required argument.")
10691064
return self.transport.perform_request('PUT', _make_path('_scripts',
10701065
lang, id), params=params, body=body)
10711066

1072-
@query_params('version', 'version_type')
1067+
@query_params()
10731068
def get_script(self, lang, id, params=None):
10741069
"""
10751070
Retrieve a script from the API.
10761071
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
10771072
10781073
:arg lang: Script language
10791074
:arg id: Script ID
1080-
:arg version: Explicit version number for concurrency control
1081-
:arg version_type: Specific version type, valid choices are: 'internal',
1082-
'external', 'external_gte', 'force'
10831075
"""
10841076
for param in (lang, id):
10851077
if param in SKIP_IN_PATH:
10861078
raise ValueError("Empty value passed for a required argument.")
10871079
return self.transport.perform_request('GET', _make_path('_scripts',
10881080
lang, id), params=params)
10891081

1090-
@query_params('version', 'version_type')
1082+
@query_params()
10911083
def delete_script(self, lang, id, params=None):
10921084
"""
10931085
Remove a stored script from elasticsearch.
10941086
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
10951087
10961088
:arg lang: Script language
10971089
:arg id: Script ID
1098-
:arg version: Explicit version number for concurrency control
1099-
:arg version_type: Specific version type, valid choices are: 'internal',
1100-
'external', 'external_gte', 'force'
11011090
"""
11021091
for param in (lang, id):
11031092
if param in SKIP_IN_PATH:
11041093
raise ValueError("Empty value passed for a required argument.")
11051094
return self.transport.perform_request('DELETE',
11061095
_make_path('_scripts', lang, id), params=params)
11071096

1108-
@query_params('op_type', 'version', 'version_type')
1097+
@query_params()
11091098
def put_template(self, id, body, params=None):
11101099
"""
11111100
Create a search template.
11121101
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
11131102
11141103
:arg id: Template ID
11151104
:arg body: The document
1116-
:arg op_type: Explicit operation type, default 'index', valid choices
1117-
are: 'index', 'create'
1118-
:arg version: Explicit version number for concurrency control
1119-
:arg version_type: Specific version type, valid choices are: 'internal',
1120-
'external', 'external_gte', 'force'
11211105
"""
11221106
for param in (id, body):
11231107
if param in SKIP_IN_PATH:
11241108
raise ValueError("Empty value passed for a required argument.")
11251109
return self.transport.perform_request('PUT', _make_path('_search',
11261110
'template', id), params=params, body=body)
11271111

1128-
@query_params('version', 'version_type')
1112+
@query_params()
11291113
def get_template(self, id, params=None):
11301114
"""
11311115
Retrieve a search template.
11321116
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
11331117
11341118
:arg id: Template ID
1135-
:arg version: Explicit version number for concurrency control
1136-
:arg version_type: Specific version type, valid choices are: 'internal',
1137-
'external', 'external_gte', 'force'
11381119
"""
11391120
if id in SKIP_IN_PATH:
11401121
raise ValueError("Empty value passed for a required argument 'id'.")
11411122
return self.transport.perform_request('GET', _make_path('_search',
11421123
'template', id), params=params)
11431124

1144-
@query_params('version', 'version_type')
1125+
@query_params()
11451126
def delete_template(self, id, params=None):
11461127
"""
11471128
Delete a search template.
11481129
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
11491130
11501131
:arg id: Template ID
1151-
:arg version: Explicit version number for concurrency control
1152-
:arg version_type: Specific version type, valid choices are: 'internal',
1153-
'external', 'external_gte', 'force'
11541132
"""
11551133
if id in SKIP_IN_PATH:
11561134
raise ValueError("Empty value passed for a required argument 'id'.")

elasticsearch/client/cat.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def pending_tasks(self, params=None):
223223
return self.transport.perform_request('GET', '/_cat/pending_tasks',
224224
params=params)
225225

226-
@query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'v')
226+
@query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'size', 'v')
227227
def thread_pool(self, params=None):
228228
"""
229229
Get information about thread pools.
@@ -236,6 +236,8 @@ def thread_pool(self, params=None):
236236
master node (default: false)
237237
:arg master_timeout: Explicit operation timeout for connection to master
238238
node
239+
:arg size: The multiplier in which to display values, valid choices are:
240+
'', 'k', 'm', 'g', 't', 'p'
239241
:arg v: Verbose mode. Display column headers, default False
240242
"""
241243
return self.transport.perform_request('GET', '/_cat/thread_pool',
@@ -250,7 +252,7 @@ def fielddata(self, fields=None, params=None):
250252
:arg fields: A comma-separated list of fields to return the fielddata
251253
size
252254
:arg bytes: The unit in which to display byte values, valid choices are:
253-
'b', 'k', 'm', 'g'
255+
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
254256
:arg h: Comma-separated list of column names to display
255257
:arg help: Return help information, default False
256258
:arg local: Return local information, do not retrieve the state from
@@ -328,3 +330,28 @@ def snapshots(self, repository=None, params=None):
328330
"""
329331
return self.transport.perform_request('GET', _make_path('_cat',
330332
'snapshots', repository), params=params)
333+
334+
@query_params('actions', 'detailed', 'format', 'h', 'help', 'node_id',
335+
'parent_node', 'parent_task', 'v')
336+
def tasks(self, params=None):
337+
"""
338+
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html>`_
339+
340+
:arg actions: A comma-separated list of actions that should be returned.
341+
Leave empty to return all.
342+
:arg detailed: Return detailed task information (default: false)
343+
:arg format: a short version of the Accept header, e.g. json, yaml
344+
:arg h: Comma-separated list of column names to display
345+
:arg help: Return help information, default False
346+
:arg node_id: A comma-separated list of node IDs or names to limit the
347+
returned information; use `_local` to return information from the
348+
node you're connecting to, leave empty to get information from all
349+
nodes
350+
:arg parent_node: Return tasks with specified parent node.
351+
:arg parent_task: Return tasks with specified parent task id. Set to -1
352+
to return all.
353+
:arg v: Verbose mode. Display column headers, default False
354+
"""
355+
return self.transport.perform_request('GET', '/_cat/tasks',
356+
params=params)
357+

elasticsearch/client/cluster.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,17 @@ def put_settings(self, body=None, params=None):
148148
return self.transport.perform_request('PUT', '/_cluster/settings',
149149
params=params, body=body)
150150

151+
@query_params('include_yes_decisions')
152+
def allocation_explain(self, body=None, params=None):
153+
"""
154+
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html>`_
155+
156+
:arg body: The index, shard, and primary flag to explain. Empty means
157+
'explain the first unassigned shard'
158+
:arg include_yes_decisions: Return 'YES' decisions in explanation
159+
(default: false)
160+
"""
161+
return self.transport.perform_request('GET',
162+
'/_cluster/allocation/explain', params=params, body=body)
163+
164+

elasticsearch/client/indices.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
22

33
class IndicesClient(NamespacedClient):
4-
@query_params('analyzer', 'attributes', 'char_filters', 'explain', 'field',
5-
'filters', 'format', 'prefer_local', 'text', 'tokenizer')
4+
@query_params('analyzer', 'attributes', 'char_filter', 'explain', 'field',
5+
'filter', 'format', 'prefer_local', 'text', 'tokenizer')
66
def analyze(self, index=None, body=None, params=None):
77
"""
88
Perform the analysis process on a text and return the tokens breakdown of the text.
@@ -13,13 +13,13 @@ def analyze(self, index=None, body=None, params=None):
1313
:arg analyzer: The name of the analyzer to use
1414
:arg attributes: A comma-separated list of token attributes to output,
1515
this parameter works only with `explain=true`
16-
:arg char_filters: A comma-separated list of character filters to use
16+
:arg char_filter: A comma-separated list of character filters to use
1717
for the analysis
1818
:arg explain: With `true`, outputs more advanced details. (default:
1919
false)
2020
:arg field: Use the analyzer configured for this field (instead of
2121
passing the analyzer name)
22-
:arg filters: A comma-separated list of filters to use for the analysis
22+
:arg filter: A comma-separated list of filters to use for the analysis
2323
:arg format: Format of the output, default 'detailed', valid choices
2424
are: 'detailed', 'text'
2525
:arg prefer_local: With `true`, specify that a local shard should be
@@ -105,7 +105,7 @@ def create(self, index, body=None, params=None):
105105
params=params, body=body)
106106

107107
@query_params('allow_no_indices', 'expand_wildcards', 'flat_settings',
108-
'human', 'ignore_unavailable', 'local')
108+
'human', 'ignore_unavailable', 'include_defaults', 'local')
109109
def get(self, index, feature=None, params=None):
110110
"""
111111
The get index API allows to retrieve information about one or more indexes.
@@ -122,6 +122,8 @@ def get(self, index, feature=None, params=None):
122122
:arg human: Whether to return version and creation date values in human-
123123
readable format., default False
124124
:arg ignore_unavailable: Ignore unavailable indexes (default: false)
125+
:arg include_defaults: Whether to return all default setting for each of
126+
the indices., default False
125127
:arg local: Return local information, do not retrieve the state from
126128
master node (default: false)
127129
"""
@@ -394,21 +396,6 @@ def get_alias(self, index=None, name=None, params=None):
394396
return self.transport.perform_request('GET', _make_path(index,
395397
'_alias', name), params=params)
396398

397-
@query_params('local', 'timeout')
398-
def get_aliases(self, index=None, name=None, params=None):
399-
"""
400-
Retrieve specified aliases
401-
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_
402-
403-
:arg index: A comma-separated list of index names to filter aliases
404-
:arg name: A comma-separated list of alias names to filter
405-
:arg local: Return local information, do not retrieve the state from
406-
master node (default: false)
407-
:arg timeout: Explicit operation timeout
408-
"""
409-
return self.transport.perform_request('GET', _make_path(index,
410-
'_aliases', name), params=params)
411-
412399
@query_params('master_timeout', 'timeout')
413400
def update_aliases(self, body, params=None):
414401
"""

elasticsearch/client/tasks.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
22

33
class TasksClient(NamespacedClient):
4-
@query_params('actions', 'detailed', 'node_id', 'parent_node',
4+
@query_params('actions', 'detailed', 'group_by', 'node_id', 'parent_node',
55
'parent_task', 'wait_for_completion')
66
def list(self, task_id=None, params=None):
77
"""
88
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-list.html>`_
99
10-
:arg task_id: Return the task with specified id
10+
:arg task_id: Return the task with specified id (node_id:task_number)
1111
:arg actions: A comma-separated list of actions that should be returned.
1212
Leave empty to return all.
1313
:arg detailed: Return detailed task information (default: false)
14+
:arg group_by: Group tasks by nodes or parent/child relationships,
15+
default 'nodes', valid choices are: 'nodes', 'parents'
1416
:arg node_id: A comma-separated list of node IDs or names to limit the
1517
returned information; use `_local` to return information from the
1618
node you're connecting to, leave empty to get information from all
1719
nodes
1820
:arg parent_node: Return tasks with specified parent node.
19-
:arg parent_task: Return tasks with specified parent task id. Set to -1
20-
to return all.
21+
:arg parent_task: Return tasks with specified parent task id
22+
(node_id:task_number). Set to -1 to return all.
2123
:arg wait_for_completion: Wait for the matching tasks to complete
2224
(default: false)
2325
"""
@@ -27,18 +29,20 @@ def list(self, task_id=None, params=None):
2729
@query_params('actions', 'node_id', 'parent_node', 'parent_task')
2830
def cancel(self, task_id=None, params=None):
2931
"""
32+
3033
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-cancel.html>`_
3134
32-
:arg task_id: Cancel the task with specified id
35+
:arg task_id: Cancel the task with specified task id
36+
(node_id:task_number)
3337
:arg actions: A comma-separated list of actions that should be
3438
cancelled. Leave empty to cancel all.
3539
:arg node_id: A comma-separated list of node IDs or names to limit the
3640
returned information; use `_local` to return information from the
3741
node you're connecting to, leave empty to get information from all
3842
nodes
3943
:arg parent_node: Cancel tasks with specified parent node.
40-
:arg parent_task: Cancel tasks with specified parent task id. Set to -1
41-
to cancel all.
44+
:arg parent_task: Cancel tasks with specified parent task id
45+
(node_id:task_number). Set to -1 to cancel all.
4246
"""
4347
return self.transport.perform_request('POST', _make_path('_tasks',
4448
task_id, '_cancel'), params=params)

0 commit comments

Comments
 (0)