|
20 | 20 | importtypingast |
21 | 21 |
|
22 | 22 | fromelastic_transportimport ( |
| 23 | +ApiResponse, |
23 | 24 | AsyncTransport, |
24 | 25 | BaseNode, |
25 | 26 | BinaryApiResponse, |
26 | 27 | HeadApiResponse, |
| 28 | +HttpHeaders, |
27 | 29 | NodeConfig, |
28 | 30 | NodePool, |
29 | 31 | NodeSelector, |
|
97 | 99 | SelfType=t.TypeVar("SelfType", bound="AsyncElasticsearch") |
98 | 100 |
|
99 | 101 |
|
100 | | -classAsyncElasticsearch(BaseClient): |
| 102 | +classAsyncElasticsearch: |
101 | 103 | """ |
102 | 104 | Elasticsearch low-level client. Provides a straightforward mapping from |
103 | 105 | Python to Elasticsearch REST APIs. |
@@ -224,6 +226,18 @@ def __init__( |
224 | 226 | ): |
225 | 227 | sniff_callback=default_sniff_callback |
226 | 228 |
|
| 229 | +headers=HttpHeaders() |
| 230 | +ifheadersisnotDEFAULTandheadersisnotNone: |
| 231 | +headers.update(headers) |
| 232 | +ifopaque_idisnotDEFAULTandopaque_idisnotNone: # type: ignore[comparison-overlap] |
| 233 | +headers["x-opaque-id"] =opaque_id |
| 234 | +headers=resolve_auth_headers( |
| 235 | +headers, |
| 236 | +api_key=api_key, |
| 237 | +basic_auth=basic_auth, |
| 238 | +bearer_auth=bearer_auth, |
| 239 | + ) |
| 240 | + |
227 | 241 | if_transportisNone: |
228 | 242 | node_configs=client_node_configs( |
229 | 243 | hosts, |
@@ -295,72 +309,92 @@ def __init__( |
295 | 309 | **transport_kwargs, |
296 | 310 | ) |
297 | 311 |
|
298 | | -super().__init__(_transport) |
| 312 | +self._base_client=BaseClient(_transport, headers=headers) |
299 | 313 |
|
300 | 314 | # These are set per-request so are stored separately. |
301 | | -self._request_timeout=request_timeout |
302 | | -self._max_retries=max_retries |
303 | | -self._retry_on_timeout=retry_on_timeout |
| 315 | +self._base_client._request_timeout=request_timeout |
| 316 | +self._base_client._max_retries=max_retries |
| 317 | +self._base_client._retry_on_timeout=retry_on_timeout |
304 | 318 | ifisinstance(retry_on_status, int): |
305 | 319 | retry_on_status= (retry_on_status,) |
306 | | -self._retry_on_status=retry_on_status |
| 320 | +self._base_client._retry_on_status=retry_on_status |
307 | 321 |
|
308 | 322 | else: |
309 | | -super().__init__(_transport) |
310 | | - |
311 | | -ifheadersisnotDEFAULTandheadersisnotNone: |
312 | | -self._headers.update(headers) |
313 | | -ifopaque_idisnotDEFAULTandopaque_idisnotNone: # type: ignore[comparison-overlap] |
314 | | -self._headers["x-opaque-id"] =opaque_id |
315 | | -self._headers=resolve_auth_headers( |
316 | | -self._headers, |
317 | | -api_key=api_key, |
318 | | -basic_auth=basic_auth, |
319 | | -bearer_auth=bearer_auth, |
320 | | - ) |
| 323 | +self._base_client=BaseClient(_transport, headers=headers) |
321 | 324 |
|
322 | 325 | # namespaced clients for compatibility with API names |
323 | | -self.async_search=AsyncSearchClient(self) |
324 | | -self.autoscaling=AutoscalingClient(self) |
325 | | -self.cat=CatClient(self) |
326 | | -self.cluster=ClusterClient(self) |
327 | | -self.connector=ConnectorClient(self) |
328 | | -self.fleet=FleetClient(self) |
329 | | -self.features=FeaturesClient(self) |
330 | | -self.indices=IndicesClient(self) |
331 | | -self.inference=InferenceClient(self) |
332 | | -self.ingest=IngestClient(self) |
333 | | -self.nodes=NodesClient(self) |
334 | | -self.snapshot=SnapshotClient(self) |
335 | | -self.tasks=TasksClient(self) |
336 | | - |
337 | | -self.xpack=XPackClient(self) |
338 | | -self.ccr=CcrClient(self) |
339 | | -self.dangling_indices=DanglingIndicesClient(self) |
340 | | -self.enrich=EnrichClient(self) |
341 | | -self.eql=EqlClient(self) |
342 | | -self.esql=EsqlClient(self) |
343 | | -self.graph=GraphClient(self) |
344 | | -self.ilm=IlmClient(self) |
345 | | -self.license=LicenseClient(self) |
346 | | -self.logstash=LogstashClient(self) |
347 | | -self.migration=MigrationClient(self) |
348 | | -self.ml=MlClient(self) |
349 | | -self.monitoring=MonitoringClient(self) |
350 | | -self.query_rules=QueryRulesClient(self) |
351 | | -self.rollup=RollupClient(self) |
352 | | -self.search_application=SearchApplicationClient(self) |
353 | | -self.searchable_snapshots=SearchableSnapshotsClient(self) |
354 | | -self.security=SecurityClient(self) |
355 | | -self.slm=SlmClient(self) |
356 | | -self.simulate=SimulateClient(self) |
357 | | -self.shutdown=ShutdownClient(self) |
358 | | -self.sql=SqlClient(self) |
359 | | -self.ssl=SslClient(self) |
360 | | -self.synonyms=SynonymsClient(self) |
361 | | -self.text_structure=TextStructureClient(self) |
362 | | -self.transform=TransformClient(self) |
363 | | -self.watcher=WatcherClient(self) |
| 326 | +self.async_search=AsyncSearchClient(self._base_client) |
| 327 | +self.autoscaling=AutoscalingClient(self._base_client) |
| 328 | +self.cat=CatClient(self._base_client) |
| 329 | +self.cluster=ClusterClient(self._base_client) |
| 330 | +self.connector=ConnectorClient(self._base_client) |
| 331 | +self.fleet=FleetClient(self._base_client) |
| 332 | +self.features=FeaturesClient(self._base_client) |
| 333 | +self.indices=IndicesClient(self._base_client) |
| 334 | +self.inference=InferenceClient(self._base_client) |
| 335 | +self.ingest=IngestClient(self._base_client) |
| 336 | +self.nodes=NodesClient(self._base_client) |
| 337 | +self.snapshot=SnapshotClient(self._base_client) |
| 338 | +self.tasks=TasksClient(self._base_client) |
| 339 | + |
| 340 | +self.xpack=XPackClient(self._base_client) |
| 341 | +self.ccr=CcrClient(self._base_client) |
| 342 | +self.dangling_indices=DanglingIndicesClient(self._base_client) |
| 343 | +self.enrich=EnrichClient(self._base_client) |
| 344 | +self.eql=EqlClient(self._base_client) |
| 345 | +self.esql=EsqlClient(self._base_client) |
| 346 | +self.graph=GraphClient(self._base_client) |
| 347 | +self.ilm=IlmClient(self._base_client) |
| 348 | +self.license=LicenseClient(self._base_client) |
| 349 | +self.logstash=LogstashClient(self._base_client) |
| 350 | +self.migration=MigrationClient(self._base_client) |
| 351 | +self.ml=MlClient(self._base_client) |
| 352 | +self.monitoring=MonitoringClient(self._base_client) |
| 353 | +self.query_rules=QueryRulesClient(self._base_client) |
| 354 | +self.rollup=RollupClient(self._base_client) |
| 355 | +self.search_application=SearchApplicationClient(self._base_client) |
| 356 | +self.searchable_snapshots=SearchableSnapshotsClient(self._base_client) |
| 357 | +self.security=SecurityClient(self._base_client) |
| 358 | +self.slm=SlmClient(self._base_client) |
| 359 | +self.simulate=SimulateClient(self._base_client) |
| 360 | +self.shutdown=ShutdownClient(self._base_client) |
| 361 | +self.sql=SqlClient(self._base_client) |
| 362 | +self.ssl=SslClient(self._base_client) |
| 363 | +self.synonyms=SynonymsClient(self._base_client) |
| 364 | +self.text_structure=TextStructureClient(self._base_client) |
| 365 | +self.transform=TransformClient(self._base_client) |
| 366 | +self.watcher=WatcherClient(self._base_client) |
| 367 | + |
| 368 | +@property |
| 369 | +deftransport(self) ->AsyncTransport: |
| 370 | +returnself._base_client._transport |
| 371 | + |
| 372 | +asyncdefperform_request( |
| 373 | +self, |
| 374 | +method: str, |
| 375 | +path: str, |
| 376 | +*, |
| 377 | +params: t.Optional[t.Mapping[str, t.Any]] =None, |
| 378 | +headers: t.Optional[t.Mapping[str, str]] =None, |
| 379 | +body: t.Optional[t.Any] =None, |
| 380 | +endpoint_id: t.Optional[str] =None, |
| 381 | +path_parts: t.Optional[t.Mapping[str, t.Any]] =None, |
| 382 | + ) ->ApiResponse[t.Any]: |
| 383 | +withself._base_client._otel.span( |
| 384 | +method, |
| 385 | +endpoint_id=endpoint_id, |
| 386 | +path_parts=path_partsor{}, |
| 387 | + ) asotel_span: |
| 388 | +response=awaitself._base_client._perform_request( |
| 389 | +method, |
| 390 | +path, |
| 391 | +params=params, |
| 392 | +headers=headers, |
| 393 | +body=body, |
| 394 | +otel_span=otel_span, |
| 395 | + ) |
| 396 | +otel_span.set_elastic_cloud_metadata(response.meta.headers) |
| 397 | +returnresponse |
364 | 398 |
|
365 | 399 | def__repr__(self) ->str: |
366 | 400 | try: |
@@ -413,44 +447,44 @@ def options( |
413 | 447 | resolved_headers["x-opaque-id"] =resolved_opaque_id |
414 | 448 |
|
415 | 449 | ifresolved_headers: |
416 | | -new_headers=self._headers.copy() |
| 450 | +new_headers=self._base_client._headers.copy() |
417 | 451 | new_headers.update(resolved_headers) |
418 | | -client._headers=new_headers |
| 452 | +client._base_client._headers=new_headers |
419 | 453 | else: |
420 | | -client._headers=self._headers.copy() |
| 454 | +client._base_client._headers=self._headers.copy() |
421 | 455 |
|
422 | 456 | ifrequest_timeoutisnotDEFAULT: |
423 | | -client._request_timeout=request_timeout |
| 457 | +client._base_client._request_timeout=request_timeout |
424 | 458 | else: |
425 | | -client._request_timeout=self._request_timeout |
| 459 | +client._base_client._request_timeout=self._base_client._request_timeout |
426 | 460 |
|
427 | 461 | ifignore_statusisnotDEFAULT: |
428 | 462 | ifisinstance(ignore_status, int): |
429 | 463 | ignore_status= (ignore_status,) |
430 | | -client._ignore_status=ignore_status |
| 464 | +client._base_client._ignore_status=ignore_status |
431 | 465 | else: |
432 | | -client._ignore_status=self._ignore_status |
| 466 | +client._base_client._ignore_status=self._base_client._ignore_status |
433 | 467 |
|
434 | 468 | ifmax_retriesisnotDEFAULT: |
435 | 469 | ifnotisinstance(max_retries, int): |
436 | 470 | raiseTypeError("'max_retries' must be of type 'int'") |
437 | | -client._max_retries=max_retries |
| 471 | +client._base_client._max_retries=max_retries |
438 | 472 | else: |
439 | | -client._max_retries=self._max_retries |
| 473 | +client._base_client._max_retries=self._base_client._max_retries |
440 | 474 |
|
441 | 475 | ifretry_on_statusisnotDEFAULT: |
442 | 476 | ifisinstance(retry_on_status, int): |
443 | 477 | retry_on_status= (retry_on_status,) |
444 | | -client._retry_on_status=retry_on_status |
| 478 | +client._base_client._retry_on_status=retry_on_status |
445 | 479 | else: |
446 | | -client._retry_on_status=self._retry_on_status |
| 480 | +client._base_client._retry_on_status=self._base_client._retry_on_status |
447 | 481 |
|
448 | 482 | ifretry_on_timeoutisnotDEFAULT: |
449 | 483 | ifnotisinstance(retry_on_timeout, bool): |
450 | 484 | raiseTypeError("'retry_on_timeout' must be of type 'bool'") |
451 | | -client._retry_on_timeout=retry_on_timeout |
| 485 | +client._base_client._retry_on_timeout=retry_on_timeout |
452 | 486 | else: |
453 | | -client._retry_on_timeout=self._retry_on_timeout |
| 487 | +client._base_client._retry_on_timeout=self._base_client._retry_on_timeout |
454 | 488 |
|
455 | 489 | returnclient |
456 | 490 |
|
|
0 commit comments