Skip to content

Commit f77eca5

Browse files
authored
Deduplicate params in docstrings
1 parent add015f commit f77eca5

File tree

9 files changed

+105
-45
lines changed

9 files changed

+105
-45
lines changed

elasticsearch/__init__.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
# flake8: noqa
22
from __future__ import absolute_import
33

4-
VERSION = (7, 5, 1)
4+
VERSION = (8, 0, 0)
55
__version__ = VERSION
66
__versionstr__ = ".".join(map(str, VERSION))
77

88
import logging
99

10-
try: # Python 2.7+
11-
from logging import NullHandler
12-
except ImportError:
13-
14-
class NullHandler(logging.Handler):
15-
def emit(self, record):
16-
pass
17-
18-
19-
import sys
20-
2110
logger = logging.getLogger("elasticsearch")
2211
logger.addHandler(logging.NullHandler())
2312

@@ -26,4 +15,41 @@ def emit(self, record):
2615
from .connection_pool import ConnectionPool, ConnectionSelector, RoundRobinSelector
2716
from .serializer import JSONSerializer
2817
from .connection import Connection, RequestsHttpConnection, Urllib3HttpConnection
29-
from .exceptions import *
18+
from .exceptions import (
19+
ImproperlyConfigured,
20+
ElasticsearchException,
21+
SerializationError,
22+
TransportError,
23+
NotFoundError,
24+
ConflictError,
25+
RequestError,
26+
ConnectionError,
27+
SSLError,
28+
ConnectionTimeout,
29+
AuthenticationException,
30+
AuthorizationException,
31+
)
32+
33+
__all__ = [
34+
"Elasticsearch",
35+
"Transport",
36+
"ConnectionPool",
37+
"ConnectionSelector",
38+
"RoundRobinSelector",
39+
"JSONSerializer",
40+
"Connection",
41+
"RequestsHttpConnection",
42+
"Urllib3HttpConnection",
43+
"ImproperlyConfigured",
44+
"ElasticsearchException",
45+
"SerializationError",
46+
"TransportError",
47+
"NotFoundError",
48+
"ConflictError",
49+
"RequestError",
50+
"ConnectionError",
51+
"SSLError",
52+
"ConnectionTimeout",
53+
"AuthenticationException",
54+
"AuthorizationException",
55+
]

elasticsearch/client/__init__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ def bulk(self, body, index=None, doc_type=None, params=None, headers=None):
434434
the returned _source field, can be overridden on each sub-request
435435
:arg _source_includes: Default list of fields to extract and
436436
return from the _source field, can be overridden on each sub-request
437-
:arg doc_type: Default document type for items which don't
438-
provide one
439437
:arg pipeline: The pipeline id to preprocess incoming documents
440438
with
441439
:arg refresh: If `true` then refresh the affected shards to make
@@ -1121,8 +1119,8 @@ def msearch(self, body, index=None, params=None, headers=None):
11211119
the number of shards the search request expands to exceeds the
11221120
threshold. This filter roundtrip can limit the number of shards
11231121
significantly if for instance a shard can not match any documents based
1124-
on it's rewrite method ie. if date filters are mandatory to match but
1125-
the shard bounds and the query are disjoint. Default: 128
1122+
on its rewrite method ie. if date filters are mandatory to match but the
1123+
shard bounds and the query are disjoint.
11261124
:arg rest_total_hits_as_int: Indicates whether hits.total should
11271125
be rendered as an integer or an object in the rest search response
11281126
:arg search_type: Search operation type Valid choices:
@@ -1151,7 +1149,6 @@ def put_script(self, id, body, context=None, params=None, headers=None):
11511149
11521150
:arg id: Script ID
11531151
:arg body: The document
1154-
:arg context: Script context
11551152
:arg context: Context name to compile script against
11561153
:arg master_timeout: Specify timeout for connection to master
11571154
:arg timeout: Explicit operation timeout
@@ -1310,12 +1307,11 @@ def scroll(self, body=None, scroll_id=None, params=None, headers=None):
13101307
13111308
:arg body: The scroll ID if not passed by URL or query
13121309
parameter.
1313-
:arg scroll_id: The scroll ID
1310+
:arg scroll_id: The scroll ID for scrolled search
13141311
:arg rest_total_hits_as_int: Indicates whether hits.total should
13151312
be rendered as an integer or an object in the rest search response
13161313
:arg scroll: Specify how long a consistent view of the index
13171314
should be maintained for scrolled search
1318-
:arg scroll_id: The scroll ID for scrolled search
13191315
"""
13201316
if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
13211317
raise ValueError("You need to supply scroll_id or body.")
@@ -1430,8 +1426,8 @@ def search(self, body=None, index=None, params=None, headers=None):
14301426
the number of shards the search request expands to exceeds the
14311427
threshold. This filter roundtrip can limit the number of shards
14321428
significantly if for instance a shard can not match any documents based
1433-
on it's rewrite method ie. if date filters are mandatory to match but
1434-
the shard bounds and the query are disjoint. Default: 128
1429+
on its rewrite method ie. if date filters are mandatory to match but the
1430+
shard bounds and the query are disjoint.
14351431
:arg preference: Specify the node or shard the operation should
14361432
be performed on (default: random)
14371433
:arg q: Query in the Lucene query string syntax

elasticsearch/client/async_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def submit(self, body=None, index=None, params=None, headers=None):
136136
be performed on (default: random)
137137
:arg q: Query in the Lucene query string syntax
138138
:arg request_cache: Specify if request cache should be used for
139-
this request or not, defaults to index level setting
139+
this request or not, defaults to true
140140
:arg routing: A comma-separated list of specific routing values
141141
:arg search_type: Search operation type Valid choices:
142142
query_then_fetch, dfs_query_then_fetch

elasticsearch/client/cat.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ def recovery(self, index=None, params=None, headers=None):
237237
yaml
238238
:arg h: Comma-separated list of column names to display
239239
:arg help: Return help information
240-
:arg index: Comma-separated list or wildcard expression of index
241-
names to limit the returned information
242240
:arg s: Comma-separated list of column names or column aliases
243241
to sort by
244242
:arg time: The unit in which to display time values Valid
@@ -362,12 +360,10 @@ def fielddata(self, fields=None, params=None, headers=None):
362360
node in the cluster.
363361
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html>`_
364362
365-
:arg fields: A comma-separated list of fields to return the
366-
fielddata size
367-
:arg bytes: The unit in which to display byte values Valid
368-
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
369363
:arg fields: A comma-separated list of fields to return in the
370364
output
365+
:arg bytes: The unit in which to display byte values Valid
366+
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
371367
:arg format: a short version of the Accept header, e.g. json,
372368
yaml
373369
:arg h: Comma-separated list of column names to display

elasticsearch/client/indices.py

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def analyze(self, body=None, index=None, params=None, headers=None):
1212
:arg body: Define analyzer/tokenizer parameters and the text on
1313
which the analysis should be performed
1414
:arg index: The name of the index to scope the operation
15-
:arg index: The name of the index to scope the operation
1615
"""
1716
return self.transport.perform_request(
1817
"POST",
@@ -514,7 +513,7 @@ def delete_alias(self, index, name, params=None, headers=None):
514513
"DELETE", _make_path(index, "_alias", name), params=params, headers=headers
515514
)
516515

517-
@query_params("create", "flat_settings", "master_timeout", "order", "timeout")
516+
@query_params("create", "master_timeout", "order")
518517
def put_template(self, name, body, params=None, headers=None):
519518
"""
520519
Creates or updates an index template.
@@ -524,13 +523,10 @@ def put_template(self, name, body, params=None, headers=None):
524523
:arg body: The template definition
525524
:arg create: Whether the index template should only be added if
526525
new or can also replace an existing one
527-
:arg flat_settings: Return settings in flat format (default:
528-
false)
529526
:arg master_timeout: Specify timeout for connection to master
530527
:arg order: The order for this template when merging multiple
531528
matching ones (higher numbers are merged later, overriding the lower
532529
numbers)
533-
:arg timeout: Explicit operation timeout
534530
"""
535531
for param in (name, body):
536532
if param in SKIP_IN_PATH:
@@ -784,8 +780,6 @@ def clear_cache(self, index=None, params=None, headers=None):
784780
using the `fielddata` parameter (default: all)
785781
:arg ignore_unavailable: Whether specified concrete indices
786782
should be ignored when unavailable (missing or closed)
787-
:arg index: A comma-separated list of index name to limit the
788-
operation
789783
:arg query: Clear query caches
790784
:arg request: Clear request cache
791785
"""
@@ -1196,3 +1190,51 @@ def validate_query(
11961190
headers=headers,
11971191
body=body,
11981192
)
1193+
1194+
@query_params()
1195+
def create_data_stream(self, name, body, params=None, headers=None):
1196+
"""
1197+
Creates or updates a data stream
1198+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html>`_
1199+
1200+
:arg name: The name of the data stream
1201+
:arg body: The data stream definition
1202+
"""
1203+
for param in (name, body):
1204+
if param in SKIP_IN_PATH:
1205+
raise ValueError("Empty value passed for a required argument.")
1206+
1207+
return self.transport.perform_request(
1208+
"PUT",
1209+
_make_path("_data_stream", name),
1210+
params=params,
1211+
headers=headers,
1212+
body=body,
1213+
)
1214+
1215+
@query_params()
1216+
def delete_data_stream(self, name, params=None, headers=None):
1217+
"""
1218+
Deletes a data stream.
1219+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html>`_
1220+
1221+
:arg name: The name of the data stream
1222+
"""
1223+
if name in SKIP_IN_PATH:
1224+
raise ValueError("Empty value passed for a required argument 'name'.")
1225+
1226+
return self.transport.perform_request(
1227+
"DELETE", _make_path("_data_stream", name), params=params, headers=headers
1228+
)
1229+
1230+
@query_params()
1231+
def get_data_streams(self, name=None, params=None, headers=None):
1232+
"""
1233+
Returns data streams.
1234+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html>`_
1235+
1236+
:arg name: The comma separated names of data streams
1237+
"""
1238+
return self.transport.perform_request(
1239+
"GET", _make_path("_data_streams", name), params=params, headers=headers
1240+
)

elasticsearch/client/transform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def update_transform(self, transform_id, body, params=None, headers=None):
200200
)
201201
def cat_transform(self, transform_id=None, params=None, headers=None):
202202
"""
203-
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transform.html>`_
203+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html>`_
204204
205205
:arg transform_id: The id of the transform for which to get
206206
stats. '_all' or '*' implies all transforms
@@ -227,7 +227,7 @@ def cat_transform(self, transform_id=None, params=None, headers=None):
227227

228228
return self.transport.perform_request(
229229
"GET",
230-
_make_path("_cat", "transform", transform_id),
230+
_make_path("_cat", "transforms", transform_id),
231231
params=params,
232232
headers=headers,
233233
)

elasticsearch/client/watcher.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ def stats(self, metric=None, params=None, headers=None):
149149
current_watches, pending_watches
150150
:arg emit_stacktraces: Emits stack traces of currently running
151151
watches
152-
:arg metric: Controls what additional stat metrics should be
153-
include in the response Valid choices: _all, queued_watches,
154-
current_watches, pending_watches
155152
"""
156153
return self.transport.perform_request(
157154
"GET",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44
import sys
55

6-
VERSION = (7, 5, 1)
6+
VERSION = (8, 0, 0)
77
__version__ = VERSION
88
__versionstr__ = ".".join(map(str, VERSION))
99

utils/generate_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,14 @@ def ind(item):
164164
@property
165165
def params(self):
166166
parts = self.all_parts
167+
params = self._def.get("params", {})
167168
return chain(
168169
((p, parts[p]) for p in parts if parts[p]["required"]),
169-
(("body", self.body), ) if self.body else (),
170-
((p, parts[p]) for p in parts if not parts[p]["required"]),
171-
sorted(self._def.get("params", {}).items()),
170+
(("body", self.body),) if self.body else (),
171+
((p, parts[p]) for p in parts
172+
if not parts[p]["required"] and
173+
p not in params),
174+
sorted(params.items(), key=lambda x: (x[0] not in parts, x[0])),
172175
)
173176

174177
@property

0 commit comments

Comments
 (0)