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,1223 @@
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 HeadApiResponse, ObjectApiResponse
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
24
+
25
+
26
+ class ClusterClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters(
29
+ body_fields=("current_node", "index", "primary", "shard"),
30
+ )
31
+ async def allocation_explain(
32
+ self,
33
+ *,
34
+ current_node: t.Optional[str] = None,
35
+ error_trace: t.Optional[bool] = None,
36
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
37
+ human: t.Optional[bool] = None,
38
+ include_disk_info: t.Optional[bool] = None,
39
+ include_yes_decisions: t.Optional[bool] = None,
40
+ index: t.Optional[str] = None,
41
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
42
+ pretty: t.Optional[bool] = None,
43
+ primary: t.Optional[bool] = None,
44
+ shard: t.Optional[int] = None,
45
+ body: t.Optional[t.Dict[str, t.Any]] = None,
46
+ ) -> ObjectApiResponse[t.Any]:
47
+ """
48
+ .. raw:: html
49
+
50
+ <p>Explain the shard allocations.
51
+ Get explanations for shard allocations in the cluster.
52
+ For unassigned shards, it provides an explanation for why the shard is unassigned.
53
+ For assigned shards, it provides an explanation for why the shard is remaining on its current node and has not moved or rebalanced to another node.
54
+ This API can be very useful when attempting to diagnose why a shard is unassigned or why a shard continues to remain on its current node when you might expect otherwise.</p>
55
+
56
+
57
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-allocation-explain>`_
58
+
59
+ :param current_node: Specifies the node ID or the name of the node to only explain
60
+ a shard that is currently located on the specified node.
61
+ :param include_disk_info: If true, returns information about disk usage and shard
62
+ sizes.
63
+ :param include_yes_decisions: If true, returns YES decisions in explanation.
64
+ :param index: Specifies the name of the index that you would like an explanation
65
+ for.
66
+ :param master_timeout: Period to wait for a connection to the master node.
67
+ :param primary: If true, returns explanation for the primary shard for the given
68
+ shard ID.
69
+ :param shard: Specifies the ID of the shard that you would like an explanation
70
+ for.
71
+ """
72
+ __path_parts: t.Dict[str, str] = {}
73
+ __path = "/_cluster/allocation/explain"
74
+ __query: t.Dict[str, t.Any] = {}
75
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
76
+ if error_trace is not None:
77
+ __query["error_trace"] = error_trace
78
+ if filter_path is not None:
79
+ __query["filter_path"] = filter_path
80
+ if human is not None:
81
+ __query["human"] = human
82
+ if include_disk_info is not None:
83
+ __query["include_disk_info"] = include_disk_info
84
+ if include_yes_decisions is not None:
85
+ __query["include_yes_decisions"] = include_yes_decisions
86
+ if master_timeout is not None:
87
+ __query["master_timeout"] = master_timeout
88
+ if pretty is not None:
89
+ __query["pretty"] = pretty
90
+ if not __body:
91
+ if current_node is not None:
92
+ __body["current_node"] = current_node
93
+ if index is not None:
94
+ __body["index"] = index
95
+ if primary is not None:
96
+ __body["primary"] = primary
97
+ if shard is not None:
98
+ __body["shard"] = shard
99
+ if not __body:
100
+ __body = None # type: ignore[assignment]
101
+ __headers = {"accept": "application/json"}
102
+ if __body is not None:
103
+ __headers["content-type"] = "application/json"
104
+ return await self.perform_request( # type: ignore[return-value]
105
+ "POST",
106
+ __path,
107
+ params=__query,
108
+ headers=__headers,
109
+ body=__body,
110
+ endpoint_id="cluster.allocation_explain",
111
+ path_parts=__path_parts,
112
+ )
113
+
114
+ @_rewrite_parameters()
115
+ async def delete_component_template(
116
+ self,
117
+ *,
118
+ name: t.Union[str, t.Sequence[str]],
119
+ error_trace: t.Optional[bool] = None,
120
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
121
+ human: t.Optional[bool] = None,
122
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
123
+ pretty: t.Optional[bool] = None,
124
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
125
+ ) -> ObjectApiResponse[t.Any]:
126
+ """
127
+ .. raw:: html
128
+
129
+ <p>Delete component templates.
130
+ Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases.</p>
131
+
132
+
133
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-put-component-template>`_
134
+
135
+ :param name: Comma-separated list or wildcard expression of component template
136
+ names used to limit the request.
137
+ :param master_timeout: Period to wait for a connection to the master node. If
138
+ no response is received before the timeout expires, the request fails and
139
+ returns an error.
140
+ :param timeout: Period to wait for a response. If no response is received before
141
+ the timeout expires, the request fails and returns an error.
142
+ """
143
+ if name in SKIP_IN_PATH:
144
+ raise ValueError("Empty value passed for parameter 'name'")
145
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
146
+ __path = f'/_component_template/{__path_parts["name"]}'
147
+ __query: t.Dict[str, t.Any] = {}
148
+ if error_trace is not None:
149
+ __query["error_trace"] = error_trace
150
+ if filter_path is not None:
151
+ __query["filter_path"] = filter_path
152
+ if human is not None:
153
+ __query["human"] = human
154
+ if master_timeout is not None:
155
+ __query["master_timeout"] = master_timeout
156
+ if pretty is not None:
157
+ __query["pretty"] = pretty
158
+ if timeout is not None:
159
+ __query["timeout"] = timeout
160
+ __headers = {"accept": "application/json"}
161
+ return await self.perform_request( # type: ignore[return-value]
162
+ "DELETE",
163
+ __path,
164
+ params=__query,
165
+ headers=__headers,
166
+ endpoint_id="cluster.delete_component_template",
167
+ path_parts=__path_parts,
168
+ )
169
+
170
+ @_rewrite_parameters()
171
+ async def delete_voting_config_exclusions(
172
+ self,
173
+ *,
174
+ error_trace: t.Optional[bool] = None,
175
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
176
+ human: t.Optional[bool] = None,
177
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
178
+ pretty: t.Optional[bool] = None,
179
+ wait_for_removal: t.Optional[bool] = None,
180
+ ) -> ObjectApiResponse[t.Any]:
181
+ """
182
+ .. raw:: html
183
+
184
+ <p>Clear cluster voting config exclusions.
185
+ Remove master-eligible nodes from the voting configuration exclusion list.</p>
186
+
187
+
188
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-post-voting-config-exclusions>`_
189
+
190
+ :param master_timeout: Period to wait for a connection to the master node.
191
+ :param wait_for_removal: Specifies whether to wait for all excluded nodes to
192
+ be removed from the cluster before clearing the voting configuration exclusions
193
+ list. Defaults to true, meaning that all excluded nodes must be removed from
194
+ the cluster before this API takes any action. If set to false then the voting
195
+ configuration exclusions list is cleared even if some excluded nodes are
196
+ still in the cluster.
197
+ """
198
+ __path_parts: t.Dict[str, str] = {}
199
+ __path = "/_cluster/voting_config_exclusions"
200
+ __query: t.Dict[str, t.Any] = {}
201
+ if error_trace is not None:
202
+ __query["error_trace"] = error_trace
203
+ if filter_path is not None:
204
+ __query["filter_path"] = filter_path
205
+ if human is not None:
206
+ __query["human"] = human
207
+ if master_timeout is not None:
208
+ __query["master_timeout"] = master_timeout
209
+ if pretty is not None:
210
+ __query["pretty"] = pretty
211
+ if wait_for_removal is not None:
212
+ __query["wait_for_removal"] = wait_for_removal
213
+ __headers = {"accept": "application/json"}
214
+ return await self.perform_request( # type: ignore[return-value]
215
+ "DELETE",
216
+ __path,
217
+ params=__query,
218
+ headers=__headers,
219
+ endpoint_id="cluster.delete_voting_config_exclusions",
220
+ path_parts=__path_parts,
221
+ )
222
+
223
+ @_rewrite_parameters()
224
+ async def exists_component_template(
225
+ self,
226
+ *,
227
+ name: t.Union[str, t.Sequence[str]],
228
+ error_trace: t.Optional[bool] = None,
229
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
230
+ human: t.Optional[bool] = None,
231
+ local: t.Optional[bool] = None,
232
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
233
+ pretty: t.Optional[bool] = None,
234
+ ) -> HeadApiResponse:
235
+ """
236
+ .. raw:: html
237
+
238
+ <p>Check component templates.
239
+ Returns information about whether a particular component template exists.</p>
240
+
241
+
242
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-put-component-template>`_
243
+
244
+ :param name: Comma-separated list of component template names used to limit the
245
+ request. Wildcard (*) expressions are supported.
246
+ :param local: If true, the request retrieves information from the local node
247
+ only. Defaults to false, which means information is retrieved from the master
248
+ node.
249
+ :param master_timeout: Period to wait for a connection to the master node. If
250
+ no response is received before the timeout expires, the request fails and
251
+ returns an error.
252
+ """
253
+ if name in SKIP_IN_PATH:
254
+ raise ValueError("Empty value passed for parameter 'name'")
255
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
256
+ __path = f'/_component_template/{__path_parts["name"]}'
257
+ __query: t.Dict[str, t.Any] = {}
258
+ if error_trace is not None:
259
+ __query["error_trace"] = error_trace
260
+ if filter_path is not None:
261
+ __query["filter_path"] = filter_path
262
+ if human is not None:
263
+ __query["human"] = human
264
+ if local is not None:
265
+ __query["local"] = local
266
+ if master_timeout is not None:
267
+ __query["master_timeout"] = master_timeout
268
+ if pretty is not None:
269
+ __query["pretty"] = pretty
270
+ __headers = {"accept": "application/json"}
271
+ return await self.perform_request( # type: ignore[return-value]
272
+ "HEAD",
273
+ __path,
274
+ params=__query,
275
+ headers=__headers,
276
+ endpoint_id="cluster.exists_component_template",
277
+ path_parts=__path_parts,
278
+ )
279
+
280
+ @_rewrite_parameters()
281
+ async def get_component_template(
282
+ self,
283
+ *,
284
+ name: t.Optional[str] = None,
285
+ error_trace: t.Optional[bool] = None,
286
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
287
+ flat_settings: t.Optional[bool] = None,
288
+ human: t.Optional[bool] = None,
289
+ include_defaults: t.Optional[bool] = None,
290
+ local: t.Optional[bool] = None,
291
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
292
+ pretty: t.Optional[bool] = None,
293
+ ) -> ObjectApiResponse[t.Any]:
294
+ """
295
+ .. raw:: html
296
+
297
+ <p>Get component templates.
298
+ Get information about component templates.</p>
299
+
300
+
301
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-put-component-template>`_
302
+
303
+ :param name: Comma-separated list of component template names used to limit the
304
+ request. Wildcard (`*`) expressions are supported.
305
+ :param flat_settings: If `true`, returns settings in flat format.
306
+ :param include_defaults: Return all default configurations for the component
307
+ template (default: false)
308
+ :param local: If `true`, the request retrieves information from the local node
309
+ only. If `false`, information is retrieved from the master node.
310
+ :param master_timeout: Period to wait for a connection to the master node. If
311
+ no response is received before the timeout expires, the request fails and
312
+ returns an error.
313
+ """
314
+ __path_parts: t.Dict[str, str]
315
+ if name not in SKIP_IN_PATH:
316
+ __path_parts = {"name": _quote(name)}
317
+ __path = f'/_component_template/{__path_parts["name"]}'
318
+ else:
319
+ __path_parts = {}
320
+ __path = "/_component_template"
321
+ __query: t.Dict[str, t.Any] = {}
322
+ if error_trace is not None:
323
+ __query["error_trace"] = error_trace
324
+ if filter_path is not None:
325
+ __query["filter_path"] = filter_path
326
+ if flat_settings is not None:
327
+ __query["flat_settings"] = flat_settings
328
+ if human is not None:
329
+ __query["human"] = human
330
+ if include_defaults is not None:
331
+ __query["include_defaults"] = include_defaults
332
+ if local is not None:
333
+ __query["local"] = local
334
+ if master_timeout is not None:
335
+ __query["master_timeout"] = master_timeout
336
+ if pretty is not None:
337
+ __query["pretty"] = pretty
338
+ __headers = {"accept": "application/json"}
339
+ return await self.perform_request( # type: ignore[return-value]
340
+ "GET",
341
+ __path,
342
+ params=__query,
343
+ headers=__headers,
344
+ endpoint_id="cluster.get_component_template",
345
+ path_parts=__path_parts,
346
+ )
347
+
348
+ @_rewrite_parameters()
349
+ async def get_settings(
350
+ self,
351
+ *,
352
+ error_trace: t.Optional[bool] = None,
353
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
354
+ flat_settings: t.Optional[bool] = None,
355
+ human: t.Optional[bool] = None,
356
+ include_defaults: t.Optional[bool] = None,
357
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
358
+ pretty: t.Optional[bool] = None,
359
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
360
+ ) -> ObjectApiResponse[t.Any]:
361
+ """
362
+ .. raw:: html
363
+
364
+ <p>Get cluster-wide settings.
365
+ By default, it returns only settings that have been explicitly defined.</p>
366
+
367
+
368
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-get-settings>`_
369
+
370
+ :param flat_settings: If `true`, returns settings in flat format.
371
+ :param include_defaults: If `true`, returns default cluster settings from the
372
+ local node.
373
+ :param master_timeout: Period to wait for a connection to the master node. If
374
+ no response is received before the timeout expires, the request fails and
375
+ returns an error.
376
+ :param timeout: Period to wait for a response. If no response is received before
377
+ the timeout expires, the request fails and returns an error.
378
+ """
379
+ __path_parts: t.Dict[str, str] = {}
380
+ __path = "/_cluster/settings"
381
+ __query: t.Dict[str, t.Any] = {}
382
+ if error_trace is not None:
383
+ __query["error_trace"] = error_trace
384
+ if filter_path is not None:
385
+ __query["filter_path"] = filter_path
386
+ if flat_settings is not None:
387
+ __query["flat_settings"] = flat_settings
388
+ if human is not None:
389
+ __query["human"] = human
390
+ if include_defaults is not None:
391
+ __query["include_defaults"] = include_defaults
392
+ if master_timeout is not None:
393
+ __query["master_timeout"] = master_timeout
394
+ if pretty is not None:
395
+ __query["pretty"] = pretty
396
+ if timeout is not None:
397
+ __query["timeout"] = timeout
398
+ __headers = {"accept": "application/json"}
399
+ return await self.perform_request( # type: ignore[return-value]
400
+ "GET",
401
+ __path,
402
+ params=__query,
403
+ headers=__headers,
404
+ endpoint_id="cluster.get_settings",
405
+ path_parts=__path_parts,
406
+ )
407
+
408
+ @_rewrite_parameters()
409
+ async def health(
410
+ self,
411
+ *,
412
+ index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
413
+ error_trace: t.Optional[bool] = None,
414
+ expand_wildcards: t.Optional[
415
+ t.Union[
416
+ t.Sequence[
417
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
418
+ ],
419
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
420
+ ]
421
+ ] = None,
422
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
423
+ human: t.Optional[bool] = None,
424
+ level: t.Optional[
425
+ t.Union[str, t.Literal["cluster", "indices", "shards"]]
426
+ ] = None,
427
+ local: t.Optional[bool] = None,
428
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
429
+ pretty: t.Optional[bool] = None,
430
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
431
+ wait_for_active_shards: t.Optional[
432
+ t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
433
+ ] = None,
434
+ wait_for_events: t.Optional[
435
+ t.Union[
436
+ str,
437
+ t.Literal["high", "immediate", "languid", "low", "normal", "urgent"],
438
+ ]
439
+ ] = None,
440
+ wait_for_no_initializing_shards: t.Optional[bool] = None,
441
+ wait_for_no_relocating_shards: t.Optional[bool] = None,
442
+ wait_for_nodes: t.Optional[t.Union[int, str]] = None,
443
+ wait_for_status: t.Optional[
444
+ t.Union[str, t.Literal["green", "red", "yellow"]]
445
+ ] = None,
446
+ ) -> ObjectApiResponse[t.Any]:
447
+ """
448
+ .. raw:: html
449
+
450
+ <p>Get the cluster health status.</p>
451
+ <p>You can also use the API to get the health status of only specified data streams and indices.
452
+ For data streams, the API retrieves the health status of the stream’s backing indices.</p>
453
+ <p>The cluster health status is: green, yellow or red.
454
+ On the shard level, a red status indicates that the specific shard is not allocated in the cluster. Yellow means that the primary shard is allocated but replicas are not. Green means that all shards are allocated.
455
+ The index level status is controlled by the worst shard status.</p>
456
+ <p>One of the main benefits of the API is the ability to wait until the cluster reaches a certain high watermark health level.
457
+ The cluster status is controlled by the worst index status.</p>
458
+
459
+
460
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-health>`_
461
+
462
+ :param index: Comma-separated list of data streams, indices, and index aliases
463
+ used to limit the request. Wildcard expressions (`*`) are supported. To target
464
+ all data streams and indices in a cluster, omit this parameter or use _all
465
+ or `*`.
466
+ :param expand_wildcards: Whether to expand wildcard expression to concrete indices
467
+ that are open, closed or both.
468
+ :param level: Can be one of cluster, indices or shards. Controls the details
469
+ level of the health information returned.
470
+ :param local: If true, the request retrieves information from the local node
471
+ only. Defaults to false, which means information is retrieved from the master
472
+ node.
473
+ :param master_timeout: Period to wait for a connection to the master node. If
474
+ no response is received before the timeout expires, the request fails and
475
+ returns an error.
476
+ :param timeout: Period to wait for a response. If no response is received before
477
+ the timeout expires, the request fails and returns an error.
478
+ :param wait_for_active_shards: A number controlling to how many active shards
479
+ to wait for, all to wait for all shards in the cluster to be active, or 0
480
+ to not wait.
481
+ :param wait_for_events: Can be one of immediate, urgent, high, normal, low, languid.
482
+ Wait until all currently queued events with the given priority are processed.
483
+ :param wait_for_no_initializing_shards: A boolean value which controls whether
484
+ to wait (until the timeout provided) for the cluster to have no shard initializations.
485
+ Defaults to false, which means it will not wait for initializing shards.
486
+ :param wait_for_no_relocating_shards: A boolean value which controls whether
487
+ to wait (until the timeout provided) for the cluster to have no shard relocations.
488
+ Defaults to false, which means it will not wait for relocating shards.
489
+ :param wait_for_nodes: The request waits until the specified number N of nodes
490
+ is available. It also accepts >=N, <=N, >N and <N. Alternatively, it is possible
491
+ to use ge(N), le(N), gt(N) and lt(N) notation.
492
+ :param wait_for_status: One of green, yellow or red. Will wait (until the timeout
493
+ provided) until the status of the cluster changes to the one provided or
494
+ better, i.e. green > yellow > red. By default, will not wait for any status.
495
+ """
496
+ __path_parts: t.Dict[str, str]
497
+ if index not in SKIP_IN_PATH:
498
+ __path_parts = {"index": _quote(index)}
499
+ __path = f'/_cluster/health/{__path_parts["index"]}'
500
+ else:
501
+ __path_parts = {}
502
+ __path = "/_cluster/health"
503
+ __query: t.Dict[str, t.Any] = {}
504
+ if error_trace is not None:
505
+ __query["error_trace"] = error_trace
506
+ if expand_wildcards is not None:
507
+ __query["expand_wildcards"] = expand_wildcards
508
+ if filter_path is not None:
509
+ __query["filter_path"] = filter_path
510
+ if human is not None:
511
+ __query["human"] = human
512
+ if level is not None:
513
+ __query["level"] = level
514
+ if local is not None:
515
+ __query["local"] = local
516
+ if master_timeout is not None:
517
+ __query["master_timeout"] = master_timeout
518
+ if pretty is not None:
519
+ __query["pretty"] = pretty
520
+ if timeout is not None:
521
+ __query["timeout"] = timeout
522
+ if wait_for_active_shards is not None:
523
+ __query["wait_for_active_shards"] = wait_for_active_shards
524
+ if wait_for_events is not None:
525
+ __query["wait_for_events"] = wait_for_events
526
+ if wait_for_no_initializing_shards is not None:
527
+ __query["wait_for_no_initializing_shards"] = wait_for_no_initializing_shards
528
+ if wait_for_no_relocating_shards is not None:
529
+ __query["wait_for_no_relocating_shards"] = wait_for_no_relocating_shards
530
+ if wait_for_nodes is not None:
531
+ __query["wait_for_nodes"] = wait_for_nodes
532
+ if wait_for_status is not None:
533
+ __query["wait_for_status"] = wait_for_status
534
+ __headers = {"accept": "application/json"}
535
+ return await self.perform_request( # type: ignore[return-value]
536
+ "GET",
537
+ __path,
538
+ params=__query,
539
+ headers=__headers,
540
+ endpoint_id="cluster.health",
541
+ path_parts=__path_parts,
542
+ )
543
+
544
+ @_rewrite_parameters()
545
+ async def info(
546
+ self,
547
+ *,
548
+ target: t.Union[
549
+ t.Sequence[
550
+ t.Union[
551
+ str, t.Literal["_all", "http", "ingest", "script", "thread_pool"]
552
+ ]
553
+ ],
554
+ t.Union[str, t.Literal["_all", "http", "ingest", "script", "thread_pool"]],
555
+ ],
556
+ error_trace: t.Optional[bool] = None,
557
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
558
+ human: t.Optional[bool] = None,
559
+ pretty: t.Optional[bool] = None,
560
+ ) -> ObjectApiResponse[t.Any]:
561
+ """
562
+ .. raw:: html
563
+
564
+ <p>Get cluster info.
565
+ Returns basic information about the cluster.</p>
566
+
567
+
568
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-info>`_
569
+
570
+ :param target: Limits the information returned to the specific target. Supports
571
+ a comma-separated list, such as http,ingest.
572
+ """
573
+ if target in SKIP_IN_PATH:
574
+ raise ValueError("Empty value passed for parameter 'target'")
575
+ __path_parts: t.Dict[str, str] = {"target": _quote(target)}
576
+ __path = f'/_info/{__path_parts["target"]}'
577
+ __query: t.Dict[str, t.Any] = {}
578
+ if error_trace is not None:
579
+ __query["error_trace"] = error_trace
580
+ if filter_path is not None:
581
+ __query["filter_path"] = filter_path
582
+ if human is not None:
583
+ __query["human"] = human
584
+ if pretty is not None:
585
+ __query["pretty"] = pretty
586
+ __headers = {"accept": "application/json"}
587
+ return await self.perform_request( # type: ignore[return-value]
588
+ "GET",
589
+ __path,
590
+ params=__query,
591
+ headers=__headers,
592
+ endpoint_id="cluster.info",
593
+ path_parts=__path_parts,
594
+ )
595
+
596
+ @_rewrite_parameters()
597
+ async def pending_tasks(
598
+ self,
599
+ *,
600
+ error_trace: t.Optional[bool] = None,
601
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
602
+ human: t.Optional[bool] = None,
603
+ local: t.Optional[bool] = None,
604
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
605
+ pretty: t.Optional[bool] = None,
606
+ ) -> ObjectApiResponse[t.Any]:
607
+ """
608
+ .. raw:: html
609
+
610
+ <p>Get the pending cluster tasks.
611
+ Get information about cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet taken effect.</p>
612
+ <p>NOTE: This API returns a list of any pending updates to the cluster state.
613
+ These are distinct from the tasks reported by the task management API which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create index requests.
614
+ However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task might be reported by both task api and pending cluster tasks API.</p>
615
+
616
+
617
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-pending-tasks>`_
618
+
619
+ :param local: If `true`, the request retrieves information from the local node
620
+ only. If `false`, information is retrieved from the master node.
621
+ :param master_timeout: Period to wait for a connection to the master node. If
622
+ no response is received before the timeout expires, the request fails and
623
+ returns an error.
624
+ """
625
+ __path_parts: t.Dict[str, str] = {}
626
+ __path = "/_cluster/pending_tasks"
627
+ __query: t.Dict[str, t.Any] = {}
628
+ if error_trace is not None:
629
+ __query["error_trace"] = error_trace
630
+ if filter_path is not None:
631
+ __query["filter_path"] = filter_path
632
+ if human is not None:
633
+ __query["human"] = human
634
+ if local is not None:
635
+ __query["local"] = local
636
+ if master_timeout is not None:
637
+ __query["master_timeout"] = master_timeout
638
+ if pretty is not None:
639
+ __query["pretty"] = pretty
640
+ __headers = {"accept": "application/json"}
641
+ return await self.perform_request( # type: ignore[return-value]
642
+ "GET",
643
+ __path,
644
+ params=__query,
645
+ headers=__headers,
646
+ endpoint_id="cluster.pending_tasks",
647
+ path_parts=__path_parts,
648
+ )
649
+
650
+ @_rewrite_parameters()
651
+ async def post_voting_config_exclusions(
652
+ self,
653
+ *,
654
+ error_trace: t.Optional[bool] = None,
655
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
656
+ human: t.Optional[bool] = None,
657
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
658
+ node_ids: t.Optional[t.Union[str, t.Sequence[str]]] = None,
659
+ node_names: t.Optional[t.Union[str, t.Sequence[str]]] = None,
660
+ pretty: t.Optional[bool] = None,
661
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
662
+ ) -> ObjectApiResponse[t.Any]:
663
+ """
664
+ .. raw:: html
665
+
666
+ <p>Update voting configuration exclusions.
667
+ Update the cluster voting config exclusions by node IDs or node names.
668
+ By default, if there are more than three master-eligible nodes in the cluster and you remove fewer than half of the master-eligible nodes in the cluster at once, the voting configuration automatically shrinks.
669
+ If you want to shrink the voting configuration to contain fewer than three nodes or to remove half or more of the master-eligible nodes in the cluster at once, use this API to remove departing nodes from the voting configuration manually.
670
+ The API adds an entry for each specified node to the cluster’s voting configuration exclusions list.
671
+ It then waits until the cluster has reconfigured its voting configuration to exclude the specified nodes.</p>
672
+ <p>Clusters should have no voting configuration exclusions in normal operation.
673
+ Once the excluded nodes have stopped, clear the voting configuration exclusions with <code>DELETE /_cluster/voting_config_exclusions</code>.
674
+ This API waits for the nodes to be fully removed from the cluster before it returns.
675
+ If your cluster has voting configuration exclusions for nodes that you no longer intend to remove, use <code>DELETE /_cluster/voting_config_exclusions?wait_for_removal=false</code> to clear the voting configuration exclusions without waiting for the nodes to leave the cluster.</p>
676
+ <p>A response to <code>POST /_cluster/voting_config_exclusions</code> with an HTTP status code of 200 OK guarantees that the node has been removed from the voting configuration and will not be reinstated until the voting configuration exclusions are cleared by calling <code>DELETE /_cluster/voting_config_exclusions</code>.
677
+ If the call to <code>POST /_cluster/voting_config_exclusions</code> fails or returns a response with an HTTP status code other than 200 OK then the node may not have been removed from the voting configuration.
678
+ In that case, you may safely retry the call.</p>
679
+ <p>NOTE: Voting exclusions are required only when you remove at least half of the master-eligible nodes from a cluster in a short time period.
680
+ They are not required when removing master-ineligible nodes or when removing fewer than half of the master-eligible nodes.</p>
681
+
682
+
683
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-post-voting-config-exclusions>`_
684
+
685
+ :param master_timeout: Period to wait for a connection to the master node.
686
+ :param node_ids: A comma-separated list of the persistent ids of the nodes to
687
+ exclude from the voting configuration. If specified, you may not also specify
688
+ node_names.
689
+ :param node_names: A comma-separated list of the names of the nodes to exclude
690
+ from the voting configuration. If specified, you may not also specify node_ids.
691
+ :param timeout: When adding a voting configuration exclusion, the API waits for
692
+ the specified nodes to be excluded from the voting configuration before returning.
693
+ If the timeout expires before the appropriate condition is satisfied, the
694
+ request fails and returns an error.
695
+ """
696
+ __path_parts: t.Dict[str, str] = {}
697
+ __path = "/_cluster/voting_config_exclusions"
698
+ __query: t.Dict[str, t.Any] = {}
699
+ if error_trace is not None:
700
+ __query["error_trace"] = error_trace
701
+ if filter_path is not None:
702
+ __query["filter_path"] = filter_path
703
+ if human is not None:
704
+ __query["human"] = human
705
+ if master_timeout is not None:
706
+ __query["master_timeout"] = master_timeout
707
+ if node_ids is not None:
708
+ __query["node_ids"] = node_ids
709
+ if node_names is not None:
710
+ __query["node_names"] = node_names
711
+ if pretty is not None:
712
+ __query["pretty"] = pretty
713
+ if timeout is not None:
714
+ __query["timeout"] = timeout
715
+ __headers = {"accept": "application/json"}
716
+ return await self.perform_request( # type: ignore[return-value]
717
+ "POST",
718
+ __path,
719
+ params=__query,
720
+ headers=__headers,
721
+ endpoint_id="cluster.post_voting_config_exclusions",
722
+ path_parts=__path_parts,
723
+ )
724
+
725
+ @_rewrite_parameters(
726
+ body_fields=("template", "deprecated", "meta", "version"),
727
+ parameter_aliases={"_meta": "meta"},
728
+ )
729
+ async def put_component_template(
730
+ self,
731
+ *,
732
+ name: str,
733
+ template: t.Optional[t.Mapping[str, t.Any]] = None,
734
+ create: t.Optional[bool] = None,
735
+ deprecated: t.Optional[bool] = None,
736
+ error_trace: t.Optional[bool] = None,
737
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
738
+ human: t.Optional[bool] = None,
739
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
740
+ meta: t.Optional[t.Mapping[str, t.Any]] = None,
741
+ pretty: t.Optional[bool] = None,
742
+ version: t.Optional[int] = None,
743
+ body: t.Optional[t.Dict[str, t.Any]] = None,
744
+ ) -> ObjectApiResponse[t.Any]:
745
+ """
746
+ .. raw:: html
747
+
748
+ <p>Create or update a component template.
749
+ Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases.</p>
750
+ <p>An index template can be composed of multiple component templates.
751
+ To use a component template, specify it in an index template’s <code>composed_of</code> list.
752
+ Component templates are only applied to new data streams and indices as part of a matching index template.</p>
753
+ <p>Settings and mappings specified directly in the index template or the create index request override any settings or mappings specified in a component template.</p>
754
+ <p>Component templates are only used during index creation.
755
+ For data streams, this includes data stream creation and the creation of a stream’s backing indices.
756
+ Changes to component templates do not affect existing indices, including a stream’s backing indices.</p>
757
+ <p>You can use C-style <code>/* *\\/</code> block comments in component templates.
758
+ You can include comments anywhere in the request body except before the opening curly bracket.</p>
759
+ <p><strong>Applying component templates</strong></p>
760
+ <p>You cannot directly apply a component template to a data stream or index.
761
+ To be applied, a component template must be included in an index template's <code>composed_of</code> list.</p>
762
+
763
+
764
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-put-component-template>`_
765
+
766
+ :param name: Name of the component template to create. Elasticsearch includes
767
+ the following built-in component templates: `logs-mappings`; `logs-settings`;
768
+ `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`.
769
+ Elastic Agent uses these templates to configure backing indices for its data
770
+ streams. If you use Elastic Agent and want to overwrite one of these templates,
771
+ set the `version` for your replacement template higher than the current version.
772
+ If you don’t use Elastic Agent and want to disable all built-in component
773
+ and index templates, set `stack.templates.enabled` to `false` using the cluster
774
+ update settings API.
775
+ :param template: The template to be applied which includes mappings, settings,
776
+ or aliases configuration.
777
+ :param create: If `true`, this request cannot replace or update existing component
778
+ templates.
779
+ :param deprecated: Marks this index template as deprecated. When creating or
780
+ updating a non-deprecated index template that uses deprecated components,
781
+ Elasticsearch will emit a deprecation warning.
782
+ :param master_timeout: Period to wait for a connection to the master node. If
783
+ no response is received before the timeout expires, the request fails and
784
+ returns an error.
785
+ :param meta: Optional user metadata about the component template. It may have
786
+ any contents. This map is not automatically generated by Elasticsearch. This
787
+ information is stored in the cluster state, so keeping it short is preferable.
788
+ To unset `_meta`, replace the template without specifying this information.
789
+ :param version: Version number used to manage component templates externally.
790
+ This number isn't automatically generated or incremented by Elasticsearch.
791
+ To unset a version, replace the template without specifying a version.
792
+ """
793
+ if name in SKIP_IN_PATH:
794
+ raise ValueError("Empty value passed for parameter 'name'")
795
+ if template is None and body is None:
796
+ raise ValueError("Empty value passed for parameter 'template'")
797
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
798
+ __path = f'/_component_template/{__path_parts["name"]}'
799
+ __query: t.Dict[str, t.Any] = {}
800
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
801
+ if create is not None:
802
+ __query["create"] = create
803
+ if error_trace is not None:
804
+ __query["error_trace"] = error_trace
805
+ if filter_path is not None:
806
+ __query["filter_path"] = filter_path
807
+ if human is not None:
808
+ __query["human"] = human
809
+ if master_timeout is not None:
810
+ __query["master_timeout"] = master_timeout
811
+ if pretty is not None:
812
+ __query["pretty"] = pretty
813
+ if not __body:
814
+ if template is not None:
815
+ __body["template"] = template
816
+ if deprecated is not None:
817
+ __body["deprecated"] = deprecated
818
+ if meta is not None:
819
+ __body["_meta"] = meta
820
+ if version is not None:
821
+ __body["version"] = version
822
+ __headers = {"accept": "application/json", "content-type": "application/json"}
823
+ return await self.perform_request( # type: ignore[return-value]
824
+ "PUT",
825
+ __path,
826
+ params=__query,
827
+ headers=__headers,
828
+ body=__body,
829
+ endpoint_id="cluster.put_component_template",
830
+ path_parts=__path_parts,
831
+ )
832
+
833
+ @_rewrite_parameters(
834
+ body_fields=("persistent", "transient"),
835
+ )
836
+ async def put_settings(
837
+ self,
838
+ *,
839
+ error_trace: t.Optional[bool] = None,
840
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
841
+ flat_settings: t.Optional[bool] = None,
842
+ human: t.Optional[bool] = None,
843
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
844
+ persistent: t.Optional[t.Mapping[str, t.Any]] = None,
845
+ pretty: t.Optional[bool] = None,
846
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
847
+ transient: t.Optional[t.Mapping[str, t.Any]] = None,
848
+ body: t.Optional[t.Dict[str, t.Any]] = None,
849
+ ) -> ObjectApiResponse[t.Any]:
850
+ """
851
+ .. raw:: html
852
+
853
+ <p>Update the cluster settings.</p>
854
+ <p>Configure and update dynamic settings on a running cluster.
855
+ You can also configure dynamic settings locally on an unstarted or shut down node in <code>elasticsearch.yml</code>.</p>
856
+ <p>Updates made with this API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart.
857
+ You can also reset transient or persistent settings by assigning them a null value.</p>
858
+ <p>If you configure the same setting using multiple methods, Elasticsearch applies the settings in following order of precedence: 1) Transient setting; 2) Persistent setting; 3) <code>elasticsearch.yml</code> setting; 4) Default setting value.
859
+ For example, you can apply a transient setting to override a persistent setting or <code>elasticsearch.yml</code> setting.
860
+ However, a change to an <code>elasticsearch.yml</code> setting will not override a defined transient or persistent setting.</p>
861
+ <p>TIP: In Elastic Cloud, use the user settings feature to configure all cluster settings. This method automatically rejects unsafe settings that could break your cluster.
862
+ If you run Elasticsearch on your own hardware, use this API to configure dynamic cluster settings.
863
+ Only use <code>elasticsearch.yml</code> for static cluster settings and node settings.
864
+ The API doesn’t require a restart and ensures a setting’s value is the same on all nodes.</p>
865
+ <p>WARNING: Transient cluster settings are no longer recommended. Use persistent cluster settings instead.
866
+ If a cluster becomes unstable, transient settings can clear unexpectedly, resulting in a potentially undesired cluster configuration.</p>
867
+
868
+
869
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-put-settings>`_
870
+
871
+ :param flat_settings: Return settings in flat format (default: false)
872
+ :param master_timeout: Explicit operation timeout for connection to master node
873
+ :param persistent:
874
+ :param timeout: Explicit operation timeout
875
+ :param transient:
876
+ """
877
+ __path_parts: t.Dict[str, str] = {}
878
+ __path = "/_cluster/settings"
879
+ __query: t.Dict[str, t.Any] = {}
880
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
881
+ if error_trace is not None:
882
+ __query["error_trace"] = error_trace
883
+ if filter_path is not None:
884
+ __query["filter_path"] = filter_path
885
+ if flat_settings is not None:
886
+ __query["flat_settings"] = flat_settings
887
+ if human is not None:
888
+ __query["human"] = human
889
+ if master_timeout is not None:
890
+ __query["master_timeout"] = master_timeout
891
+ if pretty is not None:
892
+ __query["pretty"] = pretty
893
+ if timeout is not None:
894
+ __query["timeout"] = timeout
895
+ if not __body:
896
+ if persistent is not None:
897
+ __body["persistent"] = persistent
898
+ if transient is not None:
899
+ __body["transient"] = transient
900
+ __headers = {"accept": "application/json", "content-type": "application/json"}
901
+ return await self.perform_request( # type: ignore[return-value]
902
+ "PUT",
903
+ __path,
904
+ params=__query,
905
+ headers=__headers,
906
+ body=__body,
907
+ endpoint_id="cluster.put_settings",
908
+ path_parts=__path_parts,
909
+ )
910
+
911
+ @_rewrite_parameters()
912
+ async def remote_info(
913
+ self,
914
+ *,
915
+ error_trace: t.Optional[bool] = None,
916
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
917
+ human: t.Optional[bool] = None,
918
+ pretty: t.Optional[bool] = None,
919
+ ) -> ObjectApiResponse[t.Any]:
920
+ """
921
+ .. raw:: html
922
+
923
+ <p>Get remote cluster information.</p>
924
+ <p>Get information about configured remote clusters.
925
+ The API returns connection and endpoint information keyed by the configured remote cluster alias.</p>
926
+ <blockquote>
927
+ <p>info
928
+ This API returns information that reflects current state on the local cluster.
929
+ The <code>connected</code> field does not necessarily reflect whether a remote cluster is down or unavailable, only whether there is currently an open connection to it.
930
+ Elasticsearch does not spontaneously try to reconnect to a disconnected remote cluster.
931
+ To trigger a reconnection, attempt a cross-cluster search, ES|QL cross-cluster search, or try the <a href="https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-cluster">resolve cluster endpoint</a>.</p>
932
+ </blockquote>
933
+
934
+
935
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-remote-info>`_
936
+ """
937
+ __path_parts: t.Dict[str, str] = {}
938
+ __path = "/_remote/info"
939
+ __query: t.Dict[str, t.Any] = {}
940
+ if error_trace is not None:
941
+ __query["error_trace"] = error_trace
942
+ if filter_path is not None:
943
+ __query["filter_path"] = filter_path
944
+ if human is not None:
945
+ __query["human"] = human
946
+ if pretty is not None:
947
+ __query["pretty"] = pretty
948
+ __headers = {"accept": "application/json"}
949
+ return await self.perform_request( # type: ignore[return-value]
950
+ "GET",
951
+ __path,
952
+ params=__query,
953
+ headers=__headers,
954
+ endpoint_id="cluster.remote_info",
955
+ path_parts=__path_parts,
956
+ )
957
+
958
+ @_rewrite_parameters(
959
+ body_fields=("commands",),
960
+ )
961
+ async def reroute(
962
+ self,
963
+ *,
964
+ commands: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
965
+ dry_run: t.Optional[bool] = None,
966
+ error_trace: t.Optional[bool] = None,
967
+ explain: t.Optional[bool] = None,
968
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
969
+ human: t.Optional[bool] = None,
970
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
971
+ metric: t.Optional[t.Union[str, t.Sequence[str]]] = None,
972
+ pretty: t.Optional[bool] = None,
973
+ retry_failed: t.Optional[bool] = None,
974
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
975
+ body: t.Optional[t.Dict[str, t.Any]] = None,
976
+ ) -> ObjectApiResponse[t.Any]:
977
+ """
978
+ .. raw:: html
979
+
980
+ <p>Reroute the cluster.
981
+ Manually change the allocation of individual shards in the cluster.
982
+ For example, a shard can be moved from one node to another explicitly, an allocation can be canceled, and an unassigned shard can be explicitly allocated to a specific node.</p>
983
+ <p>It is important to note that after processing any reroute commands Elasticsearch will perform rebalancing as normal (respecting the values of settings such as <code>cluster.routing.rebalance.enable</code>) in order to remain in a balanced state.
984
+ For example, if the requested allocation includes moving a shard from node1 to node2 then this may cause a shard to be moved from node2 back to node1 to even things out.</p>
985
+ <p>The cluster can be set to disable allocations using the <code>cluster.routing.allocation.enable</code> setting.
986
+ If allocations are disabled then the only allocations that will be performed are explicit ones given using the reroute command, and consequent allocations due to rebalancing.</p>
987
+ <p>The cluster will attempt to allocate a shard a maximum of <code>index.allocation.max_retries</code> times in a row (defaults to <code>5</code>), before giving up and leaving the shard unallocated.
988
+ This scenario can be caused by structural problems such as having an analyzer which refers to a stopwords file which doesn’t exist on all nodes.</p>
989
+ <p>Once the problem has been corrected, allocation can be manually retried by calling the reroute API with the <code>?retry_failed</code> URI query parameter, which will attempt a single retry round for these shards.</p>
990
+
991
+
992
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-reroute>`_
993
+
994
+ :param commands: Defines the commands to perform.
995
+ :param dry_run: If true, then the request simulates the operation. It will calculate
996
+ the result of applying the commands to the current cluster state and return
997
+ the resulting cluster state after the commands (and rebalancing) have been
998
+ applied; it will not actually perform the requested changes.
999
+ :param explain: If true, then the response contains an explanation of why the
1000
+ commands can or cannot run.
1001
+ :param master_timeout: Period to wait for a connection to the master node. If
1002
+ no response is received before the timeout expires, the request fails and
1003
+ returns an error.
1004
+ :param metric: Limits the information returned to the specified metrics.
1005
+ :param retry_failed: If true, then retries allocation of shards that are blocked
1006
+ due to too many subsequent allocation failures.
1007
+ :param timeout: Period to wait for a response. If no response is received before
1008
+ the timeout expires, the request fails and returns an error.
1009
+ """
1010
+ __path_parts: t.Dict[str, str] = {}
1011
+ __path = "/_cluster/reroute"
1012
+ __query: t.Dict[str, t.Any] = {}
1013
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
1014
+ if dry_run is not None:
1015
+ __query["dry_run"] = dry_run
1016
+ if error_trace is not None:
1017
+ __query["error_trace"] = error_trace
1018
+ if explain is not None:
1019
+ __query["explain"] = explain
1020
+ if filter_path is not None:
1021
+ __query["filter_path"] = filter_path
1022
+ if human is not None:
1023
+ __query["human"] = human
1024
+ if master_timeout is not None:
1025
+ __query["master_timeout"] = master_timeout
1026
+ if metric is not None:
1027
+ __query["metric"] = metric
1028
+ if pretty is not None:
1029
+ __query["pretty"] = pretty
1030
+ if retry_failed is not None:
1031
+ __query["retry_failed"] = retry_failed
1032
+ if timeout is not None:
1033
+ __query["timeout"] = timeout
1034
+ if not __body:
1035
+ if commands is not None:
1036
+ __body["commands"] = commands
1037
+ if not __body:
1038
+ __body = None # type: ignore[assignment]
1039
+ __headers = {"accept": "application/json"}
1040
+ if __body is not None:
1041
+ __headers["content-type"] = "application/json"
1042
+ return await self.perform_request( # type: ignore[return-value]
1043
+ "POST",
1044
+ __path,
1045
+ params=__query,
1046
+ headers=__headers,
1047
+ body=__body,
1048
+ endpoint_id="cluster.reroute",
1049
+ path_parts=__path_parts,
1050
+ )
1051
+
1052
+ @_rewrite_parameters()
1053
+ async def state(
1054
+ self,
1055
+ *,
1056
+ metric: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1057
+ index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1058
+ allow_no_indices: t.Optional[bool] = None,
1059
+ error_trace: t.Optional[bool] = None,
1060
+ expand_wildcards: t.Optional[
1061
+ t.Union[
1062
+ t.Sequence[
1063
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
1064
+ ],
1065
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
1066
+ ]
1067
+ ] = None,
1068
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1069
+ flat_settings: t.Optional[bool] = None,
1070
+ human: t.Optional[bool] = None,
1071
+ ignore_unavailable: t.Optional[bool] = None,
1072
+ local: t.Optional[bool] = None,
1073
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1074
+ pretty: t.Optional[bool] = None,
1075
+ wait_for_metadata_version: t.Optional[int] = None,
1076
+ wait_for_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1077
+ ) -> ObjectApiResponse[t.Any]:
1078
+ """
1079
+ .. raw:: html
1080
+
1081
+ <p>Get the cluster state.
1082
+ Get comprehensive information about the state of the cluster.</p>
1083
+ <p>The cluster state is an internal data structure which keeps track of a variety of information needed by every node, including the identity and attributes of the other nodes in the cluster; cluster-wide settings; index metadata, including the mapping and settings for each index; the location and status of every shard copy in the cluster.</p>
1084
+ <p>The elected master node ensures that every node in the cluster has a copy of the same cluster state.
1085
+ This API lets you retrieve a representation of this internal state for debugging or diagnostic purposes.
1086
+ You may need to consult the Elasticsearch source code to determine the precise meaning of the response.</p>
1087
+ <p>By default the API will route requests to the elected master node since this node is the authoritative source of cluster states.
1088
+ You can also retrieve the cluster state held on the node handling the API request by adding the <code>?local=true</code> query parameter.</p>
1089
+ <p>Elasticsearch may need to expend significant effort to compute a response to this API in larger clusters, and the response may comprise a very large quantity of data.
1090
+ If you use this API repeatedly, your cluster may become unstable.</p>
1091
+ <p>WARNING: The response is a representation of an internal data structure.
1092
+ Its format is not subject to the same compatibility guarantees as other more stable APIs and may change from version to version.
1093
+ Do not query this API using external monitoring tools.
1094
+ Instead, obtain the information you require using other more stable cluster APIs.</p>
1095
+
1096
+
1097
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-state>`_
1098
+
1099
+ :param metric: Limit the information returned to the specified metrics
1100
+ :param index: A comma-separated list of index names; use `_all` or empty string
1101
+ to perform the operation on all indices
1102
+ :param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
1103
+ into no concrete indices. (This includes `_all` string or when no indices
1104
+ have been specified)
1105
+ :param expand_wildcards: Whether to expand wildcard expression to concrete indices
1106
+ that are open, closed or both.
1107
+ :param flat_settings: Return settings in flat format (default: false)
1108
+ :param ignore_unavailable: Whether specified concrete indices should be ignored
1109
+ when unavailable (missing or closed)
1110
+ :param local: Return local information, do not retrieve the state from master
1111
+ node (default: false)
1112
+ :param master_timeout: Specify timeout for connection to master
1113
+ :param wait_for_metadata_version: Wait for the metadata version to be equal or
1114
+ greater than the specified metadata version
1115
+ :param wait_for_timeout: The maximum time to wait for wait_for_metadata_version
1116
+ before timing out
1117
+ """
1118
+ __path_parts: t.Dict[str, str]
1119
+ if metric not in SKIP_IN_PATH and index not in SKIP_IN_PATH:
1120
+ __path_parts = {"metric": _quote(metric), "index": _quote(index)}
1121
+ __path = f'/_cluster/state/{__path_parts["metric"]}/{__path_parts["index"]}'
1122
+ elif metric not in SKIP_IN_PATH:
1123
+ __path_parts = {"metric": _quote(metric)}
1124
+ __path = f'/_cluster/state/{__path_parts["metric"]}'
1125
+ elif index not in SKIP_IN_PATH:
1126
+ __path_parts = {"index": _quote(index)}
1127
+ __path = f'/_cluster/state/_all/{__path_parts["index"]}'
1128
+ else:
1129
+ __path_parts = {}
1130
+ __path = "/_cluster/state"
1131
+ __query: t.Dict[str, t.Any] = {}
1132
+ if allow_no_indices is not None:
1133
+ __query["allow_no_indices"] = allow_no_indices
1134
+ if error_trace is not None:
1135
+ __query["error_trace"] = error_trace
1136
+ if expand_wildcards is not None:
1137
+ __query["expand_wildcards"] = expand_wildcards
1138
+ if filter_path is not None:
1139
+ __query["filter_path"] = filter_path
1140
+ if flat_settings is not None:
1141
+ __query["flat_settings"] = flat_settings
1142
+ if human is not None:
1143
+ __query["human"] = human
1144
+ if ignore_unavailable is not None:
1145
+ __query["ignore_unavailable"] = ignore_unavailable
1146
+ if local is not None:
1147
+ __query["local"] = local
1148
+ if master_timeout is not None:
1149
+ __query["master_timeout"] = master_timeout
1150
+ if pretty is not None:
1151
+ __query["pretty"] = pretty
1152
+ if wait_for_metadata_version is not None:
1153
+ __query["wait_for_metadata_version"] = wait_for_metadata_version
1154
+ if wait_for_timeout is not None:
1155
+ __query["wait_for_timeout"] = wait_for_timeout
1156
+ __headers = {"accept": "application/json"}
1157
+ return await self.perform_request( # type: ignore[return-value]
1158
+ "GET",
1159
+ __path,
1160
+ params=__query,
1161
+ headers=__headers,
1162
+ endpoint_id="cluster.state",
1163
+ path_parts=__path_parts,
1164
+ )
1165
+
1166
+ @_rewrite_parameters()
1167
+ async def stats(
1168
+ self,
1169
+ *,
1170
+ node_id: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1171
+ error_trace: t.Optional[bool] = None,
1172
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1173
+ human: t.Optional[bool] = None,
1174
+ include_remotes: t.Optional[bool] = None,
1175
+ pretty: t.Optional[bool] = None,
1176
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1177
+ ) -> ObjectApiResponse[t.Any]:
1178
+ """
1179
+ .. raw:: html
1180
+
1181
+ <p>Get cluster statistics.
1182
+ Get basic index metrics (shard numbers, store size, memory usage) and information about the current nodes that form the cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins).</p>
1183
+
1184
+
1185
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-cluster-stats>`_
1186
+
1187
+ :param node_id: Comma-separated list of node filters used to limit returned information.
1188
+ Defaults to all nodes in the cluster.
1189
+ :param include_remotes: Include remote cluster data into the response
1190
+ :param timeout: Period to wait for each node to respond. If a node does not respond
1191
+ before its timeout expires, the response does not include its stats. However,
1192
+ timed out nodes are included in the response’s `_nodes.failed` property.
1193
+ Defaults to no timeout.
1194
+ """
1195
+ __path_parts: t.Dict[str, str]
1196
+ if node_id not in SKIP_IN_PATH:
1197
+ __path_parts = {"node_id": _quote(node_id)}
1198
+ __path = f'/_cluster/stats/nodes/{__path_parts["node_id"]}'
1199
+ else:
1200
+ __path_parts = {}
1201
+ __path = "/_cluster/stats"
1202
+ __query: t.Dict[str, t.Any] = {}
1203
+ if error_trace is not None:
1204
+ __query["error_trace"] = error_trace
1205
+ if filter_path is not None:
1206
+ __query["filter_path"] = filter_path
1207
+ if human is not None:
1208
+ __query["human"] = human
1209
+ if include_remotes is not None:
1210
+ __query["include_remotes"] = include_remotes
1211
+ if pretty is not None:
1212
+ __query["pretty"] = pretty
1213
+ if timeout is not None:
1214
+ __query["timeout"] = timeout
1215
+ __headers = {"accept": "application/json"}
1216
+ return await self.perform_request( # type: ignore[return-value]
1217
+ "GET",
1218
+ __path,
1219
+ params=__query,
1220
+ headers=__headers,
1221
+ endpoint_id="cluster.stats",
1222
+ path_parts=__path_parts,
1223
+ )