Skip to content

Commit 3be98b0

Browse files
committed
first pass for 6.0 compatibility
1 parent 95cf68a commit 3be98b0

File tree

8 files changed

+149
-361
lines changed

8 files changed

+149
-361
lines changed

elasticsearch/client/__init__.py

Lines changed: 77 additions & 300 deletions
Large diffs are not rendered by default.

elasticsearch/client/cat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def repositories(self, params=None):
375375

376376
@query_params('format', 'h', 'help', 'ignore_unavailable', 'master_timeout',
377377
's', 'v')
378-
def snapshots(self, repository=None, params=None):
378+
def snapshots(self, repository, params=None):
379379
"""
380380
381381
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html>`_
@@ -393,6 +393,8 @@ def snapshots(self, repository=None, params=None):
393393
by
394394
:arg v: Verbose mode. Display column headers, default False
395395
"""
396+
if repository in SKIP_IN_PATH:
397+
raise ValueError("Empty value passed for a required argument 'repository'.")
396398
return self.transport.perform_request('GET', _make_path('_cat',
397399
'snapshots', repository), params=params)
398400

elasticsearch/client/cluster.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def health(self, index=None, params=None):
2020
:arg wait_for_active_shards: Wait until the specified number of shards
2121
is active
2222
:arg wait_for_events: Wait until all currently queued events with the
23-
given priorty are processed, valid choices are: 'immediate',
23+
given priority are processed, valid choices are: 'immediate',
2424
'urgent', 'high', 'normal', 'low', 'languid'
2525
:arg wait_for_no_relocating_shards: Whether to wait until there are no
2626
relocating shards in the cluster
@@ -75,7 +75,7 @@ def state(self, metric=None, index=None, params=None):
7575
return self.transport.perform_request('GET', _make_path('_cluster',
7676
'state', metric, index), params=params)
7777

78-
@query_params('flat_settings', 'human', 'timeout')
78+
@query_params('flat_settings', 'timeout')
7979
def stats(self, node_id=None, params=None):
8080
"""
8181
The Cluster Stats API allows to retrieve statistics from a cluster wide
@@ -88,8 +88,6 @@ def stats(self, node_id=None, params=None):
8888
node you're connecting to, leave empty to get information from all
8989
nodes
9090
:arg flat_settings: Return settings in flat format (default: false)
91-
:arg human: Whether to return time and byte values in human-readable
92-
format., default False
9391
:arg timeout: Explicit operation timeout
9492
"""
9593
url = '/_cluster/stats'
@@ -169,4 +167,3 @@ def allocation_explain(self, body=None, params=None):
169167
return self.transport.perform_request('GET',
170168
'/_cluster/allocation/explain', params=params, body=body)
171169

172-

elasticsearch/client/indices.py

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

33
class IndicesClient(NamespacedClient):
4-
@query_params('analyzer', 'attributes', 'char_filter', 'explain', 'field',
5-
'filter', 'format', 'prefer_local', 'text', 'tokenizer')
4+
@query_params('format', 'prefer_local')
65
def analyze(self, index=None, body=None, params=None):
76
"""
87
Perform the analysis process on a text and return the tokens breakdown of the text.
98
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html>`_
109
1110
:arg index: The name of the index to scope the operation
12-
:arg body: The text on which the analysis should be performed
13-
:arg analyzer: The name of the analyzer to use
14-
:arg attributes: A comma-separated list of token attributes to output,
15-
this parameter works only with `explain=true`
16-
:arg char_filter: A comma-separated list of character filters to use for
17-
the analysis
18-
:arg explain: With `true`, outputs more advanced details. (default:
19-
false)
20-
:arg field: Use the analyzer configured for this field (instead of
21-
passing the analyzer name)
22-
:arg filter: A comma-separated list of filters to use for the analysis
11+
:arg body: Define analyzer/tokenizer parameters and the text on which
12+
the analysis should be performed
2313
:arg format: Format of the output, default 'detailed', valid choices
2414
are: 'detailed', 'text'
2515
:arg prefer_local: With `true`, specify that a local shard should be
2616
used if available, with `false`, use a random shard (default: true)
27-
:arg text: The text on which the analysis should be performed (when
28-
request body is not used)
29-
:arg tokenizer: The name of the tokenizer to use for the analysis
3017
"""
3118
return self.transport.perform_request('GET', _make_path(index,
3219
'_analyze'), params=params, body=body)
3320

34-
@query_params('allow_no_indices', 'expand_wildcards', 'force',
35-
'ignore_unavailable', 'operation_threading')
21+
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable')
3622
def refresh(self, index=None, params=None):
3723
"""
3824
Explicitly refresh one or more index, making all operations performed
@@ -47,10 +33,8 @@ def refresh(self, index=None, params=None):
4733
:arg expand_wildcards: Whether to expand wildcard expression to concrete
4834
indices that are open, closed or both., default 'open', valid
4935
choices are: 'open', 'closed', 'none', 'all'
50-
:arg force: Force a refresh even if not required, default False
5136
:arg ignore_unavailable: Whether specified concrete indices should be
5237
ignored when unavailable (missing or closed)
53-
:arg operation_threading: TODO: ?
5438
"""
5539
return self.transport.perform_request('POST', _make_path(index,
5640
'_refresh'), params=params)
@@ -107,22 +91,19 @@ def create(self, index, body=None, params=None):
10791
params=params, body=body)
10892

10993
@query_params('allow_no_indices', 'expand_wildcards', 'flat_settings',
110-
'human', 'ignore_unavailable', 'include_defaults', 'local')
94+
'ignore_unavailable', 'include_defaults', 'local')
11195
def get(self, index, feature=None, params=None):
11296
"""
11397
The get index API allows to retrieve information about one or more indexes.
11498
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html>`_
11599
116100
:arg index: A comma-separated list of index names
117-
:arg feature: A comma-separated list of features
118101
:arg allow_no_indices: Ignore if a wildcard expression resolves to no
119102
concrete indices (default: false)
120103
:arg expand_wildcards: Whether wildcard expressions should get expanded
121104
to open or closed indices (default: open), default 'open', valid
122105
choices are: 'open', 'closed', 'none', 'all'
123106
:arg flat_settings: Return settings in flat format (default: false)
124-
:arg human: Whether to return version and creation date values in human-
125-
readable format., default False
126107
:arg ignore_unavailable: Ignore unavailable indexes (default: false)
127108
:arg include_defaults: Whether to return all default setting for each of
128109
the indices., default False
@@ -183,14 +164,21 @@ def close(self, index, params=None):
183164
return self.transport.perform_request('POST', _make_path(index,
184165
'_close'), params=params)
185166

186-
@query_params('master_timeout', 'timeout')
167+
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
168+
'master_timeout', 'timeout')
187169
def delete(self, index, params=None):
188170
"""
189171
Delete an index in Elasticsearch
190172
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html>`_
191173
192174
:arg index: A comma-separated list of indices to delete; use `_all` or
193175
`*` string to delete all indices
176+
:arg allow_no_indices: Ignore if a wildcard expression resolves to no
177+
concrete indices (default: false)
178+
:arg expand_wildcards: Whether wildcard expressions should get expanded
179+
to open or closed indices (default: open), default 'open', valid
180+
choices are: 'open', 'closed', 'none', 'all'
181+
:arg ignore_unavailable: Ignore unavailable indexes (default: false)
194182
:arg master_timeout: Specify timeout for connection to master
195183
:arg timeout: Explicit operation timeout
196184
"""
@@ -199,22 +187,23 @@ def delete(self, index, params=None):
199187
return self.transport.perform_request('DELETE', _make_path(index),
200188
params=params)
201189

202-
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
203-
'local')
190+
@query_params('allow_no_indices', 'expand_wildcards', 'flat_settings',
191+
'ignore_unavailable', 'include_defaults', 'local')
204192
def exists(self, index, params=None):
205193
"""
206194
Return a boolean indicating whether given index exists.
207195
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html>`_
208196
209-
:arg index: A comma-separated list of indices to check
210-
:arg allow_no_indices: Whether to ignore if a wildcard indices
211-
expression resolves into no concrete indices. (This includes `_all`
212-
string or when no indices have been specified)
213-
:arg expand_wildcards: Whether to expand wildcard expression to concrete
214-
indices that are open, closed or both., default 'open', valid
197+
:arg index: A comma-separated list of index names
198+
:arg allow_no_indices: Ignore if a wildcard expression resolves to no
199+
concrete indices (default: false)
200+
:arg expand_wildcards: Whether wildcard expressions should get expanded
201+
to open or closed indices (default: open), default 'open', valid
215202
choices are: 'open', 'closed', 'none', 'all'
216-
:arg ignore_unavailable: Whether specified concrete indices should be
217-
ignored when unavailable (missing or closed)
203+
:arg flat_settings: Return settings in flat format (default: false)
204+
:arg ignore_unavailable: Ignore unavailable indexes (default: false)
205+
:arg include_defaults: Whether to return all default setting for each of
206+
the indices., default False
218207
:arg local: Return local information, do not retrieve the state from
219208
master node (default: false)
220209
"""
@@ -365,8 +354,8 @@ def exists_alias(self, index=None, name=None, params=None):
365354
expression resolves into no concrete indices. (This includes `_all`
366355
string or when no indices have been specified)
367356
:arg expand_wildcards: Whether to expand wildcard expression to concrete
368-
indices that are open, closed or both., default ['open', 'closed'],
369-
valid choices are: 'open', 'closed', 'none', 'all'
357+
indices that are open, closed or both., default 'all', valid choices
358+
are: 'open', 'closed', 'none', 'all'
370359
:arg ignore_unavailable: Whether specified concrete indices should be
371360
ignored when unavailable (missing or closed)
372361
:arg local: Return local information, do not retrieve the state from
@@ -388,8 +377,8 @@ def get_alias(self, index=None, name=None, params=None):
388377
expression resolves into no concrete indices. (This includes `_all`
389378
string or when no indices have been specified)
390379
:arg expand_wildcards: Whether to expand wildcard expression to concrete
391-
indices that are open, closed or both., default 'all', valid
392-
choices are: 'open', 'closed', 'none', 'all'
380+
indices that are open, closed or both., default 'all', valid choices
381+
are: 'open', 'closed', 'none', 'all'
393382
:arg ignore_unavailable: Whether specified concrete indices should be
394383
ignored when unavailable (missing or closed)
395384
:arg local: Return local information, do not retrieve the state from
@@ -457,13 +446,14 @@ def put_template(self, name, body, params=None):
457446
return self.transport.perform_request('PUT', _make_path('_template',
458447
name), params=params, body=body)
459448

460-
@query_params('local', 'master_timeout')
449+
@query_params('flat_settings', 'local', 'master_timeout')
461450
def exists_template(self, name, params=None):
462451
"""
463452
Return a boolean indicating whether given template exists.
464453
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html>`_
465454
466-
:arg name: The name of the template
455+
:arg name: The comma separated names of the index templates
456+
:arg flat_settings: Return settings in flat format (default: false)
467457
:arg local: Return local information, do not retrieve the state from
468458
master node (default: false)
469459
:arg master_timeout: Explicit operation timeout for connection to master
@@ -506,7 +496,7 @@ def delete_template(self, name, params=None):
506496
_make_path('_template', name), params=params)
507497

508498
@query_params('allow_no_indices', 'expand_wildcards', 'flat_settings',
509-
'human', 'ignore_unavailable', 'include_defaults', 'local')
499+
'ignore_unavailable', 'include_defaults', 'local')
510500
def get_settings(self, index=None, name=None, params=None):
511501
"""
512502
Retrieve settings for one or more (or all) indices.
@@ -522,8 +512,6 @@ def get_settings(self, index=None, name=None, params=None):
522512
indices that are open, closed or both., default ['open', 'closed'],
523513
valid choices are: 'open', 'closed', 'none', 'all'
524514
:arg flat_settings: Return settings in flat format (default: false)
525-
:arg human: Whether to return version and creation date values in human-
526-
readable format., default False
527515
:arg ignore_unavailable: Whether specified concrete indices should be
528516
ignored when unavailable (missing or closed)
529517
:arg include_defaults: Whether to return all default setting for each of
@@ -615,10 +603,9 @@ def segments(self, index=None, params=None):
615603
return self.transport.perform_request('GET', _make_path(index,
616604
'_segments'), params=params)
617605

618-
@query_params('allow_no_indices', 'analyze_wildcard', 'analyzer',
619-
'default_operator', 'df', 'expand_wildcards', 'explain',
620-
'ignore_unavailable', 'lenient', 'lowercase_expanded_terms',
621-
'operation_threading', 'q', 'rewrite')
606+
@query_params('all_shards', 'allow_no_indices', 'analyze_wildcard',
607+
'analyzer', 'default_operator', 'df', 'expand_wildcards', 'explain',
608+
'ignore_unavailable', 'lenient', 'operation_threading', 'q', 'rewrite')
622609
def validate_query(self, index=None, doc_type=None, body=None, params=None):
623610
"""
624611
Validate a potentially expensive query without executing it.
@@ -630,6 +617,8 @@ def validate_query(self, index=None, doc_type=None, body=None, params=None):
630617
:arg doc_type: A comma-separated list of document types to restrict the
631618
operation; leave empty to perform the operation on all types
632619
:arg body: The query definition specified with the Query DSL
620+
:arg all_shards: Execute validation on all shards instead of one random
621+
shard per index
633622
:arg allow_no_indices: Whether to ignore if a wildcard indices
634623
expression resolves into no concrete indices. (This includes `_all`
635624
string or when no indices have been specified)
@@ -648,8 +637,6 @@ def validate_query(self, index=None, doc_type=None, body=None, params=None):
648637
ignored when unavailable (missing or closed)
649638
:arg lenient: Specify whether format-based query failures (such as
650639
providing text to a numeric field) should be ignored
651-
:arg lowercase_expanded_terms: Specify whether query terms should be
652-
lowercased
653640
:arg operation_threading: TODO: ?
654641
:arg q: Query in the Lucene query string syntax
655642
:arg rewrite: Provide a more detailed explanation showing the actual
@@ -682,6 +669,7 @@ def clear_cache(self, index=None, params=None):
682669
:arg query: Clear query caches
683670
:arg recycler: Clear the recycler cache
684671
:arg request: Clear request cache
672+
:arg request_cache: Clear request cache
685673
"""
686674
return self.transport.perform_request('POST', _make_path(index,
687675
'_cache', 'clear'), params=params)

elasticsearch/client/nodes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,22 @@ def hot_threads(self, node_id=None, params=None):
8484
params['type'] = params.pop('type_')
8585
return self.transport.perform_request('GET', _make_path('_cluster',
8686
'nodes', node_id, 'hotthreads'), params=params)
87+
88+
@query_params('human', 'timeout')
89+
def usage(self, node_id=None, metric=None, params=None):
90+
"""
91+
The cluster nodes usage API allows to retrieve information on the usage
92+
of features for each node.
93+
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
94+
95+
:arg node_id: A comma-separated list of node IDs or names to limit the
96+
returned information; use `_local` to return information from the
97+
node you're connecting to, leave empty to get information from all
98+
nodes
99+
:arg metric: Limit the information returned to the specified metrics
100+
:arg human: Whether to return time and byte values in human-readable
101+
format., default False
102+
:arg timeout: Explicit operation timeout
103+
"""
104+
return self.transport.perform_request('GET', _make_path('_nodes',
105+
node_id, 'usage', metric), params=params)

elasticsearch/client/snapshot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def delete(self, repository, snapshot, params=None):
3838
return self.transport.perform_request('DELETE',
3939
_make_path('_snapshot', repository, snapshot), params=params)
4040

41-
@query_params('ignore_unavailable', 'master_timeout')
41+
@query_params('ignore_unavailable', 'master_timeout', 'verbose')
4242
def get(self, repository, snapshot, params=None):
4343
"""
4444
Retrieve information about a snapshot.
@@ -50,6 +50,8 @@ def get(self, repository, snapshot, params=None):
5050
defaults to false which means a SnapshotMissingException is thrown
5151
:arg master_timeout: Explicit operation timeout for connection to master
5252
node
53+
:arg verbose: Whether to show verbose snapshot info or only show the
54+
basic info found in the repository index blob
5355
"""
5456
for param in (repository, snapshot):
5557
if param in SKIP_IN_PATH:

elasticsearch/client/tasks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
class TasksClient(NamespacedClient):
44
@query_params('actions', 'detailed', 'group_by', 'node_id', 'parent_node',
55
'parent_task', 'wait_for_completion')
6-
def list(self, task_id=None, params=None):
6+
def list(self, params=None):
77
"""
88
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html>`_
99
10-
:arg task_id: Return the task with specified id (node_id:task_number)
1110
:arg actions: A comma-separated list of actions that should be returned.
1211
Leave empty to return all.
1312
:arg detailed: Return detailed task information (default: false)
@@ -23,8 +22,7 @@ def list(self, task_id=None, params=None):
2322
:arg wait_for_completion: Wait for the matching tasks to complete
2423
(default: false)
2524
"""
26-
return self.transport.perform_request('GET', _make_path('_tasks',
27-
task_id), params=params)
25+
return self.transport.perform_request('GET', '/_tasks', params=params)
2826

2927
@query_params('actions', 'node_id', 'parent_node', 'parent_task')
3028
def cancel(self, task_id=None, params=None):

0 commit comments

Comments
 (0)