elasticsearch9 9.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. elasticsearch9/__init__.py +98 -0
  2. elasticsearch9/_async/__init__.py +16 -0
  3. elasticsearch9/_async/client/__init__.py +6531 -0
  4. elasticsearch9/_async/client/_base.py +430 -0
  5. elasticsearch9/_async/client/async_search.py +637 -0
  6. elasticsearch9/_async/client/autoscaling.py +252 -0
  7. elasticsearch9/_async/client/cat.py +2995 -0
  8. elasticsearch9/_async/client/ccr.py +1043 -0
  9. elasticsearch9/_async/client/cluster.py +1223 -0
  10. elasticsearch9/_async/client/connector.py +1978 -0
  11. elasticsearch9/_async/client/dangling_indices.py +192 -0
  12. elasticsearch9/_async/client/enrich.py +291 -0
  13. elasticsearch9/_async/client/eql.py +359 -0
  14. elasticsearch9/_async/client/esql.py +490 -0
  15. elasticsearch9/_async/client/features.py +130 -0
  16. elasticsearch9/_async/client/fleet.py +658 -0
  17. elasticsearch9/_async/client/graph.py +113 -0
  18. elasticsearch9/_async/client/ilm.py +668 -0
  19. elasticsearch9/_async/client/indices.py +5582 -0
  20. elasticsearch9/_async/client/inference.py +2247 -0
  21. elasticsearch9/_async/client/ingest.py +766 -0
  22. elasticsearch9/_async/client/license.py +400 -0
  23. elasticsearch9/_async/client/logstash.py +176 -0
  24. elasticsearch9/_async/client/migration.py +160 -0
  25. elasticsearch9/_async/client/ml.py +5835 -0
  26. elasticsearch9/_async/client/monitoring.py +100 -0
  27. elasticsearch9/_async/client/nodes.py +543 -0
  28. elasticsearch9/_async/client/query_rules.py +485 -0
  29. elasticsearch9/_async/client/rollup.py +616 -0
  30. elasticsearch9/_async/client/search_application.py +574 -0
  31. elasticsearch9/_async/client/searchable_snapshots.py +313 -0
  32. elasticsearch9/_async/client/security.py +4688 -0
  33. elasticsearch9/_async/client/shutdown.py +268 -0
  34. elasticsearch9/_async/client/simulate.py +145 -0
  35. elasticsearch9/_async/client/slm.py +559 -0
  36. elasticsearch9/_async/client/snapshot.py +1338 -0
  37. elasticsearch9/_async/client/sql.py +469 -0
  38. elasticsearch9/_async/client/ssl.py +76 -0
  39. elasticsearch9/_async/client/synonyms.py +413 -0
  40. elasticsearch9/_async/client/tasks.py +295 -0
  41. elasticsearch9/_async/client/text_structure.py +664 -0
  42. elasticsearch9/_async/client/transform.py +922 -0
  43. elasticsearch9/_async/client/utils.py +48 -0
  44. elasticsearch9/_async/client/watcher.py +894 -0
  45. elasticsearch9/_async/client/xpack.py +134 -0
  46. elasticsearch9/_async/helpers.py +596 -0
  47. elasticsearch9/_otel.py +110 -0
  48. elasticsearch9/_sync/__init__.py +16 -0
  49. elasticsearch9/_sync/client/__init__.py +6529 -0
  50. elasticsearch9/_sync/client/_base.py +430 -0
  51. elasticsearch9/_sync/client/async_search.py +637 -0
  52. elasticsearch9/_sync/client/autoscaling.py +252 -0
  53. elasticsearch9/_sync/client/cat.py +2995 -0
  54. elasticsearch9/_sync/client/ccr.py +1043 -0
  55. elasticsearch9/_sync/client/cluster.py +1223 -0
  56. elasticsearch9/_sync/client/connector.py +1978 -0
  57. elasticsearch9/_sync/client/dangling_indices.py +192 -0
  58. elasticsearch9/_sync/client/enrich.py +291 -0
  59. elasticsearch9/_sync/client/eql.py +359 -0
  60. elasticsearch9/_sync/client/esql.py +490 -0
  61. elasticsearch9/_sync/client/features.py +130 -0
  62. elasticsearch9/_sync/client/fleet.py +658 -0
  63. elasticsearch9/_sync/client/graph.py +113 -0
  64. elasticsearch9/_sync/client/ilm.py +668 -0
  65. elasticsearch9/_sync/client/indices.py +5582 -0
  66. elasticsearch9/_sync/client/inference.py +2247 -0
  67. elasticsearch9/_sync/client/ingest.py +766 -0
  68. elasticsearch9/_sync/client/license.py +400 -0
  69. elasticsearch9/_sync/client/logstash.py +176 -0
  70. elasticsearch9/_sync/client/migration.py +160 -0
  71. elasticsearch9/_sync/client/ml.py +5835 -0
  72. elasticsearch9/_sync/client/monitoring.py +100 -0
  73. elasticsearch9/_sync/client/nodes.py +543 -0
  74. elasticsearch9/_sync/client/query_rules.py +485 -0
  75. elasticsearch9/_sync/client/rollup.py +616 -0
  76. elasticsearch9/_sync/client/search_application.py +574 -0
  77. elasticsearch9/_sync/client/searchable_snapshots.py +313 -0
  78. elasticsearch9/_sync/client/security.py +4688 -0
  79. elasticsearch9/_sync/client/shutdown.py +268 -0
  80. elasticsearch9/_sync/client/simulate.py +145 -0
  81. elasticsearch9/_sync/client/slm.py +559 -0
  82. elasticsearch9/_sync/client/snapshot.py +1338 -0
  83. elasticsearch9/_sync/client/sql.py +469 -0
  84. elasticsearch9/_sync/client/ssl.py +76 -0
  85. elasticsearch9/_sync/client/synonyms.py +413 -0
  86. elasticsearch9/_sync/client/tasks.py +295 -0
  87. elasticsearch9/_sync/client/text_structure.py +664 -0
  88. elasticsearch9/_sync/client/transform.py +922 -0
  89. elasticsearch9/_sync/client/utils.py +475 -0
  90. elasticsearch9/_sync/client/watcher.py +894 -0
  91. elasticsearch9/_sync/client/xpack.py +134 -0
  92. elasticsearch9/_utils.py +34 -0
  93. elasticsearch9/_version.py +18 -0
  94. elasticsearch9/client.py +126 -0
  95. elasticsearch9/compat.py +79 -0
  96. elasticsearch9/dsl/__init__.py +203 -0
  97. elasticsearch9/dsl/_async/__init__.py +16 -0
  98. elasticsearch9/dsl/_async/document.py +522 -0
  99. elasticsearch9/dsl/_async/faceted_search.py +50 -0
  100. elasticsearch9/dsl/_async/index.py +639 -0
  101. elasticsearch9/dsl/_async/mapping.py +49 -0
  102. elasticsearch9/dsl/_async/search.py +237 -0
  103. elasticsearch9/dsl/_async/update_by_query.py +47 -0
  104. elasticsearch9/dsl/_sync/__init__.py +16 -0
  105. elasticsearch9/dsl/_sync/document.py +514 -0
  106. elasticsearch9/dsl/_sync/faceted_search.py +50 -0
  107. elasticsearch9/dsl/_sync/index.py +597 -0
  108. elasticsearch9/dsl/_sync/mapping.py +49 -0
  109. elasticsearch9/dsl/_sync/search.py +230 -0
  110. elasticsearch9/dsl/_sync/update_by_query.py +45 -0
  111. elasticsearch9/dsl/aggs.py +3734 -0
  112. elasticsearch9/dsl/analysis.py +341 -0
  113. elasticsearch9/dsl/async_connections.py +37 -0
  114. elasticsearch9/dsl/connections.py +142 -0
  115. elasticsearch9/dsl/document.py +20 -0
  116. elasticsearch9/dsl/document_base.py +444 -0
  117. elasticsearch9/dsl/exceptions.py +32 -0
  118. elasticsearch9/dsl/faceted_search.py +28 -0
  119. elasticsearch9/dsl/faceted_search_base.py +489 -0
  120. elasticsearch9/dsl/field.py +4392 -0
  121. elasticsearch9/dsl/function.py +180 -0
  122. elasticsearch9/dsl/index.py +23 -0
  123. elasticsearch9/dsl/index_base.py +178 -0
  124. elasticsearch9/dsl/mapping.py +19 -0
  125. elasticsearch9/dsl/mapping_base.py +219 -0
  126. elasticsearch9/dsl/query.py +2822 -0
  127. elasticsearch9/dsl/response/__init__.py +388 -0
  128. elasticsearch9/dsl/response/aggs.py +100 -0
  129. elasticsearch9/dsl/response/hit.py +53 -0
  130. elasticsearch9/dsl/search.py +20 -0
  131. elasticsearch9/dsl/search_base.py +1053 -0
  132. elasticsearch9/dsl/serializer.py +34 -0
  133. elasticsearch9/dsl/types.py +6453 -0
  134. elasticsearch9/dsl/update_by_query.py +19 -0
  135. elasticsearch9/dsl/update_by_query_base.py +149 -0
  136. elasticsearch9/dsl/utils.py +687 -0
  137. elasticsearch9/dsl/wrappers.py +144 -0
  138. elasticsearch9/exceptions.py +133 -0
  139. elasticsearch9/helpers/__init__.py +41 -0
  140. elasticsearch9/helpers/actions.py +875 -0
  141. elasticsearch9/helpers/errors.py +40 -0
  142. elasticsearch9/helpers/vectorstore/__init__.py +62 -0
  143. elasticsearch9/helpers/vectorstore/_async/__init__.py +16 -0
  144. elasticsearch9/helpers/vectorstore/_async/_utils.py +39 -0
  145. elasticsearch9/helpers/vectorstore/_async/embedding_service.py +89 -0
  146. elasticsearch9/helpers/vectorstore/_async/strategies.py +487 -0
  147. elasticsearch9/helpers/vectorstore/_async/vectorstore.py +421 -0
  148. elasticsearch9/helpers/vectorstore/_sync/__init__.py +16 -0
  149. elasticsearch9/helpers/vectorstore/_sync/_utils.py +39 -0
  150. elasticsearch9/helpers/vectorstore/_sync/embedding_service.py +89 -0
  151. elasticsearch9/helpers/vectorstore/_sync/strategies.py +487 -0
  152. elasticsearch9/helpers/vectorstore/_sync/vectorstore.py +421 -0
  153. elasticsearch9/helpers/vectorstore/_utils.py +116 -0
  154. elasticsearch9/py.typed +0 -0
  155. elasticsearch9/serializer.py +250 -0
  156. elasticsearch9-9.0.0.dist-info/METADATA +175 -0
  157. elasticsearch9-9.0.0.dist-info/RECORD +160 -0
  158. elasticsearch9-9.0.0.dist-info/WHEEL +4 -0
  159. elasticsearch9-9.0.0.dist-info/licenses/LICENSE +176 -0
  160. elasticsearch9-9.0.0.dist-info/licenses/NOTICE +2 -0
@@ -0,0 +1,490 @@
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
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
24
+
25
+
26
+ class EsqlClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters(
29
+ body_fields=(
30
+ "query",
31
+ "columnar",
32
+ "filter",
33
+ "include_ccs_metadata",
34
+ "locale",
35
+ "params",
36
+ "profile",
37
+ "tables",
38
+ "wait_for_completion_timeout",
39
+ ),
40
+ ignore_deprecated_options={"params"},
41
+ )
42
+ async def async_query(
43
+ self,
44
+ *,
45
+ query: t.Optional[str] = None,
46
+ columnar: t.Optional[bool] = None,
47
+ delimiter: t.Optional[str] = None,
48
+ drop_null_columns: t.Optional[bool] = None,
49
+ error_trace: t.Optional[bool] = None,
50
+ filter: t.Optional[t.Mapping[str, t.Any]] = None,
51
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
52
+ format: t.Optional[
53
+ t.Union[
54
+ str,
55
+ t.Literal[
56
+ "arrow", "cbor", "csv", "json", "smile", "tsv", "txt", "yaml"
57
+ ],
58
+ ]
59
+ ] = None,
60
+ human: t.Optional[bool] = None,
61
+ include_ccs_metadata: t.Optional[bool] = None,
62
+ keep_alive: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
63
+ keep_on_completion: t.Optional[bool] = None,
64
+ locale: t.Optional[str] = None,
65
+ params: t.Optional[t.Sequence[t.Union[None, bool, float, int, str]]] = None,
66
+ pretty: t.Optional[bool] = None,
67
+ profile: t.Optional[bool] = None,
68
+ tables: t.Optional[
69
+ t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]
70
+ ] = None,
71
+ wait_for_completion_timeout: t.Optional[
72
+ t.Union[str, t.Literal[-1], t.Literal[0]]
73
+ ] = None,
74
+ body: t.Optional[t.Dict[str, t.Any]] = None,
75
+ ) -> ObjectApiResponse[t.Any]:
76
+ """
77
+ .. raw:: html
78
+
79
+ <p>Run an async ES|QL query.
80
+ Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available.</p>
81
+ <p>The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties.</p>
82
+
83
+
84
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-esql-async-query>`_
85
+
86
+ :param query: The ES|QL query API accepts an ES|QL query string in the query
87
+ parameter, runs it, and returns the results.
88
+ :param columnar: By default, ES|QL returns results as rows. For example, FROM
89
+ returns each individual document as one row. For the JSON, YAML, CBOR and
90
+ smile formats, ES|QL can return the results in a columnar fashion where one
91
+ row represents all the values of a certain column in the results.
92
+ :param delimiter: The character to use between values within a CSV row. It is
93
+ valid only for the CSV format.
94
+ :param drop_null_columns: Indicates whether columns that are entirely `null`
95
+ will be removed from the `columns` and `values` portion of the results. If
96
+ `true`, the response will include an extra section under the name `all_columns`
97
+ which has the name of all the columns.
98
+ :param filter: Specify a Query DSL query in the filter parameter to filter the
99
+ set of documents that an ES|QL query runs on.
100
+ :param format: A short version of the Accept header, for example `json` or `yaml`.
101
+ :param include_ccs_metadata: When set to `true` and performing a cross-cluster
102
+ query, the response will include an extra `_clusters` object with information
103
+ about the clusters that participated in the search along with info such as
104
+ shards count.
105
+ :param keep_alive: The period for which the query and its results are stored
106
+ in the cluster. The default period is five days. When this period expires,
107
+ the query and its results are deleted, even if the query is still ongoing.
108
+ If the `keep_on_completion` parameter is false, Elasticsearch only stores
109
+ async queries that do not complete within the period set by the `wait_for_completion_timeout`
110
+ parameter, regardless of this value.
111
+ :param keep_on_completion: Indicates whether the query and its results are stored
112
+ in the cluster. If false, the query and its results are stored in the cluster
113
+ only if the request does not complete during the period set by the `wait_for_completion_timeout`
114
+ parameter.
115
+ :param locale:
116
+ :param params: To avoid any attempts of hacking or code injection, extract the
117
+ values in a separate list of parameters. Use question mark placeholders (?)
118
+ in the query string for each of the parameters.
119
+ :param profile: If provided and `true` the response will include an extra `profile`
120
+ object with information on how the query was executed. This information is
121
+ for human debugging and its format can change at any time but it can give
122
+ some insight into the performance of each part of the query.
123
+ :param tables: Tables to use with the LOOKUP operation. The top level key is
124
+ the table name and the next level key is the column name.
125
+ :param wait_for_completion_timeout: The period to wait for the request to finish.
126
+ By default, the request waits for 1 second for the query results. If the
127
+ query completes during this period, results are returned Otherwise, a query
128
+ ID is returned that can later be used to retrieve the results.
129
+ """
130
+ if query is None and body is None:
131
+ raise ValueError("Empty value passed for parameter 'query'")
132
+ __path_parts: t.Dict[str, str] = {}
133
+ __path = "/_query/async"
134
+ __query: t.Dict[str, t.Any] = {}
135
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
136
+ if delimiter is not None:
137
+ __query["delimiter"] = delimiter
138
+ if drop_null_columns is not None:
139
+ __query["drop_null_columns"] = drop_null_columns
140
+ if error_trace is not None:
141
+ __query["error_trace"] = error_trace
142
+ if filter_path is not None:
143
+ __query["filter_path"] = filter_path
144
+ if format is not None:
145
+ __query["format"] = format
146
+ if human is not None:
147
+ __query["human"] = human
148
+ if keep_alive is not None:
149
+ __query["keep_alive"] = keep_alive
150
+ if keep_on_completion is not None:
151
+ __query["keep_on_completion"] = keep_on_completion
152
+ if pretty is not None:
153
+ __query["pretty"] = pretty
154
+ if not __body:
155
+ if query is not None:
156
+ __body["query"] = query
157
+ if columnar is not None:
158
+ __body["columnar"] = columnar
159
+ if filter is not None:
160
+ __body["filter"] = filter
161
+ if include_ccs_metadata is not None:
162
+ __body["include_ccs_metadata"] = include_ccs_metadata
163
+ if locale is not None:
164
+ __body["locale"] = locale
165
+ if params is not None:
166
+ __body["params"] = params
167
+ if profile is not None:
168
+ __body["profile"] = profile
169
+ if tables is not None:
170
+ __body["tables"] = tables
171
+ if wait_for_completion_timeout is not None:
172
+ __body["wait_for_completion_timeout"] = wait_for_completion_timeout
173
+ __headers = {"accept": "application/json", "content-type": "application/json"}
174
+ return await self.perform_request( # type: ignore[return-value]
175
+ "POST",
176
+ __path,
177
+ params=__query,
178
+ headers=__headers,
179
+ body=__body,
180
+ endpoint_id="esql.async_query",
181
+ path_parts=__path_parts,
182
+ )
183
+
184
+ @_rewrite_parameters()
185
+ async def async_query_delete(
186
+ self,
187
+ *,
188
+ id: str,
189
+ error_trace: t.Optional[bool] = None,
190
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
191
+ human: t.Optional[bool] = None,
192
+ pretty: t.Optional[bool] = None,
193
+ ) -> ObjectApiResponse[t.Any]:
194
+ """
195
+ .. raw:: html
196
+
197
+ <p>Delete an async ES|QL query.
198
+ If the query is still running, it is cancelled.
199
+ Otherwise, the stored results are deleted.</p>
200
+ <p>If the Elasticsearch security features are enabled, only the following users can use this API to delete a query:</p>
201
+ <ul>
202
+ <li>The authenticated user that submitted the original query request</li>
203
+ <li>Users with the <code>cancel_task</code> cluster privilege</li>
204
+ </ul>
205
+
206
+
207
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-esql-async-query-delete>`_
208
+
209
+ :param id: The unique identifier of the query. A query ID is provided in the
210
+ ES|QL async query API response for a query that does not complete in the
211
+ designated time. A query ID is also provided when the request was submitted
212
+ with the `keep_on_completion` parameter set to `true`.
213
+ """
214
+ if id in SKIP_IN_PATH:
215
+ raise ValueError("Empty value passed for parameter 'id'")
216
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
217
+ __path = f'/_query/async/{__path_parts["id"]}'
218
+ __query: t.Dict[str, t.Any] = {}
219
+ if error_trace is not None:
220
+ __query["error_trace"] = error_trace
221
+ if filter_path is not None:
222
+ __query["filter_path"] = filter_path
223
+ if human is not None:
224
+ __query["human"] = human
225
+ if pretty is not None:
226
+ __query["pretty"] = pretty
227
+ __headers = {"accept": "application/json"}
228
+ return await self.perform_request( # type: ignore[return-value]
229
+ "DELETE",
230
+ __path,
231
+ params=__query,
232
+ headers=__headers,
233
+ endpoint_id="esql.async_query_delete",
234
+ path_parts=__path_parts,
235
+ )
236
+
237
+ @_rewrite_parameters()
238
+ async def async_query_get(
239
+ self,
240
+ *,
241
+ id: str,
242
+ drop_null_columns: t.Optional[bool] = None,
243
+ error_trace: t.Optional[bool] = None,
244
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
245
+ human: t.Optional[bool] = None,
246
+ keep_alive: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
247
+ pretty: t.Optional[bool] = None,
248
+ wait_for_completion_timeout: t.Optional[
249
+ t.Union[str, t.Literal[-1], t.Literal[0]]
250
+ ] = None,
251
+ ) -> ObjectApiResponse[t.Any]:
252
+ """
253
+ .. raw:: html
254
+
255
+ <p>Get async ES|QL query results.
256
+ Get the current status and available results or stored results for an ES|QL asynchronous query.
257
+ If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can retrieve the results using this API.</p>
258
+
259
+
260
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-esql-async-query-get>`_
261
+
262
+ :param id: The unique identifier of the query. A query ID is provided in the
263
+ ES|QL async query API response for a query that does not complete in the
264
+ designated time. A query ID is also provided when the request was submitted
265
+ with the `keep_on_completion` parameter set to `true`.
266
+ :param drop_null_columns: Indicates whether columns that are entirely `null`
267
+ will be removed from the `columns` and `values` portion of the results. If
268
+ `true`, the response will include an extra section under the name `all_columns`
269
+ which has the name of all the columns.
270
+ :param keep_alive: The period for which the query and its results are stored
271
+ in the cluster. When this period expires, the query and its results are deleted,
272
+ even if the query is still ongoing.
273
+ :param wait_for_completion_timeout: The period to wait for the request to finish.
274
+ By default, the request waits for complete query results. If the request
275
+ completes during the period specified in this parameter, complete query results
276
+ are returned. Otherwise, the response returns an `is_running` value of `true`
277
+ and no results.
278
+ """
279
+ if id in SKIP_IN_PATH:
280
+ raise ValueError("Empty value passed for parameter 'id'")
281
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
282
+ __path = f'/_query/async/{__path_parts["id"]}'
283
+ __query: t.Dict[str, t.Any] = {}
284
+ if drop_null_columns is not None:
285
+ __query["drop_null_columns"] = drop_null_columns
286
+ if error_trace is not None:
287
+ __query["error_trace"] = error_trace
288
+ if filter_path is not None:
289
+ __query["filter_path"] = filter_path
290
+ if human is not None:
291
+ __query["human"] = human
292
+ if keep_alive is not None:
293
+ __query["keep_alive"] = keep_alive
294
+ if pretty is not None:
295
+ __query["pretty"] = pretty
296
+ if wait_for_completion_timeout is not None:
297
+ __query["wait_for_completion_timeout"] = wait_for_completion_timeout
298
+ __headers = {"accept": "application/json"}
299
+ return await self.perform_request( # type: ignore[return-value]
300
+ "GET",
301
+ __path,
302
+ params=__query,
303
+ headers=__headers,
304
+ endpoint_id="esql.async_query_get",
305
+ path_parts=__path_parts,
306
+ )
307
+
308
+ @_rewrite_parameters()
309
+ async def async_query_stop(
310
+ self,
311
+ *,
312
+ id: str,
313
+ drop_null_columns: t.Optional[bool] = None,
314
+ error_trace: t.Optional[bool] = None,
315
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
316
+ human: t.Optional[bool] = None,
317
+ pretty: t.Optional[bool] = None,
318
+ ) -> ObjectApiResponse[t.Any]:
319
+ """
320
+ .. raw:: html
321
+
322
+ <p>Stop async ES|QL query.</p>
323
+ <p>This API interrupts the query execution and returns the results so far.
324
+ If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can stop it.</p>
325
+
326
+
327
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-esql-async-query-stop>`_
328
+
329
+ :param id: The unique identifier of the query. A query ID is provided in the
330
+ ES|QL async query API response for a query that does not complete in the
331
+ designated time. A query ID is also provided when the request was submitted
332
+ with the `keep_on_completion` parameter set to `true`.
333
+ :param drop_null_columns: Indicates whether columns that are entirely `null`
334
+ will be removed from the `columns` and `values` portion of the results. If
335
+ `true`, the response will include an extra section under the name `all_columns`
336
+ which has the name of all the columns.
337
+ """
338
+ if id in SKIP_IN_PATH:
339
+ raise ValueError("Empty value passed for parameter 'id'")
340
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
341
+ __path = f'/_query/async/{__path_parts["id"]}/stop'
342
+ __query: t.Dict[str, t.Any] = {}
343
+ if drop_null_columns is not None:
344
+ __query["drop_null_columns"] = drop_null_columns
345
+ if error_trace is not None:
346
+ __query["error_trace"] = error_trace
347
+ if filter_path is not None:
348
+ __query["filter_path"] = filter_path
349
+ if human is not None:
350
+ __query["human"] = human
351
+ if pretty is not None:
352
+ __query["pretty"] = pretty
353
+ __headers = {"accept": "application/json"}
354
+ return await self.perform_request( # type: ignore[return-value]
355
+ "POST",
356
+ __path,
357
+ params=__query,
358
+ headers=__headers,
359
+ endpoint_id="esql.async_query_stop",
360
+ path_parts=__path_parts,
361
+ )
362
+
363
+ @_rewrite_parameters(
364
+ body_fields=(
365
+ "query",
366
+ "columnar",
367
+ "filter",
368
+ "include_ccs_metadata",
369
+ "locale",
370
+ "params",
371
+ "profile",
372
+ "tables",
373
+ ),
374
+ ignore_deprecated_options={"params"},
375
+ )
376
+ async def query(
377
+ self,
378
+ *,
379
+ query: t.Optional[str] = None,
380
+ columnar: t.Optional[bool] = None,
381
+ delimiter: t.Optional[str] = None,
382
+ drop_null_columns: t.Optional[bool] = None,
383
+ error_trace: t.Optional[bool] = None,
384
+ filter: t.Optional[t.Mapping[str, t.Any]] = None,
385
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
386
+ format: t.Optional[
387
+ t.Union[
388
+ str,
389
+ t.Literal[
390
+ "arrow", "cbor", "csv", "json", "smile", "tsv", "txt", "yaml"
391
+ ],
392
+ ]
393
+ ] = None,
394
+ human: t.Optional[bool] = None,
395
+ include_ccs_metadata: t.Optional[bool] = None,
396
+ locale: t.Optional[str] = None,
397
+ params: t.Optional[t.Sequence[t.Union[None, bool, float, int, str]]] = None,
398
+ pretty: t.Optional[bool] = None,
399
+ profile: t.Optional[bool] = None,
400
+ tables: t.Optional[
401
+ t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]
402
+ ] = None,
403
+ body: t.Optional[t.Dict[str, t.Any]] = None,
404
+ ) -> ObjectApiResponse[t.Any]:
405
+ """
406
+ .. raw:: html
407
+
408
+ <p>Run an ES|QL query.
409
+ Get search results for an ES|QL (Elasticsearch query language) query.</p>
410
+
411
+
412
+ `<https://www.elastic.co/docs/explore-analyze/query-filter/languages/esql-rest>`_
413
+
414
+ :param query: The ES|QL query API accepts an ES|QL query string in the query
415
+ parameter, runs it, and returns the results.
416
+ :param columnar: By default, ES|QL returns results as rows. For example, FROM
417
+ returns each individual document as one row. For the JSON, YAML, CBOR and
418
+ smile formats, ES|QL can return the results in a columnar fashion where one
419
+ row represents all the values of a certain column in the results.
420
+ :param delimiter: The character to use between values within a CSV row. Only
421
+ valid for the CSV format.
422
+ :param drop_null_columns: Should columns that are entirely `null` be removed
423
+ from the `columns` and `values` portion of the results? Defaults to `false`.
424
+ If `true` then the response will include an extra section under the name
425
+ `all_columns` which has the name of all columns.
426
+ :param filter: Specify a Query DSL query in the filter parameter to filter the
427
+ set of documents that an ES|QL query runs on.
428
+ :param format: A short version of the Accept header, e.g. json, yaml.
429
+ :param include_ccs_metadata: When set to `true` and performing a cross-cluster
430
+ query, the response will include an extra `_clusters` object with information
431
+ about the clusters that participated in the search along with info such as
432
+ shards count.
433
+ :param locale:
434
+ :param params: To avoid any attempts of hacking or code injection, extract the
435
+ values in a separate list of parameters. Use question mark placeholders (?)
436
+ in the query string for each of the parameters.
437
+ :param profile: If provided and `true` the response will include an extra `profile`
438
+ object with information on how the query was executed. This information is
439
+ for human debugging and its format can change at any time but it can give
440
+ some insight into the performance of each part of the query.
441
+ :param tables: Tables to use with the LOOKUP operation. The top level key is
442
+ the table name and the next level key is the column name.
443
+ """
444
+ if query is None and body is None:
445
+ raise ValueError("Empty value passed for parameter 'query'")
446
+ __path_parts: t.Dict[str, str] = {}
447
+ __path = "/_query"
448
+ __query: t.Dict[str, t.Any] = {}
449
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
450
+ if delimiter is not None:
451
+ __query["delimiter"] = delimiter
452
+ if drop_null_columns is not None:
453
+ __query["drop_null_columns"] = drop_null_columns
454
+ if error_trace is not None:
455
+ __query["error_trace"] = error_trace
456
+ if filter_path is not None:
457
+ __query["filter_path"] = filter_path
458
+ if format is not None:
459
+ __query["format"] = format
460
+ if human is not None:
461
+ __query["human"] = human
462
+ if pretty is not None:
463
+ __query["pretty"] = pretty
464
+ if not __body:
465
+ if query is not None:
466
+ __body["query"] = query
467
+ if columnar is not None:
468
+ __body["columnar"] = columnar
469
+ if filter is not None:
470
+ __body["filter"] = filter
471
+ if include_ccs_metadata is not None:
472
+ __body["include_ccs_metadata"] = include_ccs_metadata
473
+ if locale is not None:
474
+ __body["locale"] = locale
475
+ if params is not None:
476
+ __body["params"] = params
477
+ if profile is not None:
478
+ __body["profile"] = profile
479
+ if tables is not None:
480
+ __body["tables"] = tables
481
+ __headers = {"accept": "application/json", "content-type": "application/json"}
482
+ return await self.perform_request( # type: ignore[return-value]
483
+ "POST",
484
+ __path,
485
+ params=__query,
486
+ headers=__headers,
487
+ body=__body,
488
+ endpoint_id="esql.query",
489
+ path_parts=__path_parts,
490
+ )
@@ -0,0 +1,130 @@
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
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import Stability, _rewrite_parameters, _stability_warning
24
+
25
+
26
+ class FeaturesClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters()
29
+ async def get_features(
30
+ self,
31
+ *,
32
+ error_trace: t.Optional[bool] = None,
33
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
34
+ human: t.Optional[bool] = None,
35
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
36
+ pretty: t.Optional[bool] = None,
37
+ ) -> ObjectApiResponse[t.Any]:
38
+ """
39
+ .. raw:: html
40
+
41
+ <p>Get the features.
42
+ Get a list of features that can be included in snapshots using the <code>feature_states</code> field when creating a snapshot.
43
+ You can use this API to determine which feature states to include when taking a snapshot.
44
+ By default, all feature states are included in a snapshot if that snapshot includes the global state, or none if it does not.</p>
45
+ <p>A feature state includes one or more system indices necessary for a given feature to function.
46
+ In order to ensure data integrity, all system indices that comprise a feature state are snapshotted and restored together.</p>
47
+ <p>The features listed by this API are a combination of built-in features and features defined by plugins.
48
+ In order for a feature state to be listed in this API and recognized as a valid feature state by the create snapshot API, the plugin that defines that feature must be installed on the master node.</p>
49
+
50
+
51
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-features-get-features>`_
52
+
53
+ :param master_timeout: Period to wait for a connection to the master node.
54
+ """
55
+ __path_parts: t.Dict[str, str] = {}
56
+ __path = "/_features"
57
+ __query: t.Dict[str, t.Any] = {}
58
+ if error_trace is not None:
59
+ __query["error_trace"] = error_trace
60
+ if filter_path is not None:
61
+ __query["filter_path"] = filter_path
62
+ if human is not None:
63
+ __query["human"] = human
64
+ if master_timeout is not None:
65
+ __query["master_timeout"] = master_timeout
66
+ if pretty is not None:
67
+ __query["pretty"] = pretty
68
+ __headers = {"accept": "application/json"}
69
+ return await self.perform_request( # type: ignore[return-value]
70
+ "GET",
71
+ __path,
72
+ params=__query,
73
+ headers=__headers,
74
+ endpoint_id="features.get_features",
75
+ path_parts=__path_parts,
76
+ )
77
+
78
+ @_rewrite_parameters()
79
+ @_stability_warning(Stability.EXPERIMENTAL)
80
+ async def reset_features(
81
+ self,
82
+ *,
83
+ error_trace: t.Optional[bool] = None,
84
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
85
+ human: t.Optional[bool] = None,
86
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
87
+ pretty: t.Optional[bool] = None,
88
+ ) -> ObjectApiResponse[t.Any]:
89
+ """
90
+ .. raw:: html
91
+
92
+ <p>Reset the features.
93
+ Clear all of the state information stored in system indices by Elasticsearch features, including the security and machine learning indices.</p>
94
+ <p>WARNING: Intended for development and testing use only. Do not reset features on a production cluster.</p>
95
+ <p>Return a cluster to the same state as a new installation by resetting the feature state for all Elasticsearch features.
96
+ This deletes all state information stored in system indices.</p>
97
+ <p>The response code is HTTP 200 if the state is successfully reset for all features.
98
+ It is HTTP 500 if the reset operation failed for any feature.</p>
99
+ <p>Note that select features might provide a way to reset particular system indices.
100
+ Using this API resets all features, both those that are built-in and implemented as plugins.</p>
101
+ <p>To list the features that will be affected, use the get features API.</p>
102
+ <p>IMPORTANT: The features installed on the node you submit this request to are the features that will be reset. Run on the master node if you have any doubts about which plugins are installed on individual nodes.</p>
103
+
104
+
105
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-features-reset-features>`_
106
+
107
+ :param master_timeout: Period to wait for a connection to the master node.
108
+ """
109
+ __path_parts: t.Dict[str, str] = {}
110
+ __path = "/_features/_reset"
111
+ __query: t.Dict[str, t.Any] = {}
112
+ if error_trace is not None:
113
+ __query["error_trace"] = error_trace
114
+ if filter_path is not None:
115
+ __query["filter_path"] = filter_path
116
+ if human is not None:
117
+ __query["human"] = human
118
+ if master_timeout is not None:
119
+ __query["master_timeout"] = master_timeout
120
+ if pretty is not None:
121
+ __query["pretty"] = pretty
122
+ __headers = {"accept": "application/json"}
123
+ return await self.perform_request( # type: ignore[return-value]
124
+ "POST",
125
+ __path,
126
+ params=__query,
127
+ headers=__headers,
128
+ endpoint_id="features.reset_features",
129
+ path_parts=__path_parts,
130
+ )