elasticsearch 8.12.1__py3-none-any.whl → 8.13.1__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.
- elasticsearch/__init__.py +7 -0
- elasticsearch/_async/client/__init__.py +477 -128
- elasticsearch/_async/client/_base.py +41 -1
- elasticsearch/_async/client/async_search.py +40 -12
- elasticsearch/_async/client/autoscaling.py +37 -11
- elasticsearch/_async/client/cat.py +260 -69
- elasticsearch/_async/client/ccr.py +123 -38
- elasticsearch/_async/client/cluster.py +153 -42
- elasticsearch/_async/client/dangling_indices.py +27 -8
- elasticsearch/_async/client/enrich.py +48 -14
- elasticsearch/_async/client/eql.py +38 -12
- elasticsearch/_async/client/esql.py +10 -2
- elasticsearch/_async/client/features.py +17 -4
- elasticsearch/_async/client/fleet.py +30 -7
- elasticsearch/_async/client/graph.py +11 -3
- elasticsearch/_async/client/ilm.py +101 -29
- elasticsearch/_async/client/indices.py +688 -181
- elasticsearch/_async/client/inference.py +111 -44
- elasticsearch/_async/client/ingest.py +59 -16
- elasticsearch/_async/client/license.py +58 -14
- elasticsearch/_async/client/logstash.py +31 -9
- elasticsearch/_async/client/migration.py +28 -7
- elasticsearch/_async/client/ml.py +781 -214
- elasticsearch/_async/client/monitoring.py +10 -2
- elasticsearch/_async/client/nodes.py +103 -29
- elasticsearch/_async/client/query_ruleset.py +37 -11
- elasticsearch/_async/client/rollup.py +79 -24
- elasticsearch/_async/client/search_application.py +76 -23
- elasticsearch/_async/client/searchable_snapshots.py +49 -12
- elasticsearch/_async/client/security.py +544 -143
- elasticsearch/_async/client/shutdown.py +28 -6
- elasticsearch/_async/client/slm.py +80 -22
- elasticsearch/_async/client/snapshot.py +140 -54
- elasticsearch/_async/client/sql.py +55 -15
- elasticsearch/_async/client/ssl.py +9 -2
- elasticsearch/_async/client/synonyms.py +75 -21
- elasticsearch/_async/client/tasks.py +29 -8
- elasticsearch/_async/client/text_structure.py +74 -2
- elasticsearch/_async/client/transform.py +106 -32
- elasticsearch/_async/client/watcher.py +110 -31
- elasticsearch/_async/client/xpack.py +16 -4
- elasticsearch/_async/helpers.py +1 -1
- elasticsearch/_otel.py +92 -0
- elasticsearch/_sync/client/__init__.py +477 -128
- elasticsearch/_sync/client/_base.py +41 -1
- elasticsearch/_sync/client/async_search.py +40 -12
- elasticsearch/_sync/client/autoscaling.py +37 -11
- elasticsearch/_sync/client/cat.py +260 -69
- elasticsearch/_sync/client/ccr.py +123 -38
- elasticsearch/_sync/client/cluster.py +153 -42
- elasticsearch/_sync/client/dangling_indices.py +27 -8
- elasticsearch/_sync/client/enrich.py +48 -14
- elasticsearch/_sync/client/eql.py +38 -12
- elasticsearch/_sync/client/esql.py +10 -2
- elasticsearch/_sync/client/features.py +17 -4
- elasticsearch/_sync/client/fleet.py +30 -7
- elasticsearch/_sync/client/graph.py +11 -3
- elasticsearch/_sync/client/ilm.py +101 -29
- elasticsearch/_sync/client/indices.py +688 -181
- elasticsearch/_sync/client/inference.py +111 -44
- elasticsearch/_sync/client/ingest.py +59 -16
- elasticsearch/_sync/client/license.py +58 -14
- elasticsearch/_sync/client/logstash.py +31 -9
- elasticsearch/_sync/client/migration.py +28 -7
- elasticsearch/_sync/client/ml.py +781 -214
- elasticsearch/_sync/client/monitoring.py +10 -2
- elasticsearch/_sync/client/nodes.py +103 -29
- elasticsearch/_sync/client/query_ruleset.py +37 -11
- elasticsearch/_sync/client/rollup.py +79 -24
- elasticsearch/_sync/client/search_application.py +76 -23
- elasticsearch/_sync/client/searchable_snapshots.py +49 -12
- elasticsearch/_sync/client/security.py +544 -143
- elasticsearch/_sync/client/shutdown.py +28 -6
- elasticsearch/_sync/client/slm.py +80 -22
- elasticsearch/_sync/client/snapshot.py +140 -54
- elasticsearch/_sync/client/sql.py +55 -15
- elasticsearch/_sync/client/ssl.py +9 -2
- elasticsearch/_sync/client/synonyms.py +75 -21
- elasticsearch/_sync/client/tasks.py +29 -8
- elasticsearch/_sync/client/text_structure.py +74 -2
- elasticsearch/_sync/client/transform.py +106 -32
- elasticsearch/_sync/client/watcher.py +110 -31
- elasticsearch/_sync/client/xpack.py +16 -4
- elasticsearch/_version.py +1 -1
- elasticsearch/helpers/actions.py +1 -1
- elasticsearch/helpers/vectorstore/__init__.py +62 -0
- elasticsearch/helpers/vectorstore/_async/__init__.py +16 -0
- elasticsearch/helpers/vectorstore/_async/_utils.py +39 -0
- elasticsearch/helpers/vectorstore/_async/embedding_service.py +89 -0
- elasticsearch/helpers/vectorstore/_async/strategies.py +466 -0
- elasticsearch/helpers/vectorstore/_async/vectorstore.py +391 -0
- elasticsearch/helpers/vectorstore/_sync/__init__.py +16 -0
- elasticsearch/helpers/vectorstore/_sync/_utils.py +39 -0
- elasticsearch/helpers/vectorstore/_sync/embedding_service.py +89 -0
- elasticsearch/helpers/vectorstore/_sync/strategies.py +466 -0
- elasticsearch/helpers/vectorstore/_sync/vectorstore.py +388 -0
- elasticsearch/helpers/vectorstore/_utils.py +116 -0
- elasticsearch/serializer.py +14 -0
- {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/METADATA +28 -8
- elasticsearch-8.13.1.dist-info/RECORD +116 -0
- {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/WHEEL +1 -1
- elasticsearch-8.12.1.dist-info/RECORD +0 -103
- {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/LICENSE +0 -0
- {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/NOTICE +0 -0
- {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/top_level.txt +0 -0
|
@@ -24,6 +24,7 @@ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class WatcherClient(NamespacedClient):
|
|
27
|
+
|
|
27
28
|
@_rewrite_parameters()
|
|
28
29
|
async def ack_watch(
|
|
29
30
|
self,
|
|
@@ -38,17 +39,23 @@ class WatcherClient(NamespacedClient):
|
|
|
38
39
|
"""
|
|
39
40
|
Acknowledges a watch, manually throttling the execution of the watch's actions.
|
|
40
41
|
|
|
41
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
42
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-ack-watch.html>`_
|
|
42
43
|
|
|
43
44
|
:param watch_id: Watch ID
|
|
44
45
|
:param action_id: A comma-separated list of the action ids to be acked
|
|
45
46
|
"""
|
|
46
47
|
if watch_id in SKIP_IN_PATH:
|
|
47
48
|
raise ValueError("Empty value passed for parameter 'watch_id'")
|
|
49
|
+
__path_parts: t.Dict[str, str]
|
|
48
50
|
if watch_id not in SKIP_IN_PATH and action_id not in SKIP_IN_PATH:
|
|
49
|
-
|
|
51
|
+
__path_parts = {
|
|
52
|
+
"watch_id": _quote(watch_id),
|
|
53
|
+
"action_id": _quote(action_id),
|
|
54
|
+
}
|
|
55
|
+
__path = f'/_watcher/watch/{__path_parts["watch_id"]}/_ack/{__path_parts["action_id"]}'
|
|
50
56
|
elif watch_id not in SKIP_IN_PATH:
|
|
51
|
-
|
|
57
|
+
__path_parts = {"watch_id": _quote(watch_id)}
|
|
58
|
+
__path = f'/_watcher/watch/{__path_parts["watch_id"]}/_ack'
|
|
52
59
|
else:
|
|
53
60
|
raise ValueError("Couldn't find a path for the given parameters")
|
|
54
61
|
__query: t.Dict[str, t.Any] = {}
|
|
@@ -62,7 +69,12 @@ class WatcherClient(NamespacedClient):
|
|
|
62
69
|
__query["pretty"] = pretty
|
|
63
70
|
__headers = {"accept": "application/json"}
|
|
64
71
|
return await self.perform_request( # type: ignore[return-value]
|
|
65
|
-
"PUT",
|
|
72
|
+
"PUT",
|
|
73
|
+
__path,
|
|
74
|
+
params=__query,
|
|
75
|
+
headers=__headers,
|
|
76
|
+
endpoint_id="watcher.ack_watch",
|
|
77
|
+
path_parts=__path_parts,
|
|
66
78
|
)
|
|
67
79
|
|
|
68
80
|
@_rewrite_parameters()
|
|
@@ -78,13 +90,14 @@ class WatcherClient(NamespacedClient):
|
|
|
78
90
|
"""
|
|
79
91
|
Activates a currently inactive watch.
|
|
80
92
|
|
|
81
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
93
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-activate-watch.html>`_
|
|
82
94
|
|
|
83
95
|
:param watch_id: Watch ID
|
|
84
96
|
"""
|
|
85
97
|
if watch_id in SKIP_IN_PATH:
|
|
86
98
|
raise ValueError("Empty value passed for parameter 'watch_id'")
|
|
87
|
-
|
|
99
|
+
__path_parts: t.Dict[str, str] = {"watch_id": _quote(watch_id)}
|
|
100
|
+
__path = f'/_watcher/watch/{__path_parts["watch_id"]}/_activate'
|
|
88
101
|
__query: t.Dict[str, t.Any] = {}
|
|
89
102
|
if error_trace is not None:
|
|
90
103
|
__query["error_trace"] = error_trace
|
|
@@ -96,7 +109,12 @@ class WatcherClient(NamespacedClient):
|
|
|
96
109
|
__query["pretty"] = pretty
|
|
97
110
|
__headers = {"accept": "application/json"}
|
|
98
111
|
return await self.perform_request( # type: ignore[return-value]
|
|
99
|
-
"PUT",
|
|
112
|
+
"PUT",
|
|
113
|
+
__path,
|
|
114
|
+
params=__query,
|
|
115
|
+
headers=__headers,
|
|
116
|
+
endpoint_id="watcher.activate_watch",
|
|
117
|
+
path_parts=__path_parts,
|
|
100
118
|
)
|
|
101
119
|
|
|
102
120
|
@_rewrite_parameters()
|
|
@@ -112,13 +130,14 @@ class WatcherClient(NamespacedClient):
|
|
|
112
130
|
"""
|
|
113
131
|
Deactivates a currently active watch.
|
|
114
132
|
|
|
115
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
133
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-deactivate-watch.html>`_
|
|
116
134
|
|
|
117
135
|
:param watch_id: Watch ID
|
|
118
136
|
"""
|
|
119
137
|
if watch_id in SKIP_IN_PATH:
|
|
120
138
|
raise ValueError("Empty value passed for parameter 'watch_id'")
|
|
121
|
-
|
|
139
|
+
__path_parts: t.Dict[str, str] = {"watch_id": _quote(watch_id)}
|
|
140
|
+
__path = f'/_watcher/watch/{__path_parts["watch_id"]}/_deactivate'
|
|
122
141
|
__query: t.Dict[str, t.Any] = {}
|
|
123
142
|
if error_trace is not None:
|
|
124
143
|
__query["error_trace"] = error_trace
|
|
@@ -130,7 +149,12 @@ class WatcherClient(NamespacedClient):
|
|
|
130
149
|
__query["pretty"] = pretty
|
|
131
150
|
__headers = {"accept": "application/json"}
|
|
132
151
|
return await self.perform_request( # type: ignore[return-value]
|
|
133
|
-
"PUT",
|
|
152
|
+
"PUT",
|
|
153
|
+
__path,
|
|
154
|
+
params=__query,
|
|
155
|
+
headers=__headers,
|
|
156
|
+
endpoint_id="watcher.deactivate_watch",
|
|
157
|
+
path_parts=__path_parts,
|
|
134
158
|
)
|
|
135
159
|
|
|
136
160
|
@_rewrite_parameters()
|
|
@@ -146,13 +170,14 @@ class WatcherClient(NamespacedClient):
|
|
|
146
170
|
"""
|
|
147
171
|
Removes a watch from Watcher.
|
|
148
172
|
|
|
149
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
173
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-delete-watch.html>`_
|
|
150
174
|
|
|
151
175
|
:param id: Watch ID
|
|
152
176
|
"""
|
|
153
177
|
if id in SKIP_IN_PATH:
|
|
154
178
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
155
|
-
|
|
179
|
+
__path_parts: t.Dict[str, str] = {"id": _quote(id)}
|
|
180
|
+
__path = f'/_watcher/watch/{__path_parts["id"]}'
|
|
156
181
|
__query: t.Dict[str, t.Any] = {}
|
|
157
182
|
if error_trace is not None:
|
|
158
183
|
__query["error_trace"] = error_trace
|
|
@@ -164,7 +189,12 @@ class WatcherClient(NamespacedClient):
|
|
|
164
189
|
__query["pretty"] = pretty
|
|
165
190
|
__headers = {"accept": "application/json"}
|
|
166
191
|
return await self.perform_request( # type: ignore[return-value]
|
|
167
|
-
"DELETE",
|
|
192
|
+
"DELETE",
|
|
193
|
+
__path,
|
|
194
|
+
params=__query,
|
|
195
|
+
headers=__headers,
|
|
196
|
+
endpoint_id="watcher.delete_watch",
|
|
197
|
+
path_parts=__path_parts,
|
|
168
198
|
)
|
|
169
199
|
|
|
170
200
|
@_rewrite_parameters(
|
|
@@ -207,7 +237,7 @@ class WatcherClient(NamespacedClient):
|
|
|
207
237
|
"""
|
|
208
238
|
Forces the execution of a stored watch.
|
|
209
239
|
|
|
210
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
240
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-execute-watch.html>`_
|
|
211
241
|
|
|
212
242
|
:param id: Identifier for the watch.
|
|
213
243
|
:param action_modes: Determines how to handle the watch actions as part of the
|
|
@@ -228,9 +258,12 @@ class WatcherClient(NamespacedClient):
|
|
|
228
258
|
the request. This watch is not persisted to the index and record_execution
|
|
229
259
|
cannot be set.
|
|
230
260
|
"""
|
|
261
|
+
__path_parts: t.Dict[str, str]
|
|
231
262
|
if id not in SKIP_IN_PATH:
|
|
232
|
-
|
|
263
|
+
__path_parts = {"id": _quote(id)}
|
|
264
|
+
__path = f'/_watcher/watch/{__path_parts["id"]}/_execute'
|
|
233
265
|
else:
|
|
266
|
+
__path_parts = {}
|
|
234
267
|
__path = "/_watcher/watch/_execute"
|
|
235
268
|
__query: t.Dict[str, t.Any] = {}
|
|
236
269
|
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
@@ -265,7 +298,13 @@ class WatcherClient(NamespacedClient):
|
|
|
265
298
|
if __body is not None:
|
|
266
299
|
__headers["content-type"] = "application/json"
|
|
267
300
|
return await self.perform_request( # type: ignore[return-value]
|
|
268
|
-
"PUT",
|
|
301
|
+
"PUT",
|
|
302
|
+
__path,
|
|
303
|
+
params=__query,
|
|
304
|
+
headers=__headers,
|
|
305
|
+
body=__body,
|
|
306
|
+
endpoint_id="watcher.execute_watch",
|
|
307
|
+
path_parts=__path_parts,
|
|
269
308
|
)
|
|
270
309
|
|
|
271
310
|
@_rewrite_parameters()
|
|
@@ -281,13 +320,14 @@ class WatcherClient(NamespacedClient):
|
|
|
281
320
|
"""
|
|
282
321
|
Retrieves a watch by its ID.
|
|
283
322
|
|
|
284
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
323
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-get-watch.html>`_
|
|
285
324
|
|
|
286
325
|
:param id: Watch ID
|
|
287
326
|
"""
|
|
288
327
|
if id in SKIP_IN_PATH:
|
|
289
328
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
290
|
-
|
|
329
|
+
__path_parts: t.Dict[str, str] = {"id": _quote(id)}
|
|
330
|
+
__path = f'/_watcher/watch/{__path_parts["id"]}'
|
|
291
331
|
__query: t.Dict[str, t.Any] = {}
|
|
292
332
|
if error_trace is not None:
|
|
293
333
|
__query["error_trace"] = error_trace
|
|
@@ -299,7 +339,12 @@ class WatcherClient(NamespacedClient):
|
|
|
299
339
|
__query["pretty"] = pretty
|
|
300
340
|
__headers = {"accept": "application/json"}
|
|
301
341
|
return await self.perform_request( # type: ignore[return-value]
|
|
302
|
-
"GET",
|
|
342
|
+
"GET",
|
|
343
|
+
__path,
|
|
344
|
+
params=__query,
|
|
345
|
+
headers=__headers,
|
|
346
|
+
endpoint_id="watcher.get_watch",
|
|
347
|
+
path_parts=__path_parts,
|
|
303
348
|
)
|
|
304
349
|
|
|
305
350
|
@_rewrite_parameters(
|
|
@@ -337,7 +382,7 @@ class WatcherClient(NamespacedClient):
|
|
|
337
382
|
"""
|
|
338
383
|
Creates a new watch, or updates an existing one.
|
|
339
384
|
|
|
340
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
385
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-put-watch.html>`_
|
|
341
386
|
|
|
342
387
|
:param id: Watch ID
|
|
343
388
|
:param actions:
|
|
@@ -356,7 +401,8 @@ class WatcherClient(NamespacedClient):
|
|
|
356
401
|
"""
|
|
357
402
|
if id in SKIP_IN_PATH:
|
|
358
403
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
359
|
-
|
|
404
|
+
__path_parts: t.Dict[str, str] = {"id": _quote(id)}
|
|
405
|
+
__path = f'/_watcher/watch/{__path_parts["id"]}'
|
|
360
406
|
__query: t.Dict[str, t.Any] = {}
|
|
361
407
|
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
362
408
|
if active is not None:
|
|
@@ -396,7 +442,13 @@ class WatcherClient(NamespacedClient):
|
|
|
396
442
|
if __body is not None:
|
|
397
443
|
__headers["content-type"] = "application/json"
|
|
398
444
|
return await self.perform_request( # type: ignore[return-value]
|
|
399
|
-
"PUT",
|
|
445
|
+
"PUT",
|
|
446
|
+
__path,
|
|
447
|
+
params=__query,
|
|
448
|
+
headers=__headers,
|
|
449
|
+
body=__body,
|
|
450
|
+
endpoint_id="watcher.put_watch",
|
|
451
|
+
path_parts=__path_parts,
|
|
400
452
|
)
|
|
401
453
|
|
|
402
454
|
@_rewrite_parameters(
|
|
@@ -427,7 +479,7 @@ class WatcherClient(NamespacedClient):
|
|
|
427
479
|
"""
|
|
428
480
|
Retrieves stored watches.
|
|
429
481
|
|
|
430
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
482
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-query-watches.html>`_
|
|
431
483
|
|
|
432
484
|
:param from_: The offset from the first result to fetch. Needs to be non-negative.
|
|
433
485
|
:param query: Optional, query filter watches to be returned.
|
|
@@ -436,6 +488,7 @@ class WatcherClient(NamespacedClient):
|
|
|
436
488
|
:param size: The number of hits to return. Needs to be non-negative.
|
|
437
489
|
:param sort: Optional sort definition.
|
|
438
490
|
"""
|
|
491
|
+
__path_parts: t.Dict[str, str] = {}
|
|
439
492
|
__path = "/_watcher/_query/watches"
|
|
440
493
|
__query: t.Dict[str, t.Any] = {}
|
|
441
494
|
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
@@ -475,7 +528,13 @@ class WatcherClient(NamespacedClient):
|
|
|
475
528
|
if __body is not None:
|
|
476
529
|
__headers["content-type"] = "application/json"
|
|
477
530
|
return await self.perform_request( # type: ignore[return-value]
|
|
478
|
-
"POST",
|
|
531
|
+
"POST",
|
|
532
|
+
__path,
|
|
533
|
+
params=__query,
|
|
534
|
+
headers=__headers,
|
|
535
|
+
body=__body,
|
|
536
|
+
endpoint_id="watcher.query_watches",
|
|
537
|
+
path_parts=__path_parts,
|
|
479
538
|
)
|
|
480
539
|
|
|
481
540
|
@_rewrite_parameters()
|
|
@@ -490,8 +549,9 @@ class WatcherClient(NamespacedClient):
|
|
|
490
549
|
"""
|
|
491
550
|
Starts Watcher if it is not already running.
|
|
492
551
|
|
|
493
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
552
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-start.html>`_
|
|
494
553
|
"""
|
|
554
|
+
__path_parts: t.Dict[str, str] = {}
|
|
495
555
|
__path = "/_watcher/_start"
|
|
496
556
|
__query: t.Dict[str, t.Any] = {}
|
|
497
557
|
if error_trace is not None:
|
|
@@ -504,7 +564,12 @@ class WatcherClient(NamespacedClient):
|
|
|
504
564
|
__query["pretty"] = pretty
|
|
505
565
|
__headers = {"accept": "application/json"}
|
|
506
566
|
return await self.perform_request( # type: ignore[return-value]
|
|
507
|
-
"POST",
|
|
567
|
+
"POST",
|
|
568
|
+
__path,
|
|
569
|
+
params=__query,
|
|
570
|
+
headers=__headers,
|
|
571
|
+
endpoint_id="watcher.start",
|
|
572
|
+
path_parts=__path_parts,
|
|
508
573
|
)
|
|
509
574
|
|
|
510
575
|
@_rewrite_parameters()
|
|
@@ -534,15 +599,18 @@ class WatcherClient(NamespacedClient):
|
|
|
534
599
|
"""
|
|
535
600
|
Retrieves the current Watcher metrics.
|
|
536
601
|
|
|
537
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
602
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-stats.html>`_
|
|
538
603
|
|
|
539
604
|
:param metric: Defines which additional metrics are included in the response.
|
|
540
605
|
:param emit_stacktraces: Defines whether stack traces are generated for each
|
|
541
606
|
watch that is running.
|
|
542
607
|
"""
|
|
608
|
+
__path_parts: t.Dict[str, str]
|
|
543
609
|
if metric not in SKIP_IN_PATH:
|
|
544
|
-
|
|
610
|
+
__path_parts = {"metric": _quote(metric)}
|
|
611
|
+
__path = f'/_watcher/stats/{__path_parts["metric"]}'
|
|
545
612
|
else:
|
|
613
|
+
__path_parts = {}
|
|
546
614
|
__path = "/_watcher/stats"
|
|
547
615
|
__query: t.Dict[str, t.Any] = {}
|
|
548
616
|
if emit_stacktraces is not None:
|
|
@@ -557,7 +625,12 @@ class WatcherClient(NamespacedClient):
|
|
|
557
625
|
__query["pretty"] = pretty
|
|
558
626
|
__headers = {"accept": "application/json"}
|
|
559
627
|
return await self.perform_request( # type: ignore[return-value]
|
|
560
|
-
"GET",
|
|
628
|
+
"GET",
|
|
629
|
+
__path,
|
|
630
|
+
params=__query,
|
|
631
|
+
headers=__headers,
|
|
632
|
+
endpoint_id="watcher.stats",
|
|
633
|
+
path_parts=__path_parts,
|
|
561
634
|
)
|
|
562
635
|
|
|
563
636
|
@_rewrite_parameters()
|
|
@@ -572,8 +645,9 @@ class WatcherClient(NamespacedClient):
|
|
|
572
645
|
"""
|
|
573
646
|
Stops Watcher if it is running.
|
|
574
647
|
|
|
575
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
648
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-stop.html>`_
|
|
576
649
|
"""
|
|
650
|
+
__path_parts: t.Dict[str, str] = {}
|
|
577
651
|
__path = "/_watcher/_stop"
|
|
578
652
|
__query: t.Dict[str, t.Any] = {}
|
|
579
653
|
if error_trace is not None:
|
|
@@ -586,5 +660,10 @@ class WatcherClient(NamespacedClient):
|
|
|
586
660
|
__query["pretty"] = pretty
|
|
587
661
|
__headers = {"accept": "application/json"}
|
|
588
662
|
return await self.perform_request( # type: ignore[return-value]
|
|
589
|
-
"POST",
|
|
663
|
+
"POST",
|
|
664
|
+
__path,
|
|
665
|
+
params=__query,
|
|
666
|
+
headers=__headers,
|
|
667
|
+
endpoint_id="watcher.stop",
|
|
668
|
+
path_parts=__path_parts,
|
|
590
669
|
)
|
|
@@ -43,12 +43,13 @@ class XPackClient(NamespacedClient):
|
|
|
43
43
|
"""
|
|
44
44
|
Retrieves information about the installed X-Pack features.
|
|
45
45
|
|
|
46
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
46
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/info-api.html>`_
|
|
47
47
|
|
|
48
48
|
:param accept_enterprise: If this param is used it must be set to true
|
|
49
49
|
:param categories: A comma-separated list of the information categories to include
|
|
50
50
|
in the response. For example, `build,license,features`.
|
|
51
51
|
"""
|
|
52
|
+
__path_parts: t.Dict[str, str] = {}
|
|
52
53
|
__path = "/_xpack"
|
|
53
54
|
__query: t.Dict[str, t.Any] = {}
|
|
54
55
|
if accept_enterprise is not None:
|
|
@@ -65,7 +66,12 @@ class XPackClient(NamespacedClient):
|
|
|
65
66
|
__query["pretty"] = pretty
|
|
66
67
|
__headers = {"accept": "application/json"}
|
|
67
68
|
return await self.perform_request( # type: ignore[return-value]
|
|
68
|
-
"GET",
|
|
69
|
+
"GET",
|
|
70
|
+
__path,
|
|
71
|
+
params=__query,
|
|
72
|
+
headers=__headers,
|
|
73
|
+
endpoint_id="xpack.info",
|
|
74
|
+
path_parts=__path_parts,
|
|
69
75
|
)
|
|
70
76
|
|
|
71
77
|
@_rewrite_parameters()
|
|
@@ -83,12 +89,13 @@ class XPackClient(NamespacedClient):
|
|
|
83
89
|
"""
|
|
84
90
|
Retrieves usage information about the installed X-Pack features.
|
|
85
91
|
|
|
86
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
92
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/usage-api.html>`_
|
|
87
93
|
|
|
88
94
|
:param master_timeout: Period to wait for a connection to the master node. If
|
|
89
95
|
no response is received before the timeout expires, the request fails and
|
|
90
96
|
returns an error.
|
|
91
97
|
"""
|
|
98
|
+
__path_parts: t.Dict[str, str] = {}
|
|
92
99
|
__path = "/_xpack/usage"
|
|
93
100
|
__query: t.Dict[str, t.Any] = {}
|
|
94
101
|
if error_trace is not None:
|
|
@@ -103,5 +110,10 @@ class XPackClient(NamespacedClient):
|
|
|
103
110
|
__query["pretty"] = pretty
|
|
104
111
|
__headers = {"accept": "application/json"}
|
|
105
112
|
return await self.perform_request( # type: ignore[return-value]
|
|
106
|
-
"GET",
|
|
113
|
+
"GET",
|
|
114
|
+
__path,
|
|
115
|
+
params=__query,
|
|
116
|
+
headers=__headers,
|
|
117
|
+
endpoint_id="xpack.usage",
|
|
118
|
+
path_parts=__path_parts,
|
|
107
119
|
)
|
elasticsearch/_async/helpers.py
CHANGED
elasticsearch/_otel.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import contextlib
|
|
21
|
+
import os
|
|
22
|
+
from typing import TYPE_CHECKING, Generator, Mapping
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from typing import Literal
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
from opentelemetry import trace
|
|
29
|
+
|
|
30
|
+
_tracer: trace.Tracer | None = trace.get_tracer("elasticsearch-api")
|
|
31
|
+
except ModuleNotFoundError:
|
|
32
|
+
_tracer = None
|
|
33
|
+
|
|
34
|
+
from elastic_transport import OpenTelemetrySpan
|
|
35
|
+
|
|
36
|
+
# Valid values for the enabled config are 'true' and 'false'. Default is 'true'.
|
|
37
|
+
ENABLED_ENV_VAR = "OTEL_PYTHON_INSTRUMENTATION_ELASTICSEARCH_ENABLED"
|
|
38
|
+
# Describes how to handle search queries in the request body when assigned to
|
|
39
|
+
# a span attribute.
|
|
40
|
+
# Valid values are 'omit' and 'raw'.
|
|
41
|
+
# Default is 'omit' as 'raw' has security implications.
|
|
42
|
+
BODY_STRATEGY_ENV_VAR = "OTEL_PYTHON_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY"
|
|
43
|
+
DEFAULT_BODY_STRATEGY = "omit"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class OpenTelemetry:
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
enabled: bool | None = None,
|
|
50
|
+
tracer: trace.Tracer | None = None,
|
|
51
|
+
# TODO import Literal at the top-level when dropping Python 3.7
|
|
52
|
+
body_strategy: 'Literal["omit", "raw"]' | None = None,
|
|
53
|
+
):
|
|
54
|
+
if enabled is None:
|
|
55
|
+
enabled = os.environ.get(ENABLED_ENV_VAR, "true") == "true"
|
|
56
|
+
self.tracer = tracer or _tracer
|
|
57
|
+
self.enabled = enabled and self.tracer is not None
|
|
58
|
+
|
|
59
|
+
if body_strategy is not None:
|
|
60
|
+
self.body_strategy = body_strategy
|
|
61
|
+
else:
|
|
62
|
+
self.body_strategy = os.environ.get(
|
|
63
|
+
BODY_STRATEGY_ENV_VAR, DEFAULT_BODY_STRATEGY
|
|
64
|
+
) # type: ignore[assignment]
|
|
65
|
+
assert self.body_strategy in ("omit", "raw")
|
|
66
|
+
|
|
67
|
+
@contextlib.contextmanager
|
|
68
|
+
def span(
|
|
69
|
+
self,
|
|
70
|
+
method: str,
|
|
71
|
+
*,
|
|
72
|
+
endpoint_id: str | None,
|
|
73
|
+
path_parts: Mapping[str, str],
|
|
74
|
+
) -> Generator[OpenTelemetrySpan, None, None]:
|
|
75
|
+
if not self.enabled or self.tracer is None:
|
|
76
|
+
yield OpenTelemetrySpan(None)
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
span_name = endpoint_id or method
|
|
80
|
+
with self.tracer.start_as_current_span(span_name) as otel_span:
|
|
81
|
+
otel_span.set_attribute("http.request.method", method)
|
|
82
|
+
otel_span.set_attribute("db.system", "elasticsearch")
|
|
83
|
+
if endpoint_id is not None:
|
|
84
|
+
otel_span.set_attribute("db.operation", endpoint_id)
|
|
85
|
+
for key, value in path_parts.items():
|
|
86
|
+
otel_span.set_attribute(f"db.elasticsearch.path_parts.{key}", value)
|
|
87
|
+
|
|
88
|
+
yield OpenTelemetrySpan(
|
|
89
|
+
otel_span,
|
|
90
|
+
endpoint_id=endpoint_id,
|
|
91
|
+
body_strategy=self.body_strategy,
|
|
92
|
+
)
|