Skip to content

Commit 5ffb4e4

Browse files
Auto-generated code for main (#3327)
* Auto-generated API code * bring back the streams namespace * missing docs file --------- Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
1 parent 56b8ba2 commit 5ffb4e4

File tree

18 files changed

+478
-19
lines changed

18 files changed

+478
-19
lines changed

docs/sphinx/api/streams.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. _streams:
2+
3+
Streams
4+
-------
5+
.. py:module:: elasticsearch.client
6+
:no-index:
7+
8+
.. autoclass:: StreamsClient
9+
:members:

docs/sphinx/es_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ arguments are required for all calls.
5151
api/snapshots
5252
api/snapshottable-features
5353
api/sql
54+
api/streams
5455
api/synonyms
5556
api/tls-ssl
5657
api/tasks

elasticsearch/_async/client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
from .snapshot import SnapshotClient
7676
from .sql import SqlClient
7777
from .ssl import SslClient
78+
from .streams import StreamsClient
7879
from .synonyms import SynonymsClient
7980
from .tasks import TasksClient
8081
from .text_structure import TextStructureClient
@@ -380,6 +381,7 @@ def __init__(
380381
self.shutdown = ShutdownClient(self)
381382
self.sql = SqlClient(self)
382383
self.ssl = SslClient(self)
384+
self.streams = StreamsClient(self)
383385
self.synonyms = SynonymsClient(self)
384386
self.text_structure = TextStructureClient(self)
385387
self.transform = TransformClient(self)

elasticsearch/_async/client/cat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ async def count(
649649
The document count only includes live documents, not deleted documents which have not yet been removed by the merge process.</p>
650650
<p>IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console.
651651
They are not intended for use by applications. For application consumption, use the count API.</p>
652+
<p>NOTE: Starting in Elasticsearch 9.3.0, this endpoint also supports the <code>POST</code> method. This is primarily intended for project routing in serverless environments.</p>
652653
653654
654655
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-count>`_

elasticsearch/_async/client/esql.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class EsqlClient(NamespacedClient):
4646
"locale",
4747
"params",
4848
"profile",
49+
"project_routing",
4950
"tables",
5051
"time_zone",
5152
"wait_for_completion_timeout",
@@ -80,6 +81,7 @@ async def async_query(
8081
params: t.Optional[t.Sequence[t.Union[None, bool, float, int, str]]] = None,
8182
pretty: t.Optional[bool] = None,
8283
profile: t.Optional[bool] = None,
84+
project_routing: t.Optional[str] = None,
8385
tables: t.Optional[
8486
t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]
8587
] = None,
@@ -151,6 +153,10 @@ async def async_query(
151153
object with information on how the query was executed. This information is
152154
for human debugging and its format can change at any time but it can give
153155
some insight into the performance of each part of the query.
156+
:param project_routing: Specifies a subset of projects to target using project
157+
metadata tags in a subset of Lucene query syntax. Allowed Lucene queries:
158+
the _alias tag and a single value (possibly wildcarded). Examples: _alias:my-project
159+
_alias:_origin _alias:*pr* Supported in serverless only.
154160
:param tables: Tables to use with the LOOKUP operation. The top level key is
155161
the table name and the next level key is the column name.
156162
:param time_zone: Sets the default timezone of the query.
@@ -202,6 +208,8 @@ async def async_query(
202208
__body["params"] = params
203209
if profile is not None:
204210
__body["profile"] = profile
211+
if project_routing is not None:
212+
__body["project_routing"] = project_routing
205213
if tables is not None:
206214
__body["tables"] = tables
207215
if time_zone is not None:
@@ -504,6 +512,7 @@ async def list_queries(
504512
"locale",
505513
"params",
506514
"profile",
515+
"project_routing",
507516
"tables",
508517
"time_zone",
509518
),
@@ -553,6 +562,7 @@ async def query(
553562
] = None,
554563
pretty: t.Optional[bool] = None,
555564
profile: t.Optional[bool] = None,
565+
project_routing: t.Optional[str] = None,
556566
tables: t.Optional[
557567
t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]
558568
] = None,
@@ -607,6 +617,10 @@ async def query(
607617
object with information on how the query was executed. This information is
608618
for human debugging and its format can change at any time but it can give
609619
some insight into the performance of each part of the query.
620+
:param project_routing: Specifies a subset of projects to target using project
621+
metadata tags in a subset of Lucene query syntax. Allowed Lucene queries:
622+
the _alias tag and a single value (possibly wildcarded). Examples: _alias:my-project
623+
_alias:_origin _alias:*pr* Supported in serverless only.
610624
:param tables: Tables to use with the LOOKUP operation. The top level key is
611625
the table name and the next level key is the column name.
612626
:param time_zone: Sets the default timezone of the query.
@@ -650,6 +664,8 @@ async def query(
650664
__body["params"] = params
651665
if profile is not None:
652666
__body["profile"] = profile
667+
if project_routing is not None:
668+
__body["project_routing"] = project_routing
653669
if tables is not None:
654670
__body["tables"] = tables
655671
if time_zone is not None:

elasticsearch/_async/client/indices.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,12 +3516,12 @@ async def put_alias(
35163516
filter: t.Optional[t.Mapping[str, t.Any]] = None,
35173517
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
35183518
human: t.Optional[bool] = None,
3519-
index_routing: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3519+
index_routing: t.Optional[str] = None,
35203520
is_write_index: t.Optional[bool] = None,
35213521
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
35223522
pretty: t.Optional[bool] = None,
3523-
routing: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3524-
search_routing: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3523+
routing: t.Optional[str] = None,
3524+
search_routing: t.Optional[str] = None,
35253525
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
35263526
body: t.Optional[t.Dict[str, t.Any]] = None,
35273527
) -> ObjectApiResponse[t.Any]:
@@ -5502,6 +5502,7 @@ async def shrink(
55025502
For example an index with 8 primary shards can be shrunk into 4, 2 or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1.
55035503
If the number of shards in the index is a prime number it can only be shrunk into a single primary shard
55045504
Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node.</p>
5505+
<p>IMPORTANT: If the source index already has one primary shard, configuring the shrink operation with 'index.number_of_shards: 1' will cause the request to fail. An index with one primary shard cannot be shrunk further.</p>
55055506
<p>The current write index on a data stream cannot be shrunk. In order to shrink the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be shrunk.</p>
55065507
<p>A shrink operation:</p>
55075508
<ul>

elasticsearch/_async/client/inference.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,10 @@ async def get(
274274
275275
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-get>`_
276276
277-
:param task_type: The task type
278-
:param inference_id: The inference Id
277+
:param task_type: The task type of the endpoint to return
278+
:param inference_id: The inference Id of the endpoint to return. Using `_all`
279+
or `*` will return all endpoints with the specified `task_type` if one is
280+
specified, or all endpoints for all task types if no `task_type` is specified
279281
"""
280282
__path_parts: t.Dict[str, str]
281283
if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH:
@@ -284,6 +286,9 @@ async def get(
284286
"inference_id": _quote(inference_id),
285287
}
286288
__path = f'/_inference/{__path_parts["task_type"]}/{__path_parts["inference_id"]}'
289+
elif task_type not in SKIP_IN_PATH:
290+
__path_parts = {"task_type": _quote(task_type)}
291+
__path = f'/_inference/{__path_parts["task_type"]}/_all'
287292
elif inference_id not in SKIP_IN_PATH:
288293
__path_parts = {"inference_id": _quote(inference_id)}
289294
__path = f'/_inference/{__path_parts["inference_id"]}'
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
import typing as t
19+
20+
from elastic_transport import ObjectApiResponse, TextApiResponse
21+
22+
from ._base import NamespacedClient
23+
from .utils import (
24+
SKIP_IN_PATH,
25+
Stability,
26+
_availability_warning,
27+
_quote,
28+
_rewrite_parameters,
29+
)
30+
31+
32+
class StreamsClient(NamespacedClient):
33+
34+
@_rewrite_parameters()
35+
@_availability_warning(Stability.EXPERIMENTAL)
36+
async def logs_disable(
37+
self,
38+
*,
39+
name: t.Union[str, t.Literal["logs", "logs.ecs", "logs.otel"]],
40+
error_trace: t.Optional[bool] = None,
41+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
42+
human: t.Optional[bool] = None,
43+
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
44+
pretty: t.Optional[bool] = None,
45+
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
46+
) -> t.Union[ObjectApiResponse[t.Any], TextApiResponse]:
47+
"""
48+
.. raw:: html
49+
50+
<p>Disable a named stream.</p>
51+
<p>Turn off the named stream feature for this cluster.</p>
52+
53+
54+
`<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_
55+
56+
:param name: The stream type to disable.
57+
:param master_timeout: The period to wait for a connection to the master node.
58+
If no response is received before the timeout expires, the request fails
59+
and returns an error.
60+
:param timeout: The period to wait for a response. If no response is received
61+
before the timeout expires, the request fails and returns an error.
62+
"""
63+
if name in SKIP_IN_PATH:
64+
raise ValueError("Empty value passed for parameter 'name'")
65+
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
66+
__path = f'/_streams/{__path_parts["name"]}/_disable'
67+
__query: t.Dict[str, t.Any] = {}
68+
if error_trace is not None:
69+
__query["error_trace"] = error_trace
70+
if filter_path is not None:
71+
__query["filter_path"] = filter_path
72+
if human is not None:
73+
__query["human"] = human
74+
if master_timeout is not None:
75+
__query["master_timeout"] = master_timeout
76+
if pretty is not None:
77+
__query["pretty"] = pretty
78+
if timeout is not None:
79+
__query["timeout"] = timeout
80+
__headers = {"accept": "text/plain,application/json"}
81+
return await self.perform_request( # type: ignore[return-value]
82+
"POST",
83+
__path,
84+
params=__query,
85+
headers=__headers,
86+
endpoint_id="streams.logs_disable",
87+
path_parts=__path_parts,
88+
)
89+
90+
@_rewrite_parameters()
91+
@_availability_warning(Stability.EXPERIMENTAL)
92+
async def logs_enable(
93+
self,
94+
*,
95+
name: t.Union[str, t.Literal["logs", "logs.ecs", "logs.otel"]],
96+
error_trace: t.Optional[bool] = None,
97+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
98+
human: t.Optional[bool] = None,
99+
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
100+
pretty: t.Optional[bool] = None,
101+
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
102+
) -> t.Union[ObjectApiResponse[t.Any], TextApiResponse]:
103+
"""
104+
.. raw:: html
105+
106+
<p>Enable a named stream.</p>
107+
<p>Turn on the named stream feature for this cluster.</p>
108+
<p>NOTE: To protect existing data, this feature can be turned on only if the cluster does not have
109+
existing indices or data streams that match the pattern <code>&lt;name&gt;|&lt;name&gt;.*</code> for the enabled stream
110+
type name. If those indices or data streams exist, a <code>409 - Conflict</code> response and error is
111+
returned.</p>
112+
113+
114+
`<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_
115+
116+
:param name: The stream type to enable.
117+
:param master_timeout: The period to wait for a connection to the master node.
118+
If no response is received before the timeout expires, the request fails
119+
and returns an error.
120+
:param timeout: The period to wait for a response. If no response is received
121+
before the timeout expires, the request fails and returns an error.
122+
"""
123+
if name in SKIP_IN_PATH:
124+
raise ValueError("Empty value passed for parameter 'name'")
125+
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
126+
__path = f'/_streams/{__path_parts["name"]}/_enable'
127+
__query: t.Dict[str, t.Any] = {}
128+
if error_trace is not None:
129+
__query["error_trace"] = error_trace
130+
if filter_path is not None:
131+
__query["filter_path"] = filter_path
132+
if human is not None:
133+
__query["human"] = human
134+
if master_timeout is not None:
135+
__query["master_timeout"] = master_timeout
136+
if pretty is not None:
137+
__query["pretty"] = pretty
138+
if timeout is not None:
139+
__query["timeout"] = timeout
140+
__headers = {"accept": "text/plain,application/json"}
141+
return await self.perform_request( # type: ignore[return-value]
142+
"POST",
143+
__path,
144+
params=__query,
145+
headers=__headers,
146+
endpoint_id="streams.logs_enable",
147+
path_parts=__path_parts,
148+
)
149+
150+
@_rewrite_parameters()
151+
@_availability_warning(Stability.EXPERIMENTAL)
152+
async def status(
153+
self,
154+
*,
155+
error_trace: t.Optional[bool] = None,
156+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
157+
human: t.Optional[bool] = None,
158+
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
159+
pretty: t.Optional[bool] = None,
160+
) -> ObjectApiResponse[t.Any]:
161+
"""
162+
.. raw:: html
163+
164+
<p>Get the status of streams.</p>
165+
<p>Get the current status for all types of streams.</p>
166+
167+
168+
`<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_
169+
170+
:param master_timeout: Period to wait for a connection to the master node. If
171+
no response is received before the timeout expires, the request fails and
172+
returns an error.
173+
"""
174+
__path_parts: t.Dict[str, str] = {}
175+
__path = "/_streams/status"
176+
__query: t.Dict[str, t.Any] = {}
177+
if error_trace is not None:
178+
__query["error_trace"] = error_trace
179+
if filter_path is not None:
180+
__query["filter_path"] = filter_path
181+
if human is not None:
182+
__query["human"] = human
183+
if master_timeout is not None:
184+
__query["master_timeout"] = master_timeout
185+
if pretty is not None:
186+
__query["pretty"] = pretty
187+
__headers = {"accept": "application/json"}
188+
return await self.perform_request( # type: ignore[return-value]
189+
"GET",
190+
__path,
191+
params=__query,
192+
headers=__headers,
193+
endpoint_id="streams.status",
194+
path_parts=__path_parts,
195+
)

elasticsearch/_sync/client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
from .snapshot import SnapshotClient
7676
from .sql import SqlClient
7777
from .ssl import SslClient
78+
from .streams import StreamsClient
7879
from .synonyms import SynonymsClient
7980
from .tasks import TasksClient
8081
from .text_structure import TextStructureClient
@@ -380,6 +381,7 @@ def __init__(
380381
self.shutdown = ShutdownClient(self)
381382
self.sql = SqlClient(self)
382383
self.ssl = SslClient(self)
384+
self.streams = StreamsClient(self)
383385
self.synonyms = SynonymsClient(self)
384386
self.text_structure = TextStructureClient(self)
385387
self.transform = TransformClient(self)

elasticsearch/_sync/client/cat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ def count(
649649
The document count only includes live documents, not deleted documents which have not yet been removed by the merge process.</p>
650650
<p>IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console.
651651
They are not intended for use by applications. For application consumption, use the count API.</p>
652+
<p>NOTE: Starting in Elasticsearch 9.3.0, this endpoint also supports the <code>POST</code> method. This is primarily intended for project routing in serverless environments.</p>
652653
653654
654655
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-count>`_

0 commit comments

Comments
 (0)