| 
87 | 87 |     _rewrite_parameters,  | 
88 | 88 |     _stability_warning,  | 
89 | 89 |     client_node_configs,  | 
 | 90 | +    is_requests_http_auth,  | 
 | 91 | +    is_requests_node_class,  | 
90 | 92 | )  | 
91 | 93 | from .watcher import WatcherClient  | 
92 | 94 | from .xpack import XPackClient  | 
@@ -178,6 +180,7 @@ def __init__(  | 
178 | 180 |             t.Callable[[t.Dict[str, t.Any], NodeConfig], t.Optional[NodeConfig]]  | 
179 | 181 |         ] = None,  | 
180 | 182 |         meta_header: t.Union[DefaultType, bool] = DEFAULT,  | 
 | 183 | +        http_auth: t.Union[DefaultType, t.Any] = DEFAULT,  | 
181 | 184 |         # Internal use only  | 
182 | 185 |         _transport: t.Optional[AsyncTransport] = None,  | 
183 | 186 |     ) -> None:  | 
@@ -225,9 +228,26 @@ def __init__(  | 
225 | 228 |             sniff_callback = default_sniff_callback  | 
226 | 229 | 
 
  | 
227 | 230 |         if _transport is None:  | 
 | 231 | +            requests_session_auth = None  | 
 | 232 | +            if http_auth is not None and http_auth is not DEFAULT:  | 
 | 233 | +                if is_requests_http_auth(http_auth):  | 
 | 234 | +                    # If we're using custom requests authentication  | 
 | 235 | +                    # then we need to alert the user that they also  | 
 | 236 | +                    # need to use 'node_class=requests'.  | 
 | 237 | +                    if not is_requests_node_class(node_class):  | 
 | 238 | +                        raise ValueError(  | 
 | 239 | +                            "Using a custom 'requests.auth.AuthBase' class for "  | 
 | 240 | +                            "'http_auth' must be used with node_class='requests'"  | 
 | 241 | +                        )  | 
 | 242 | + | 
 | 243 | +                    # Reset 'http_auth' to DEFAULT so it's not consumed below.  | 
 | 244 | +                    requests_session_auth = http_auth  | 
 | 245 | +                    http_auth = DEFAULT  | 
 | 246 | + | 
228 | 247 |             node_configs = client_node_configs(  | 
229 | 248 |                 hosts,  | 
230 | 249 |                 cloud_id=cloud_id,  | 
 | 250 | +                requests_session_auth=requests_session_auth,  | 
231 | 251 |                 connections_per_node=connections_per_node,  | 
232 | 252 |                 http_compress=http_compress,  | 
233 | 253 |                 verify_certs=verify_certs,  | 
@@ -314,6 +334,7 @@ def __init__(  | 
314 | 334 |             self._headers["x-opaque-id"] = opaque_id  | 
315 | 335 |         self._headers = resolve_auth_headers(  | 
316 | 336 |             self._headers,  | 
 | 337 | +            http_auth=http_auth,  | 
317 | 338 |             api_key=api_key,  | 
318 | 339 |             basic_auth=basic_auth,  | 
319 | 340 |             bearer_auth=bearer_auth,  | 
@@ -1468,7 +1489,7 @@ async def delete_by_query(  | 
1468 | 1489 |             If the request can target data streams, this argument determines whether  | 
1469 | 1490 |             wildcard expressions match hidden data streams. It supports comma-separated  | 
1470 | 1491 |             values, such as `open,hidden`.  | 
1471 |  | -        :param from_: Starting offset (default: 0)  | 
 | 1492 | +        :param from_: Skips the specified number of documents.  | 
1472 | 1493 |         :param ignore_unavailable: If `false`, the request returns an error if it targets  | 
1473 | 1494 |             a missing or closed index.  | 
1474 | 1495 |         :param lenient: If `true`, format-based query failures (such as providing text  | 
@@ -3307,7 +3328,8 @@ async def msearch(  | 
3307 | 3328 |             computationally expensive named queries on a large number of hits may add  | 
3308 | 3329 |             significant overhead.  | 
3309 | 3330 |         :param max_concurrent_searches: Maximum number of concurrent searches the multi  | 
3310 |  | -            search API can execute.  | 
 | 3331 | +            search API can execute. Defaults to `max(1, (# of data nodes * min(search  | 
 | 3332 | +            thread pool size, 10)))`.  | 
3311 | 3333 |         :param max_concurrent_shard_requests: Maximum number of concurrent shard requests  | 
3312 | 3334 |             that each sub-search request executes per node.  | 
3313 | 3335 |         :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter  | 
@@ -3635,6 +3657,7 @@ async def open_point_in_time(  | 
3635 | 3657 |         human: t.Optional[bool] = None,  | 
3636 | 3658 |         ignore_unavailable: t.Optional[bool] = None,  | 
3637 | 3659 |         index_filter: t.Optional[t.Mapping[str, t.Any]] = None,  | 
 | 3660 | +        max_concurrent_shard_requests: t.Optional[int] = None,  | 
3638 | 3661 |         preference: t.Optional[str] = None,  | 
3639 | 3662 |         pretty: t.Optional[bool] = None,  | 
3640 | 3663 |         routing: t.Optional[str] = None,  | 
@@ -3690,6 +3713,8 @@ async def open_point_in_time(  | 
3690 | 3713 |             a missing or closed index.  | 
3691 | 3714 |         :param index_filter: Filter indices if the provided query rewrites to `match_none`  | 
3692 | 3715 |             on every shard.  | 
 | 3716 | +        :param max_concurrent_shard_requests: Maximum number of concurrent shard requests  | 
 | 3717 | +            that each sub-search request executes per node.  | 
3693 | 3718 |         :param preference: The node or shard the operation should be performed on. By  | 
3694 | 3719 |             default, it is random.  | 
3695 | 3720 |         :param routing: A custom value that is used to route operations to a specific  | 
@@ -3717,6 +3742,8 @@ async def open_point_in_time(  | 
3717 | 3742 |             __query["human"] = human  | 
3718 | 3743 |         if ignore_unavailable is not None:  | 
3719 | 3744 |             __query["ignore_unavailable"] = ignore_unavailable  | 
 | 3745 | +        if max_concurrent_shard_requests is not None:  | 
 | 3746 | +            __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests  | 
3720 | 3747 |         if preference is not None:  | 
3721 | 3748 |             __query["preference"] = preference  | 
3722 | 3749 |         if pretty is not None:  | 
@@ -4257,7 +4284,7 @@ async def render_search_template(  | 
4257 | 4284 |         human: t.Optional[bool] = None,  | 
4258 | 4285 |         params: t.Optional[t.Mapping[str, t.Any]] = None,  | 
4259 | 4286 |         pretty: t.Optional[bool] = None,  | 
4260 |  | -        source: t.Optional[str] = None,  | 
 | 4287 | +        source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,  | 
4261 | 4288 |         body: t.Optional[t.Dict[str, t.Any]] = None,  | 
4262 | 4289 |     ) -> ObjectApiResponse[t.Any]:  | 
4263 | 4290 |         """  | 
@@ -4718,7 +4745,8 @@ async def search(  | 
4718 | 4745 |             limit the impact of the search on the cluster in order to limit the number  | 
4719 | 4746 |             of concurrent shard requests.  | 
4720 | 4747 |         :param min_score: The minimum `_score` for matching documents. Documents with  | 
4721 |  | -            a lower `_score` are not included in the search results.  | 
 | 4748 | +            a lower `_score` are not included in search results and results collected  | 
 | 4749 | +            by aggregations.  | 
4722 | 4750 |         :param pit: Limit the search to a point in time (PIT). If you provide a PIT,  | 
4723 | 4751 |             you cannot specify an `<index>` in the request path.  | 
4724 | 4752 |         :param post_filter: Use the `post_filter` parameter to filter search results.  | 
@@ -5661,7 +5689,7 @@ async def search_template(  | 
5661 | 5689 |         search_type: t.Optional[  | 
5662 | 5690 |             t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]  | 
5663 | 5691 |         ] = None,  | 
5664 |  | -        source: t.Optional[str] = None,  | 
 | 5692 | +        source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,  | 
5665 | 5693 |         typed_keys: t.Optional[bool] = None,  | 
5666 | 5694 |         body: t.Optional[t.Dict[str, t.Any]] = None,  | 
5667 | 5695 |     ) -> ObjectApiResponse[t.Any]:  | 
@@ -6399,7 +6427,7 @@ async def update_by_query(  | 
6399 | 6427 |             wildcard expressions match hidden data streams. It supports comma-separated  | 
6400 | 6428 |             values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,  | 
6401 | 6429 |             `hidden`, `none`.  | 
6402 |  | -        :param from_: Starting offset (default: 0)  | 
 | 6430 | +        :param from_: Skips the specified number of documents.  | 
6403 | 6431 |         :param ignore_unavailable: If `false`, the request returns an error if it targets  | 
6404 | 6432 |             a missing or closed index.  | 
6405 | 6433 |         :param lenient: If `true`, format-based query failures (such as providing text  | 
 | 
0 commit comments