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
18import logging
19from typing import (
20    Any,
21    AsyncGenerator,
22    AsyncIterable,
23    Callable,
24    Collection,
25    Dict,
26    Iterable,
27    List,
28    Mapping,
29    Optional,
30    Tuple,
31    TypeVar,
32    Union,
33)
34
35from ..serializer import Serializer
36from .client import AsyncElasticsearch
37
38logger: logging.Logger
39
40T = TypeVar("T")
41
42def _chunk_actions(
43    actions: Any, chunk_size: int, max_chunk_bytes: int, serializer: Serializer
44) -> AsyncGenerator[Any, None]: ...
45def _process_bulk_chunk(
46    client: AsyncElasticsearch,
47    bulk_actions: Any,
48    bulk_data: Any,
49    raise_on_exception: bool = ...,
50    raise_on_error: bool = ...,
51    ignore_status: Optional[Union[int, Collection[int]]] = ...,
52    *args: Any,
53    **kwargs: Any
54) -> AsyncGenerator[Tuple[bool, Any], None]: ...
55def aiter(x: Union[Iterable[T], AsyncIterable[T]]) -> AsyncGenerator[T, None]: ...
56def azip(
57    *iterables: Union[Iterable[T], AsyncIterable[T]]
58) -> AsyncGenerator[Tuple[T, ...], None]: ...
59def async_streaming_bulk(
60    client: AsyncElasticsearch,
61    actions: Union[Iterable[Any], AsyncIterable[Any]],
62    chunk_size: int = ...,
63    max_chunk_bytes: int = ...,
64    raise_on_error: bool = ...,
65    expand_action_callback: Callable[[Any], Tuple[Dict[str, Any], Optional[Any]]] = ...,
66    raise_on_exception: bool = ...,
67    max_retries: int = ...,
68    initial_backoff: Union[float, int] = ...,
69    max_backoff: Union[float, int] = ...,
70    yield_ok: bool = ...,
71    ignore_status: Optional[Union[int, Collection[int]]] = ...,
72    *args: Any,
73    **kwargs: Any
74) -> AsyncGenerator[Tuple[bool, Any], None]: ...
75async def async_bulk(
76    client: AsyncElasticsearch,
77    actions: Union[Iterable[Any], AsyncIterable[Any]],
78    stats_only: bool = ...,
79    ignore_status: Optional[Union[int, Collection[int]]] = ...,
80    *args: Any,
81    **kwargs: Any
82) -> Tuple[int, Union[int, List[Any]]]: ...
83def async_scan(
84    client: AsyncElasticsearch,
85    query: Optional[Any] = ...,
86    scroll: str = ...,
87    raise_on_error: bool = ...,
88    preserve_order: bool = ...,
89    size: int = ...,
90    request_timeout: Optional[Union[float, int]] = ...,
91    clear_scroll: bool = ...,
92    scroll_kwargs: Optional[Mapping[str, Any]] = ...,
93    **kwargs: Any
94) -> AsyncGenerator[int, None]: ...
95async def async_reindex(
96    client: AsyncElasticsearch,
97    source_index: Union[str, Collection[str]],
98    target_index: str,
99    query: Any = ...,
100    target_client: Optional[AsyncElasticsearch] = ...,
101    chunk_size: int = ...,
102    scroll: str = ...,
103    op_type: str = ...,
104    scan_kwargs: Optional[Mapping[str, Any]] = ...,
105    bulk_kwargs: Optional[Mapping[str, Any]] = ...,
106) -> Tuple[int, Union[int, List[Any]]]: ...
107