Skip to content

Commit 47a5148

Browse files
authored
Update APIs to 8.3.0-SNAPSHOT
1 parent 0e16cd6 commit 47a5148

File tree

8 files changed

+370
-34
lines changed

8 files changed

+370
-34
lines changed

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/master/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/ml.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,10 +3620,10 @@ async def start_trained_model_deployment(
36203620
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
36213621
] = None,
36223622
human: t.Optional[bool] = None,
3623-
inference_threads: t.Optional[int] = None,
3624-
model_threads: t.Optional[int] = None,
3623+
number_of_allocations: t.Optional[int] = None,
36253624
pretty: t.Optional[bool] = None,
36263625
queue_capacity: t.Optional[int] = None,
3626+
threads_per_allocation: t.Optional[int] = None,
36273627
timeout: t.Optional[t.Union[int, str]] = None,
36283628
wait_for: t.Optional[
36293629
t.Union["t.Literal['fully_allocated', 'started', 'starting']", str]
@@ -3636,16 +3636,22 @@ async def start_trained_model_deployment(
36363636
36373637
:param model_id: The unique identifier of the trained model. Currently, only
36383638
PyTorch models are supported.
3639-
:param inference_threads: Specifies the number of threads that are used by the
3640-
inference process. If you increase this value, inference speed generally
3641-
increases. However, the actual number of threads is limited by the number
3642-
of available CPU cores.
3643-
:param model_threads: Specifies the number of threads that are used when sending
3644-
inference requests to the model. If you increase this value, throughput generally
3645-
increases.
3639+
:param number_of_allocations: The number of model allocations on each node where
3640+
the model is deployed. All allocations on a node share the same copy of the
3641+
model in memory but use a separate set of threads to evaluate the model.
3642+
Increasing this value generally increases the throughput. If this setting
3643+
is greater than the number of hardware threads it will automatically be changed
3644+
to a value less than the number of hardware threads.
36463645
:param queue_capacity: Specifies the number of inference requests that are allowed
36473646
in the queue. After the number of requests exceeds this value, new requests
36483647
are rejected with a 429 error.
3648+
:param threads_per_allocation: Sets the number of threads used by each model
3649+
allocation during inference. This generally increases the inference speed.
3650+
The inference process is a compute-bound process; any number greater than
3651+
the number of available hardware threads on the machine does not increase
3652+
the inference speed. If this setting is greater than the number of hardware
3653+
threads it will automatically be changed to a value less than the number
3654+
of hardware threads.
36493655
:param timeout: Specifies the amount of time to wait for the model to deploy.
36503656
:param wait_for: Specifies the allocation status to wait for before returning.
36513657
"""
@@ -3659,14 +3665,14 @@ async def start_trained_model_deployment(
36593665
__query["filter_path"] = filter_path
36603666
if human is not None:
36613667
__query["human"] = human
3662-
if inference_threads is not None:
3663-
__query["inference_threads"] = inference_threads
3664-
if model_threads is not None:
3665-
__query["model_threads"] = model_threads
3668+
if number_of_allocations is not None:
3669+
__query["number_of_allocations"] = number_of_allocations
36663670
if pretty is not None:
36673671
__query["pretty"] = pretty
36683672
if queue_capacity is not None:
36693673
__query["queue_capacity"] = queue_capacity
3674+
if threads_per_allocation is not None:
3675+
__query["threads_per_allocation"] = threads_per_allocation
36703676
if timeout is not None:
36713677
__query["timeout"] = timeout
36723678
if wait_for is not None:

elasticsearch/_async/client/security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ async def grant_api_key(
15081508
async def has_privileges(
15091509
self,
15101510
*,
1511-
user: t.Optional[t.Union[None, str]] = None,
1511+
user: t.Optional[str] = None,
15121512
application: t.Optional[
15131513
t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]]
15141514
] = 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)