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,616 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ import typing as t
19
+
20
+ from elastic_transport import ObjectApiResponse
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import (
24
+ SKIP_IN_PATH,
25
+ Stability,
26
+ _quote,
27
+ _rewrite_parameters,
28
+ _stability_warning,
29
+ )
30
+
31
+
32
+ class RollupClient(NamespacedClient):
33
+
34
+ @_rewrite_parameters()
35
+ @_stability_warning(Stability.EXPERIMENTAL)
36
+ async def delete_job(
37
+ self,
38
+ *,
39
+ id: str,
40
+ error_trace: t.Optional[bool] = None,
41
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
42
+ human: t.Optional[bool] = None,
43
+ pretty: t.Optional[bool] = None,
44
+ ) -> ObjectApiResponse[t.Any]:
45
+ """
46
+ .. raw:: html
47
+
48
+ <p>Delete a rollup job.</p>
49
+ <p>A job must be stopped before it can be deleted.
50
+ If you attempt to delete a started job, an error occurs.
51
+ Similarly, if you attempt to delete a nonexistent job, an exception occurs.</p>
52
+ <p>IMPORTANT: When you delete a job, you remove only the process that is actively monitoring and rolling up data.
53
+ The API does not delete any previously rolled up data.
54
+ This is by design; a user may wish to roll up a static data set.
55
+ Because the data set is static, after it has been fully rolled up there is no need to keep the indexing rollup job around (as there will be no new data).
56
+ Thus the job can be deleted, leaving behind the rolled up data for analysis.
57
+ If you wish to also remove the rollup data and the rollup index contains the data for only a single job, you can delete the whole rollup index.
58
+ If the rollup index stores data from several jobs, you must issue a delete-by-query that targets the rollup job's identifier in the rollup index. For example:</p>
59
+ <pre><code>POST my_rollup_index/_delete_by_query
60
+ {
61
+ &quot;query&quot;: {
62
+ &quot;term&quot;: {
63
+ &quot;_rollup.id&quot;: &quot;the_rollup_job_id&quot;
64
+ }
65
+ }
66
+ }
67
+ </code></pre>
68
+
69
+
70
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-delete-job>`_
71
+
72
+ :param id: Identifier for the job.
73
+ """
74
+ if id in SKIP_IN_PATH:
75
+ raise ValueError("Empty value passed for parameter 'id'")
76
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
77
+ __path = f'/_rollup/job/{__path_parts["id"]}'
78
+ __query: t.Dict[str, t.Any] = {}
79
+ if error_trace is not None:
80
+ __query["error_trace"] = error_trace
81
+ if filter_path is not None:
82
+ __query["filter_path"] = filter_path
83
+ if human is not None:
84
+ __query["human"] = human
85
+ if pretty is not None:
86
+ __query["pretty"] = pretty
87
+ __headers = {"accept": "application/json"}
88
+ return await self.perform_request( # type: ignore[return-value]
89
+ "DELETE",
90
+ __path,
91
+ params=__query,
92
+ headers=__headers,
93
+ endpoint_id="rollup.delete_job",
94
+ path_parts=__path_parts,
95
+ )
96
+
97
+ @_rewrite_parameters()
98
+ @_stability_warning(Stability.EXPERIMENTAL)
99
+ async def get_jobs(
100
+ self,
101
+ *,
102
+ id: t.Optional[str] = None,
103
+ error_trace: t.Optional[bool] = None,
104
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
105
+ human: t.Optional[bool] = None,
106
+ pretty: t.Optional[bool] = None,
107
+ ) -> ObjectApiResponse[t.Any]:
108
+ """
109
+ .. raw:: html
110
+
111
+ <p>Get rollup job information.
112
+ Get the configuration, stats, and status of rollup jobs.</p>
113
+ <p>NOTE: This API returns only active (both <code>STARTED</code> and <code>STOPPED</code>) jobs.
114
+ If a job was created, ran for a while, then was deleted, the API does not return any details about it.
115
+ For details about a historical rollup job, the rollup capabilities API may be more useful.</p>
116
+
117
+
118
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-get-jobs>`_
119
+
120
+ :param id: Identifier for the rollup job. If it is `_all` or omitted, the API
121
+ returns all rollup jobs.
122
+ """
123
+ __path_parts: t.Dict[str, str]
124
+ if id not in SKIP_IN_PATH:
125
+ __path_parts = {"id": _quote(id)}
126
+ __path = f'/_rollup/job/{__path_parts["id"]}'
127
+ else:
128
+ __path_parts = {}
129
+ __path = "/_rollup/job"
130
+ __query: t.Dict[str, t.Any] = {}
131
+ if error_trace is not None:
132
+ __query["error_trace"] = error_trace
133
+ if filter_path is not None:
134
+ __query["filter_path"] = filter_path
135
+ if human is not None:
136
+ __query["human"] = human
137
+ if pretty is not None:
138
+ __query["pretty"] = pretty
139
+ __headers = {"accept": "application/json"}
140
+ return await self.perform_request( # type: ignore[return-value]
141
+ "GET",
142
+ __path,
143
+ params=__query,
144
+ headers=__headers,
145
+ endpoint_id="rollup.get_jobs",
146
+ path_parts=__path_parts,
147
+ )
148
+
149
+ @_rewrite_parameters()
150
+ @_stability_warning(Stability.EXPERIMENTAL)
151
+ async def get_rollup_caps(
152
+ self,
153
+ *,
154
+ id: t.Optional[str] = None,
155
+ error_trace: t.Optional[bool] = None,
156
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
157
+ human: t.Optional[bool] = None,
158
+ pretty: t.Optional[bool] = None,
159
+ ) -> ObjectApiResponse[t.Any]:
160
+ """
161
+ .. raw:: html
162
+
163
+ <p>Get the rollup job capabilities.
164
+ Get the capabilities of any rollup jobs that have been configured for a specific index or index pattern.</p>
165
+ <p>This API is useful because a rollup job is often configured to rollup only a subset of fields from the source index.
166
+ Furthermore, only certain aggregations can be configured for various fields, leading to a limited subset of functionality depending on that configuration.
167
+ This API enables you to inspect an index and determine:</p>
168
+ <ol>
169
+ <li>Does this index have associated rollup data somewhere in the cluster?</li>
170
+ <li>If yes to the first question, what fields were rolled up, what aggregations can be performed, and where does the data live?</li>
171
+ </ol>
172
+
173
+
174
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-get-rollup-caps>`_
175
+
176
+ :param id: Index, indices or index-pattern to return rollup capabilities for.
177
+ `_all` may be used to fetch rollup capabilities from all jobs.
178
+ """
179
+ __path_parts: t.Dict[str, str]
180
+ if id not in SKIP_IN_PATH:
181
+ __path_parts = {"id": _quote(id)}
182
+ __path = f'/_rollup/data/{__path_parts["id"]}'
183
+ else:
184
+ __path_parts = {}
185
+ __path = "/_rollup/data"
186
+ __query: t.Dict[str, t.Any] = {}
187
+ if error_trace is not None:
188
+ __query["error_trace"] = error_trace
189
+ if filter_path is not None:
190
+ __query["filter_path"] = filter_path
191
+ if human is not None:
192
+ __query["human"] = human
193
+ if pretty is not None:
194
+ __query["pretty"] = pretty
195
+ __headers = {"accept": "application/json"}
196
+ return await self.perform_request( # type: ignore[return-value]
197
+ "GET",
198
+ __path,
199
+ params=__query,
200
+ headers=__headers,
201
+ endpoint_id="rollup.get_rollup_caps",
202
+ path_parts=__path_parts,
203
+ )
204
+
205
+ @_rewrite_parameters()
206
+ @_stability_warning(Stability.EXPERIMENTAL)
207
+ async def get_rollup_index_caps(
208
+ self,
209
+ *,
210
+ index: t.Union[str, t.Sequence[str]],
211
+ error_trace: t.Optional[bool] = None,
212
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
213
+ human: t.Optional[bool] = None,
214
+ pretty: t.Optional[bool] = None,
215
+ ) -> ObjectApiResponse[t.Any]:
216
+ """
217
+ .. raw:: html
218
+
219
+ <p>Get the rollup index capabilities.
220
+ Get the rollup capabilities of all jobs inside of a rollup index.
221
+ A single rollup index may store the data for multiple rollup jobs and may have a variety of capabilities depending on those jobs. This API enables you to determine:</p>
222
+ <ul>
223
+ <li>What jobs are stored in an index (or indices specified via a pattern)?</li>
224
+ <li>What target indices were rolled up, what fields were used in those rollups, and what aggregations can be performed on each job?</li>
225
+ </ul>
226
+
227
+
228
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-get-rollup-index-caps>`_
229
+
230
+ :param index: Data stream or index to check for rollup capabilities. Wildcard
231
+ (`*`) expressions are supported.
232
+ """
233
+ if index in SKIP_IN_PATH:
234
+ raise ValueError("Empty value passed for parameter 'index'")
235
+ __path_parts: t.Dict[str, str] = {"index": _quote(index)}
236
+ __path = f'/{__path_parts["index"]}/_rollup/data'
237
+ __query: t.Dict[str, t.Any] = {}
238
+ if error_trace is not None:
239
+ __query["error_trace"] = error_trace
240
+ if filter_path is not None:
241
+ __query["filter_path"] = filter_path
242
+ if human is not None:
243
+ __query["human"] = human
244
+ if pretty is not None:
245
+ __query["pretty"] = pretty
246
+ __headers = {"accept": "application/json"}
247
+ return await self.perform_request( # type: ignore[return-value]
248
+ "GET",
249
+ __path,
250
+ params=__query,
251
+ headers=__headers,
252
+ endpoint_id="rollup.get_rollup_index_caps",
253
+ path_parts=__path_parts,
254
+ )
255
+
256
+ @_rewrite_parameters(
257
+ body_fields=(
258
+ "cron",
259
+ "groups",
260
+ "index_pattern",
261
+ "page_size",
262
+ "rollup_index",
263
+ "headers",
264
+ "metrics",
265
+ "timeout",
266
+ ),
267
+ ignore_deprecated_options={"headers"},
268
+ )
269
+ @_stability_warning(Stability.EXPERIMENTAL)
270
+ async def put_job(
271
+ self,
272
+ *,
273
+ id: str,
274
+ cron: t.Optional[str] = None,
275
+ groups: t.Optional[t.Mapping[str, t.Any]] = None,
276
+ index_pattern: t.Optional[str] = None,
277
+ page_size: t.Optional[int] = None,
278
+ rollup_index: t.Optional[str] = None,
279
+ error_trace: t.Optional[bool] = None,
280
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
281
+ headers: t.Optional[t.Mapping[str, t.Union[str, t.Sequence[str]]]] = None,
282
+ human: t.Optional[bool] = None,
283
+ metrics: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
284
+ pretty: t.Optional[bool] = None,
285
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
286
+ body: t.Optional[t.Dict[str, t.Any]] = None,
287
+ ) -> ObjectApiResponse[t.Any]:
288
+ """
289
+ .. raw:: html
290
+
291
+ <p>Create a rollup job.</p>
292
+ <p>WARNING: From 8.15.0, calling this API in a cluster with no rollup usage will fail with a message about the deprecation and planned removal of rollup features. A cluster needs to contain either a rollup job or a rollup index in order for this API to be allowed to run.</p>
293
+ <p>The rollup job configuration contains all the details about how the job should run, when it indexes documents, and what future queries will be able to run against the rollup index.</p>
294
+ <p>There are three main sections to the job configuration: the logistical details about the job (for example, the cron schedule), the fields that are used for grouping, and what metrics to collect for each group.</p>
295
+ <p>Jobs are created in a <code>STOPPED</code> state. You can start them with the start rollup jobs API.</p>
296
+
297
+
298
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-put-job>`_
299
+
300
+ :param id: Identifier for the rollup job. This can be any alphanumeric string
301
+ and uniquely identifies the data that is associated with the rollup job.
302
+ The ID is persistent; it is stored with the rolled up data. If you create
303
+ a job, let it run for a while, then delete the job, the data that the job
304
+ rolled up is still be associated with this job ID. You cannot create a new
305
+ job with the same ID since that could lead to problems with mismatched job
306
+ configurations.
307
+ :param cron: A cron string which defines the intervals when the rollup job should
308
+ be executed. When the interval triggers, the indexer attempts to rollup the
309
+ data in the index pattern. The cron pattern is unrelated to the time interval
310
+ of the data being rolled up. For example, you may wish to create hourly rollups
311
+ of your document but to only run the indexer on a daily basis at midnight,
312
+ as defined by the cron. The cron pattern is defined just like a Watcher cron
313
+ schedule.
314
+ :param groups: Defines the grouping fields and aggregations that are defined
315
+ for this rollup job. These fields will then be available later for aggregating
316
+ into buckets. These aggs and fields can be used in any combination. Think
317
+ of the groups configuration as defining a set of tools that can later be
318
+ used in aggregations to partition the data. Unlike raw data, we have to think
319
+ ahead to which fields and aggregations might be used. Rollups provide enough
320
+ flexibility that you simply need to determine which fields are needed, not
321
+ in what order they are needed.
322
+ :param index_pattern: The index or index pattern to roll up. Supports wildcard-style
323
+ patterns (`logstash-*`). The job attempts to rollup the entire index or index-pattern.
324
+ :param page_size: The number of bucket results that are processed on each iteration
325
+ of the rollup indexer. A larger value tends to execute faster, but requires
326
+ more memory during processing. This value has no effect on how the data is
327
+ rolled up; it is merely used for tweaking the speed or memory cost of the
328
+ indexer.
329
+ :param rollup_index: The index that contains the rollup results. The index can
330
+ be shared with other rollup jobs. The data is stored so that it doesn’t interfere
331
+ with unrelated jobs.
332
+ :param headers:
333
+ :param metrics: Defines the metrics to collect for each grouping tuple. By default,
334
+ only the doc_counts are collected for each group. To make rollup useful,
335
+ you will often add metrics like averages, mins, maxes, etc. Metrics are defined
336
+ on a per-field basis and for each field you configure which metric should
337
+ be collected.
338
+ :param timeout: Time to wait for the request to complete.
339
+ """
340
+ if id in SKIP_IN_PATH:
341
+ raise ValueError("Empty value passed for parameter 'id'")
342
+ if cron is None and body is None:
343
+ raise ValueError("Empty value passed for parameter 'cron'")
344
+ if groups is None and body is None:
345
+ raise ValueError("Empty value passed for parameter 'groups'")
346
+ if index_pattern is None and body is None:
347
+ raise ValueError("Empty value passed for parameter 'index_pattern'")
348
+ if page_size is None and body is None:
349
+ raise ValueError("Empty value passed for parameter 'page_size'")
350
+ if rollup_index is None and body is None:
351
+ raise ValueError("Empty value passed for parameter 'rollup_index'")
352
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
353
+ __path = f'/_rollup/job/{__path_parts["id"]}'
354
+ __query: t.Dict[str, t.Any] = {}
355
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
356
+ if error_trace is not None:
357
+ __query["error_trace"] = error_trace
358
+ if filter_path is not None:
359
+ __query["filter_path"] = filter_path
360
+ if human is not None:
361
+ __query["human"] = human
362
+ if pretty is not None:
363
+ __query["pretty"] = pretty
364
+ if not __body:
365
+ if cron is not None:
366
+ __body["cron"] = cron
367
+ if groups is not None:
368
+ __body["groups"] = groups
369
+ if index_pattern is not None:
370
+ __body["index_pattern"] = index_pattern
371
+ if page_size is not None:
372
+ __body["page_size"] = page_size
373
+ if rollup_index is not None:
374
+ __body["rollup_index"] = rollup_index
375
+ if headers is not None:
376
+ __body["headers"] = headers
377
+ if metrics is not None:
378
+ __body["metrics"] = metrics
379
+ if timeout is not None:
380
+ __body["timeout"] = timeout
381
+ __headers = {"accept": "application/json", "content-type": "application/json"}
382
+ return await self.perform_request( # type: ignore[return-value]
383
+ "PUT",
384
+ __path,
385
+ params=__query,
386
+ headers=__headers,
387
+ body=__body,
388
+ endpoint_id="rollup.put_job",
389
+ path_parts=__path_parts,
390
+ )
391
+
392
+ @_rewrite_parameters(
393
+ body_fields=("aggregations", "aggs", "query", "size"),
394
+ )
395
+ @_stability_warning(Stability.EXPERIMENTAL)
396
+ async def rollup_search(
397
+ self,
398
+ *,
399
+ index: t.Union[str, t.Sequence[str]],
400
+ aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
401
+ aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
402
+ error_trace: t.Optional[bool] = None,
403
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
404
+ human: t.Optional[bool] = None,
405
+ pretty: t.Optional[bool] = None,
406
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
407
+ rest_total_hits_as_int: t.Optional[bool] = None,
408
+ size: t.Optional[int] = None,
409
+ typed_keys: t.Optional[bool] = None,
410
+ body: t.Optional[t.Dict[str, t.Any]] = None,
411
+ ) -> ObjectApiResponse[t.Any]:
412
+ """
413
+ .. raw:: html
414
+
415
+ <p>Search rolled-up data.
416
+ The rollup search endpoint is needed because, internally, rolled-up documents utilize a different document structure than the original data.
417
+ It rewrites standard Query DSL into a format that matches the rollup documents then takes the response and rewrites it back to what a client would expect given the original query.</p>
418
+ <p>The request body supports a subset of features from the regular search API.
419
+ The following functionality is not available:</p>
420
+ <p><code>size</code>: Because rollups work on pre-aggregated data, no search hits can be returned and so size must be set to zero or omitted entirely.
421
+ <code>highlighter</code>, <code>suggestors</code>, <code>post_filter</code>, <code>profile</code>, <code>explain</code>: These are similarly disallowed.</p>
422
+ <p><strong>Searching both historical rollup and non-rollup data</strong></p>
423
+ <p>The rollup search API has the capability to search across both &quot;live&quot; non-rollup data and the aggregated rollup data.
424
+ This is done by simply adding the live indices to the URI. For example:</p>
425
+ <pre><code>GET sensor-1,sensor_rollup/_rollup_search
426
+ {
427
+ &quot;size&quot;: 0,
428
+ &quot;aggregations&quot;: {
429
+ &quot;max_temperature&quot;: {
430
+ &quot;max&quot;: {
431
+ &quot;field&quot;: &quot;temperature&quot;
432
+ }
433
+ }
434
+ }
435
+ }
436
+ </code></pre>
437
+ <p>The rollup search endpoint does two things when the search runs:</p>
438
+ <ul>
439
+ <li>The original request is sent to the non-rollup index unaltered.</li>
440
+ <li>A rewritten version of the original request is sent to the rollup index.</li>
441
+ </ul>
442
+ <p>When the two responses are received, the endpoint rewrites the rollup response and merges the two together.
443
+ During the merging process, if there is any overlap in buckets between the two responses, the buckets from the non-rollup index are used.</p>
444
+
445
+
446
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-rollup-search>`_
447
+
448
+ :param index: A comma-separated list of data streams and indices used to limit
449
+ the request. This parameter has the following rules: * At least one data
450
+ stream, index, or wildcard expression must be specified. This target can
451
+ include a rollup or non-rollup index. For data streams, the stream's backing
452
+ indices can only serve as non-rollup indices. Omitting the parameter or using
453
+ `_all` are not permitted. * Multiple non-rollup indices may be specified.
454
+ * Only one rollup index may be specified. If more than one are supplied,
455
+ an exception occurs. * Wildcard expressions (`*`) may be used. If they match
456
+ more than one rollup index, an exception occurs. However, you can use an
457
+ expression to match multiple non-rollup indices or data streams.
458
+ :param aggregations: Specifies aggregations.
459
+ :param aggs: Specifies aggregations.
460
+ :param query: Specifies a DSL query that is subject to some limitations.
461
+ :param rest_total_hits_as_int: Indicates whether hits.total should be rendered
462
+ as an integer or an object in the rest search response
463
+ :param size: Must be zero if set, as rollups work on pre-aggregated data.
464
+ :param typed_keys: Specify whether aggregation and suggester names should be
465
+ prefixed by their respective types in the response
466
+ """
467
+ if index in SKIP_IN_PATH:
468
+ raise ValueError("Empty value passed for parameter 'index'")
469
+ __path_parts: t.Dict[str, str] = {"index": _quote(index)}
470
+ __path = f'/{__path_parts["index"]}/_rollup_search'
471
+ __query: t.Dict[str, t.Any] = {}
472
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
473
+ if error_trace is not None:
474
+ __query["error_trace"] = error_trace
475
+ if filter_path is not None:
476
+ __query["filter_path"] = filter_path
477
+ if human is not None:
478
+ __query["human"] = human
479
+ if pretty is not None:
480
+ __query["pretty"] = pretty
481
+ if rest_total_hits_as_int is not None:
482
+ __query["rest_total_hits_as_int"] = rest_total_hits_as_int
483
+ if typed_keys is not None:
484
+ __query["typed_keys"] = typed_keys
485
+ if not __body:
486
+ if aggregations is not None:
487
+ __body["aggregations"] = aggregations
488
+ if aggs is not None:
489
+ __body["aggs"] = aggs
490
+ if query is not None:
491
+ __body["query"] = query
492
+ if size is not None:
493
+ __body["size"] = size
494
+ __headers = {"accept": "application/json", "content-type": "application/json"}
495
+ return await self.perform_request( # type: ignore[return-value]
496
+ "POST",
497
+ __path,
498
+ params=__query,
499
+ headers=__headers,
500
+ body=__body,
501
+ endpoint_id="rollup.rollup_search",
502
+ path_parts=__path_parts,
503
+ )
504
+
505
+ @_rewrite_parameters()
506
+ @_stability_warning(Stability.EXPERIMENTAL)
507
+ async def start_job(
508
+ self,
509
+ *,
510
+ id: str,
511
+ error_trace: t.Optional[bool] = None,
512
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
513
+ human: t.Optional[bool] = None,
514
+ pretty: t.Optional[bool] = None,
515
+ ) -> ObjectApiResponse[t.Any]:
516
+ """
517
+ .. raw:: html
518
+
519
+ <p>Start rollup jobs.
520
+ If you try to start a job that does not exist, an exception occurs.
521
+ If you try to start a job that is already started, nothing happens.</p>
522
+
523
+
524
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-start-job>`_
525
+
526
+ :param id: Identifier for the rollup job.
527
+ """
528
+ if id in SKIP_IN_PATH:
529
+ raise ValueError("Empty value passed for parameter 'id'")
530
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
531
+ __path = f'/_rollup/job/{__path_parts["id"]}/_start'
532
+ __query: t.Dict[str, t.Any] = {}
533
+ if error_trace is not None:
534
+ __query["error_trace"] = error_trace
535
+ if filter_path is not None:
536
+ __query["filter_path"] = filter_path
537
+ if human is not None:
538
+ __query["human"] = human
539
+ if pretty is not None:
540
+ __query["pretty"] = pretty
541
+ __headers = {"accept": "application/json"}
542
+ return await self.perform_request( # type: ignore[return-value]
543
+ "POST",
544
+ __path,
545
+ params=__query,
546
+ headers=__headers,
547
+ endpoint_id="rollup.start_job",
548
+ path_parts=__path_parts,
549
+ )
550
+
551
+ @_rewrite_parameters()
552
+ @_stability_warning(Stability.EXPERIMENTAL)
553
+ async def stop_job(
554
+ self,
555
+ *,
556
+ id: str,
557
+ error_trace: t.Optional[bool] = None,
558
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
559
+ human: t.Optional[bool] = None,
560
+ pretty: t.Optional[bool] = None,
561
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
562
+ wait_for_completion: t.Optional[bool] = None,
563
+ ) -> ObjectApiResponse[t.Any]:
564
+ """
565
+ .. raw:: html
566
+
567
+ <p>Stop rollup jobs.
568
+ If you try to stop a job that does not exist, an exception occurs.
569
+ If you try to stop a job that is already stopped, nothing happens.</p>
570
+ <p>Since only a stopped job can be deleted, it can be useful to block the API until the indexer has fully stopped.
571
+ This is accomplished with the <code>wait_for_completion</code> query parameter, and optionally a timeout. For example:</p>
572
+ <pre><code>POST _rollup/job/sensor/_stop?wait_for_completion=true&amp;timeout=10s
573
+ </code></pre>
574
+ <p>The parameter blocks the API call from returning until either the job has moved to STOPPED or the specified time has elapsed.
575
+ If the specified time elapses without the job moving to STOPPED, a timeout exception occurs.</p>
576
+
577
+
578
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rollup-stop-job>`_
579
+
580
+ :param id: Identifier for the rollup job.
581
+ :param timeout: If `wait_for_completion` is `true`, the API blocks for (at maximum)
582
+ the specified duration while waiting for the job to stop. If more than `timeout`
583
+ time has passed, the API throws a timeout exception. NOTE: Even if a timeout
584
+ occurs, the stop request is still processing and eventually moves the job
585
+ to STOPPED. The timeout simply means the API call itself timed out while
586
+ waiting for the status change.
587
+ :param wait_for_completion: If set to `true`, causes the API to block until the
588
+ indexer state completely stops. If set to `false`, the API returns immediately
589
+ and the indexer is stopped asynchronously in the background.
590
+ """
591
+ if id in SKIP_IN_PATH:
592
+ raise ValueError("Empty value passed for parameter 'id'")
593
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
594
+ __path = f'/_rollup/job/{__path_parts["id"]}/_stop'
595
+ __query: t.Dict[str, t.Any] = {}
596
+ if error_trace is not None:
597
+ __query["error_trace"] = error_trace
598
+ if filter_path is not None:
599
+ __query["filter_path"] = filter_path
600
+ if human is not None:
601
+ __query["human"] = human
602
+ if pretty is not None:
603
+ __query["pretty"] = pretty
604
+ if timeout is not None:
605
+ __query["timeout"] = timeout
606
+ if wait_for_completion is not None:
607
+ __query["wait_for_completion"] = wait_for_completion
608
+ __headers = {"accept": "application/json"}
609
+ return await self.perform_request( # type: ignore[return-value]
610
+ "POST",
611
+ __path,
612
+ params=__query,
613
+ headers=__headers,
614
+ endpoint_id="rollup.stop_job",
615
+ path_parts=__path_parts,
616
+ )