Skip to content

Commit d3ee8b5

Browse files
authored
Update API to 8.2
1 parent 07bccad commit d3ee8b5

File tree

10 files changed

+376
-20
lines changed

10 files changed

+376
-20
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ async def delete_by_query(
11491149
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
11501150
] = None,
11511151
slice: t.Optional[t.Mapping[str, t.Any]] = None,
1152-
slices: t.Optional[int] = None,
1152+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
11531153
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11541154
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11551155
terminate_after: t.Optional[int] = None,
@@ -2529,6 +2529,7 @@ async def msearch(
25292529
pre_filter_shard_size: t.Optional[int] = None,
25302530
pretty: t.Optional[bool] = None,
25312531
rest_total_hits_as_int: t.Optional[bool] = None,
2532+
routing: t.Optional[str] = None,
25322533
search_type: t.Optional[
25332534
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
25342535
] = None,
@@ -2568,6 +2569,8 @@ async def msearch(
25682569
filters are mandatory to match but the shard bounds and the query are disjoint.
25692570
:param rest_total_hits_as_int: If true, hits.total are returned as an integer
25702571
in the response. Defaults to false, which returns an object.
2572+
:param routing: Custom routing value used to route search operations to a specific
2573+
shard.
25712574
:param search_type: Indicates whether global term and document frequencies should
25722575
be used when scoring returned documents.
25732576
:param typed_keys: Specifies whether aggregation and suggester names should be
@@ -2606,6 +2609,8 @@ async def msearch(
26062609
__query["pretty"] = pretty
26072610
if rest_total_hits_as_int is not None:
26082611
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
2612+
if routing is not None:
2613+
__query["routing"] = routing
26092614
if search_type is not None:
26102615
__query["search_type"] = search_type
26112616
if typed_keys is not None:
@@ -3036,7 +3041,7 @@ async def reindex(
30363041
script: t.Optional[t.Mapping[str, t.Any]] = None,
30373042
scroll: t.Optional[t.Union[int, str]] = None,
30383043
size: t.Optional[int] = None,
3039-
slices: t.Optional[int] = None,
3044+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
30403045
timeout: t.Optional[t.Union[int, str]] = None,
30413046
wait_for_active_shards: t.Optional[
30423047
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
@@ -4530,7 +4535,7 @@ async def update_by_query(
45304535
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
45314536
] = None,
45324537
slice: t.Optional[t.Mapping[str, t.Any]] = None,
4533-
slices: t.Optional[int] = None,
4538+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
45344539
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45354540
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45364541
terminate_after: t.Optional[int] = None,

elasticsearch/_async/client/cat.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,78 @@ async def allocation(
201201
"GET", __path, params=__query, headers=__headers
202202
)
203203

204+
@_rewrite_parameters()
205+
async def component_templates(
206+
self,
207+
*,
208+
name: t.Optional[str] = None,
209+
error_trace: t.Optional[bool] = None,
210+
filter_path: t.Optional[
211+
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
212+
] = None,
213+
format: t.Optional[str] = None,
214+
h: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None,
215+
help: t.Optional[bool] = None,
216+
human: t.Optional[bool] = None,
217+
local: t.Optional[bool] = None,
218+
master_timeout: t.Optional[t.Union[int, str]] = None,
219+
pretty: t.Optional[bool] = None,
220+
s: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None,
221+
v: t.Optional[bool] = None,
222+
) -> t.Union[ObjectApiResponse[t.Any], TextApiResponse]:
223+
"""
224+
Returns information about existing component_templates templates.
225+
226+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.2/cat-compoentn-templates.html>`_
227+
228+
:param name: A pattern that returned component template names must match
229+
:param format: Specifies the format to return the columnar data in, can be set
230+
to `text`, `json`, `cbor`, `yaml`, or `smile`.
231+
:param h: List of columns to appear in the response. Supports simple wildcards.
232+
:param help: When set to `true` will output available columns. This option can't
233+
be combined with any other query string option.
234+
:param local: If `true`, the request computes the list of selected nodes from
235+
the local cluster state. If `false` the list of selected nodes are computed
236+
from the cluster state of the master node. In both cases the coordinating
237+
node will send requests for further information to each selected node.
238+
:param master_timeout: Period to wait for a connection to the master node.
239+
:param s: List of columns that determine how the table should be sorted. Sorting
240+
defaults to ascending and can be changed by setting `:asc` or `:desc` as
241+
a suffix to the column name.
242+
:param v: When set to `true` will enable verbose output.
243+
"""
244+
if name not in SKIP_IN_PATH:
245+
__path = f"/_cat/component_templates/{_quote(name)}"
246+
else:
247+
__path = "/_cat/component_templates"
248+
__query: t.Dict[str, t.Any] = {}
249+
if error_trace is not None:
250+
__query["error_trace"] = error_trace
251+
if filter_path is not None:
252+
__query["filter_path"] = filter_path
253+
if format is not None:
254+
__query["format"] = format
255+
if h is not None:
256+
__query["h"] = h
257+
if help is not None:
258+
__query["help"] = help
259+
if human is not None:
260+
__query["human"] = human
261+
if local is not None:
262+
__query["local"] = local
263+
if master_timeout is not None:
264+
__query["master_timeout"] = master_timeout
265+
if pretty is not None:
266+
__query["pretty"] = pretty
267+
if s is not None:
268+
__query["s"] = s
269+
if v is not None:
270+
__query["v"] = v
271+
__headers = {"accept": "text/plain,application/json"}
272+
return await self.perform_request( # type: ignore[return-value]
273+
"GET", __path, params=__query, headers=__headers
274+
)
275+
204276
@_rewrite_parameters()
205277
async def count(
206278
self,

elasticsearch/_async/client/ingest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ async def put_pipeline(
189189
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
190190
] = None,
191191
human: t.Optional[bool] = None,
192+
if_version: t.Optional[int] = None,
192193
master_timeout: t.Optional[t.Union[int, str]] = None,
193194
meta: t.Optional[t.Mapping[str, t.Any]] = None,
194195
on_failure: t.Optional[
@@ -208,6 +209,8 @@ async def put_pipeline(
208209
209210
:param id: ID of the ingest pipeline to create or update.
210211
:param description: Description of the ingest pipeline.
212+
:param if_version: Required version for optimistic concurrency control for pipeline
213+
updates
211214
:param master_timeout: Period to wait for a connection to the master node. If
212215
no response is received before the timeout expires, the request fails and
213216
returns an error.
@@ -240,6 +243,8 @@ async def put_pipeline(
240243
__query["filter_path"] = filter_path
241244
if human is not None:
242245
__query["human"] = human
246+
if if_version is not None:
247+
__query["if_version"] = if_version
243248
if master_timeout is not None:
244249
__query["master_timeout"] = master_timeout
245250
if meta is not None:

elasticsearch/_async/client/security.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,16 @@ async def create_service_token(
438438
*,
439439
namespace: str,
440440
service: str,
441-
name: str,
441+
name: t.Optional[str] = None,
442442
error_trace: t.Optional[bool] = None,
443443
filter_path: t.Optional[
444444
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
445445
] = None,
446446
human: t.Optional[bool] = None,
447447
pretty: t.Optional[bool] = None,
448+
refresh: t.Optional[
449+
t.Union["t.Literal['false', 'true', 'wait_for']", bool, str]
450+
] = None,
448451
) -> ObjectApiResponse[t.Any]:
449452
"""
450453
Creates a service account token for access without requiring basic authentication.
@@ -454,13 +457,14 @@ async def create_service_token(
454457
:param namespace: An identifier for the namespace
455458
:param service: An identifier for the service name
456459
:param name: An identifier for the token name
460+
:param refresh: If `true` then refresh the affected shards to make this operation
461+
visible to search, if `wait_for` (the default) then wait for a refresh to
462+
make this operation visible to search, if `false` then do nothing with refreshes.
457463
"""
458464
if namespace in SKIP_IN_PATH:
459465
raise ValueError("Empty value passed for parameter 'namespace'")
460466
if service in SKIP_IN_PATH:
461467
raise ValueError("Empty value passed for parameter 'service'")
462-
if name in SKIP_IN_PATH:
463-
raise ValueError("Empty value passed for parameter 'name'")
464468
if (
465469
namespace not in SKIP_IN_PATH
466470
and service not in SKIP_IN_PATH
@@ -482,6 +486,8 @@ async def create_service_token(
482486
__query["human"] = human
483487
if pretty is not None:
484488
__query["pretty"] = pretty
489+
if refresh is not None:
490+
__query["refresh"] = refresh
485491
__headers = {"accept": "application/json"}
486492
return await self.perform_request( # type: ignore[return-value]
487493
__method, __path, params=__query, headers=__headers
@@ -1508,7 +1514,7 @@ async def grant_api_key(
15081514
async def has_privileges(
15091515
self,
15101516
*,
1511-
user: t.Optional[t.Union[None, str]] = None,
1517+
user: t.Optional[str] = None,
15121518
application: t.Optional[
15131519
t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]]
15141520
] = None,

elasticsearch/_async/client/shutdown.py

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ async def delete_node(
3434
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
3535
] = None,
3636
human: t.Optional[bool] = None,
37+
master_timeout: t.Optional[
38+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
39+
] = None,
3740
pretty: t.Optional[bool] = None,
41+
timeout: t.Optional[
42+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
43+
] = None,
3844
) -> ObjectApiResponse[t.Any]:
3945
"""
4046
Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and
@@ -43,6 +49,11 @@ async def delete_node(
4349
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
4450
4551
:param node_id: The node id of node to be removed from the shutdown state
52+
:param master_timeout: Period to wait for a connection to the master node. If
53+
no response is received before the timeout expires, the request fails and
54+
returns an error.
55+
:param timeout: Period to wait for a response. If no response is received before
56+
the timeout expires, the request fails and returns an error.
4657
"""
4758
if node_id in SKIP_IN_PATH:
4859
raise ValueError("Empty value passed for parameter 'node_id'")
@@ -54,8 +65,12 @@ async def delete_node(
5465
__query["filter_path"] = filter_path
5566
if human is not None:
5667
__query["human"] = human
68+
if master_timeout is not None:
69+
__query["master_timeout"] = master_timeout
5770
if pretty is not None:
5871
__query["pretty"] = pretty
72+
if timeout is not None:
73+
__query["timeout"] = timeout
5974
__headers = {"accept": "application/json"}
6075
return await self.perform_request( # type: ignore[return-value]
6176
"DELETE", __path, params=__query, headers=__headers
@@ -73,7 +88,13 @@ async def get_node(
7388
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
7489
] = None,
7590
human: t.Optional[bool] = None,
91+
master_timeout: t.Optional[
92+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
93+
] = None,
7694
pretty: t.Optional[bool] = None,
95+
timeout: t.Optional[
96+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
97+
] = None,
7798
) -> ObjectApiResponse[t.Any]:
7899
"""
79100
Retrieve status of a node or nodes that are currently marked as shutting down.
@@ -82,6 +103,11 @@ async def get_node(
82103
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
83104
84105
:param node_id: Which node for which to retrieve the shutdown status
106+
:param master_timeout: Period to wait for a connection to the master node. If
107+
no response is received before the timeout expires, the request fails and
108+
returns an error.
109+
:param timeout: Period to wait for a response. If no response is received before
110+
the timeout expires, the request fails and returns an error.
85111
"""
86112
if node_id not in SKIP_IN_PATH:
87113
__path = f"/_nodes/{_quote(node_id)}/shutdown"
@@ -94,24 +120,40 @@ async def get_node(
94120
__query["filter_path"] = filter_path
95121
if human is not None:
96122
__query["human"] = human
123+
if master_timeout is not None:
124+
__query["master_timeout"] = master_timeout
97125
if pretty is not None:
98126
__query["pretty"] = pretty
127+
if timeout is not None:
128+
__query["timeout"] = timeout
99129
__headers = {"accept": "application/json"}
100130
return await self.perform_request( # type: ignore[return-value]
101131
"GET", __path, params=__query, headers=__headers
102132
)
103133

104-
@_rewrite_parameters()
134+
@_rewrite_parameters(
135+
body_fields=True,
136+
)
105137
async def put_node(
106138
self,
107139
*,
108140
node_id: str,
141+
reason: str,
142+
type: t.Union["t.Literal['remove', 'replace', 'restart']", str],
143+
allocation_delay: t.Optional[str] = None,
109144
error_trace: t.Optional[bool] = None,
110145
filter_path: t.Optional[
111146
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
112147
] = None,
113148
human: t.Optional[bool] = None,
149+
master_timeout: t.Optional[
150+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
151+
] = None,
114152
pretty: t.Optional[bool] = None,
153+
target_node_name: t.Optional[str] = None,
154+
timeout: t.Optional[
155+
t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str]
156+
] = None,
115157
) -> ObjectApiResponse[t.Any]:
116158
"""
117159
Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct
@@ -120,20 +162,68 @@ async def put_node(
120162
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
121163
122164
:param node_id: The node id of node to be shut down
165+
:param reason: A human-readable reason that the node is being shut down. This
166+
field provides information for other cluster operators; it does not affect
167+
the shut down process.
168+
:param type: Valid values are restart, remove, or replace. Use restart when you
169+
need to temporarily shut down a node to perform an upgrade, make configuration
170+
changes, or perform other maintenance. Because the node is expected to rejoin
171+
the cluster, data is not migrated off of the node. Use remove when you need
172+
to permanently remove a node from the cluster. The node is not marked ready
173+
for shutdown until data is migrated off of the node Use replace to do a 1:1
174+
replacement of a node with another node. Certain allocation decisions will
175+
be ignored (such as disk watermarks) in the interest of true replacement
176+
of the source node with the target node. During a replace-type shutdown,
177+
rollover and index creation may result in unassigned shards, and shrink may
178+
fail until the replacement is complete.
179+
:param allocation_delay: Only valid if type is restart. Controls how long Elasticsearch
180+
will wait for the node to restart and join the cluster before reassigning
181+
its shards to other nodes. This works the same as delaying allocation with
182+
the index.unassigned.node_left.delayed_timeout setting. If you specify both
183+
a restart allocation delay and an index-level allocation delay, the longer
184+
of the two is used.
185+
:param master_timeout: Period to wait for a connection to the master node. If
186+
no response is received before the timeout expires, the request fails and
187+
returns an error.
188+
:param target_node_name: Only valid if type is replace. Specifies the name of
189+
the node that is replacing the node being shut down. Shards from the shut
190+
down node are only allowed to be allocated to the target node, and no other
191+
data will be allocated to the target node. During relocation of data certain
192+
allocation rules are ignored, such as disk watermarks or user attribute filtering
193+
rules.
194+
:param timeout: Period to wait for a response. If no response is received before
195+
the timeout expires, the request fails and returns an error.
123196
"""
124197
if node_id in SKIP_IN_PATH:
125198
raise ValueError("Empty value passed for parameter 'node_id'")
199+
if reason is None:
200+
raise ValueError("Empty value passed for parameter 'reason'")
201+
if type is None:
202+
raise ValueError("Empty value passed for parameter 'type'")
126203
__path = f"/_nodes/{_quote(node_id)}/shutdown"
204+
__body: t.Dict[str, t.Any] = {}
127205
__query: t.Dict[str, t.Any] = {}
206+
if reason is not None:
207+
__body["reason"] = reason
208+
if type is not None:
209+
__body["type"] = type
210+
if allocation_delay is not None:
211+
__body["allocation_delay"] = allocation_delay
128212
if error_trace is not None:
129213
__query["error_trace"] = error_trace
130214
if filter_path is not None:
131215
__query["filter_path"] = filter_path
132216
if human is not None:
133217
__query["human"] = human
218+
if master_timeout is not None:
219+
__query["master_timeout"] = master_timeout
134220
if pretty is not None:
135221
__query["pretty"] = pretty
136-
__headers = {"accept": "application/json"}
222+
if target_node_name is not None:
223+
__body["target_node_name"] = target_node_name
224+
if timeout is not None:
225+
__query["timeout"] = timeout
226+
__headers = {"accept": "application/json", "content-type": "application/json"}
137227
return await self.perform_request( # type: ignore[return-value]
138-
"PUT", __path, params=__query, headers=__headers
228+
"PUT", __path, params=__query, headers=__headers, body=__body
139229
)

0 commit comments

Comments
 (0)