diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index c1f2c2265..0c595f30d 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -604,7 +604,7 @@ async def bulk( ] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -925,7 +925,7 @@ async def create( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1011,7 +1011,7 @@ async def delete( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1136,7 +1136,7 @@ async def delete_by_query( timeout: t.Optional[t.Union[int, str]] = None, version: t.Optional[bool] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -1205,6 +1205,17 @@ async def delete_by_query( __path = f"/{_quote(index)}/_delete_by_query" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if analyze_wildcard is not None: @@ -2127,7 +2138,7 @@ async def index( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -2981,7 +2992,7 @@ async def reindex( source: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -3540,6 +3551,17 @@ async def search( __path = "/_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: @@ -3785,6 +3807,17 @@ async def search_mvt( __path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggs is not None: __body["aggs"] = aggs if error_trace is not None: @@ -4289,7 +4322,7 @@ async def update( timeout: t.Optional[t.Union[int, str]] = None, upsert: t.Optional[t.Mapping[str, t.Any]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -4454,7 +4487,7 @@ async def update_by_query( version: t.Optional[bool] = None, version_type: t.Optional[bool] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -4528,6 +4561,17 @@ async def update_by_query( __path = f"/{_quote(index)}/_update_by_query" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if analyze_wildcard is not None: diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index dbaff3325..cc562c1d0 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -427,6 +427,17 @@ async def submit( __path = "/_async_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: diff --git a/elasticsearch/_async/client/ccr.py b/elasticsearch/_async/client/ccr.py index 909281706..fd1954273 100644 --- a/elasticsearch/_async/client/ccr.py +++ b/elasticsearch/_async/client/ccr.py @@ -86,7 +86,7 @@ async def follow( read_poll_timeout: t.Optional[t.Union[int, str]] = None, remote_cluster: t.Optional[str] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ diff --git a/elasticsearch/_async/client/cluster.py b/elasticsearch/_async/client/cluster.py index ef8012ea9..98f8671a4 100644 --- a/elasticsearch/_async/client/cluster.py +++ b/elasticsearch/_async/client/cluster.py @@ -360,7 +360,7 @@ async def health( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_events: t.Optional[ t.Union[ diff --git a/elasticsearch/_async/client/fleet.py b/elasticsearch/_async/client/fleet.py index 9c6d37305..d21b05182 100644 --- a/elasticsearch/_async/client/fleet.py +++ b/elasticsearch/_async/client/fleet.py @@ -489,6 +489,17 @@ async def search( __path = f"/{_quote(index)}/_fleet/_fleet_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index c7e3d583c..79905bccd 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -304,7 +304,7 @@ async def clone( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -389,7 +389,7 @@ async def close( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -458,7 +458,7 @@ async def create( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -794,20 +794,28 @@ async def delete_data_stream( async def delete_index_template( self, *, - name: str, + name: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] ] = None, human: t.Optional[bool] = None, + master_timeout: t.Optional[t.Union[int, str]] = None, pretty: t.Optional[bool] = None, + timeout: t.Optional[t.Union[int, str]] = None, ) -> ObjectApiResponse[t.Any]: """ Deletes an index template. ``_ - :param name: The name of the template + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'name'") @@ -819,8 +827,12 @@ async def delete_index_template( __query["filter_path"] = filter_path if human is not None: __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout __headers = {"accept": "application/json"} return await self.perform_request( # type: ignore[return-value] "DELETE", __path, params=__query, headers=__headers @@ -1236,7 +1248,7 @@ async def exists_template( async def field_usage_stats( self, *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, + index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], allow_no_indices: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, expand_wildcards: t.Optional[ @@ -1269,7 +1281,7 @@ async def field_usage_stats( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1301,6 +1313,8 @@ async def field_usage_stats( before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") __path = f"/{_quote(index)}/_field_usage_stats" __query: t.Dict[str, t.Any] = {} if allow_no_indices is not None: @@ -2172,7 +2186,7 @@ async def open( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3025,7 +3039,7 @@ async def rollover( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3269,7 +3283,7 @@ async def shrink( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3491,7 +3505,7 @@ async def split( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 7a344e8f5..c5be0d6b4 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -166,7 +166,7 @@ async def delete_calendar_job( self, *, calendar_id: str, - job_id: str, + job_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -1464,7 +1464,9 @@ async def get_datafeeds( async def get_filters( self, *, - filter_id: t.Optional[str] = None, + filter_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -2028,7 +2030,9 @@ async def get_trained_models( async def get_trained_models_stats( self, *, - model_id: t.Optional[str] = None, + model_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, allow_no_match: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index e2d2ff3ff..8f3b7bf4b 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -1848,6 +1848,17 @@ async def query_api_keys( __path = "/_security/_query/api_key" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_async/client/sql.py b/elasticsearch/_async/client/sql.py index 87f35fc5f..fc6b4b12f 100644 --- a/elasticsearch/_async/client/sql.py +++ b/elasticsearch/_async/client/sql.py @@ -199,11 +199,12 @@ async def get_async_status( @_rewrite_parameters( body_fields=True, - ignore_deprecated_options={"request_timeout"}, + ignore_deprecated_options={"params", "request_timeout"}, ) async def query( self, *, + catalog: t.Optional[str] = None, columnar: t.Optional[bool] = None, cursor: t.Optional[str] = None, error_trace: t.Optional[bool] = None, @@ -215,17 +216,36 @@ async def query( ] = None, format: t.Optional[str] = None, human: t.Optional[bool] = None, + index_using_frozen: t.Optional[bool] = None, + keep_alive: t.Optional[t.Union[int, str]] = None, + keep_on_completion: t.Optional[bool] = None, page_timeout: t.Optional[t.Union[int, str]] = None, + params: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, query: t.Optional[str] = None, request_timeout: t.Optional[t.Union[int, str]] = None, + runtime_mappings: t.Optional[ + t.Mapping[ + str, + t.Union[ + t.Mapping[str, t.Any], + t.Union[ + t.List[t.Mapping[str, t.Any]], + t.Tuple[t.Mapping[str, t.Any], ...], + ], + ], + ] + ] = None, time_zone: t.Optional[str] = None, + wait_for_completion_timeout: t.Optional[t.Union[int, str]] = None, ) -> ObjectApiResponse[t.Any]: """ Executes a SQL request ``_ + :param catalog: Default catalog (cluster) for queries. If unspecified, the queries + execute on the data in the local cluster only. :param columnar: :param cursor: :param fetch_size: The maximum number of rows (or entries) to return in one response @@ -235,15 +255,29 @@ async def query( in natural ascending order). :param filter: Optional Elasticsearch query DSL for additional filtering. :param format: a short version of the Accept header, e.g. json, yaml + :param index_using_frozen: If true, the search can run on frozen indices. Defaults + to false. + :param keep_alive: Retention period for an async or saved synchronous search. + :param keep_on_completion: If true, Elasticsearch stores synchronous searches + if you also specify the wait_for_completion_timeout parameter. If false, + Elasticsearch only stores async searches that don’t finish before the wait_for_completion_timeout. :param page_timeout: The timeout before a pagination request fails. + :param params: Values for parameters in the query. :param query: SQL query to execute :param request_timeout: The timeout before the request fails. + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. :param time_zone: Time-zone in ISO 8601 used for executing the query on the server. More information available here. + :param wait_for_completion_timeout: Period to wait for complete results. Defaults + to no timeout, meaning the request waits for complete search results. If + the search doesn’t finish within this period, the search becomes async. """ __path = "/_sql" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + if catalog is not None: + __body["catalog"] = catalog if columnar is not None: __body["columnar"] = columnar if cursor is not None: @@ -262,16 +296,28 @@ async def query( __query["format"] = format if human is not None: __query["human"] = human + if index_using_frozen is not None: + __body["index_using_frozen"] = index_using_frozen + if keep_alive is not None: + __body["keep_alive"] = keep_alive + if keep_on_completion is not None: + __body["keep_on_completion"] = keep_on_completion if page_timeout is not None: __body["page_timeout"] = page_timeout + if params is not None: + __body["params"] = params if pretty is not None: __query["pretty"] = pretty if query is not None: __body["query"] = query if request_timeout is not None: __body["request_timeout"] = request_timeout + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings if time_zone is not None: __body["time_zone"] = time_zone + if wait_for_completion_timeout is not None: + __body["wait_for_completion_timeout"] = wait_for_completion_timeout __headers = {"accept": "application/json", "content-type": "application/json"} return await self.perform_request( # type: ignore[return-value] "POST", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch/_async/client/transform.py b/elasticsearch/_async/client/transform.py index ac9563221..a8caf1bab 100644 --- a/elasticsearch/_async/client/transform.py +++ b/elasticsearch/_async/client/transform.py @@ -77,7 +77,9 @@ async def delete_transform( async def get_transform( self, *, - transform_id: t.Optional[str] = None, + transform_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, allow_no_match: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, exclude_generated: t.Optional[bool] = None, diff --git a/elasticsearch/_async/client/watcher.py b/elasticsearch/_async/client/watcher.py index bde4e21e1..364c4d9b9 100644 --- a/elasticsearch/_async/client/watcher.py +++ b/elasticsearch/_async/client/watcher.py @@ -443,6 +443,17 @@ async def query_watches( __path = "/_watcher/_query/watches" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index ff04507e3..d70e649c7 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -602,7 +602,7 @@ def bulk( ] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -923,7 +923,7 @@ def create( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1009,7 +1009,7 @@ def delete( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1134,7 +1134,7 @@ def delete_by_query( timeout: t.Optional[t.Union[int, str]] = None, version: t.Optional[bool] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -1203,6 +1203,17 @@ def delete_by_query( __path = f"/{_quote(index)}/_delete_by_query" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if analyze_wildcard is not None: @@ -2125,7 +2136,7 @@ def index( t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str] ] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -2979,7 +2990,7 @@ def reindex( source: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -3538,6 +3549,17 @@ def search( __path = "/_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: @@ -3783,6 +3805,17 @@ def search_mvt( __path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggs is not None: __body["aggs"] = aggs if error_trace is not None: @@ -4287,7 +4320,7 @@ def update( timeout: t.Optional[t.Union[int, str]] = None, upsert: t.Optional[t.Mapping[str, t.Any]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -4452,7 +4485,7 @@ def update_by_query( version: t.Optional[bool] = None, version_type: t.Optional[bool] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_completion: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: @@ -4526,6 +4559,17 @@ def update_by_query( __path = f"/{_quote(index)}/_update_by_query" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if analyze_wildcard is not None: diff --git a/elasticsearch/_sync/client/async_search.py b/elasticsearch/_sync/client/async_search.py index 6dd9c6d7a..ab3785de0 100644 --- a/elasticsearch/_sync/client/async_search.py +++ b/elasticsearch/_sync/client/async_search.py @@ -427,6 +427,17 @@ def submit( __path = "/_async_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: diff --git a/elasticsearch/_sync/client/ccr.py b/elasticsearch/_sync/client/ccr.py index bb740b943..5793018c2 100644 --- a/elasticsearch/_sync/client/ccr.py +++ b/elasticsearch/_sync/client/ccr.py @@ -86,7 +86,7 @@ def follow( read_poll_timeout: t.Optional[t.Union[int, str]] = None, remote_cluster: t.Optional[str] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ diff --git a/elasticsearch/_sync/client/cluster.py b/elasticsearch/_sync/client/cluster.py index 91a4e0213..07d2e620d 100644 --- a/elasticsearch/_sync/client/cluster.py +++ b/elasticsearch/_sync/client/cluster.py @@ -360,7 +360,7 @@ def health( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, wait_for_events: t.Optional[ t.Union[ diff --git a/elasticsearch/_sync/client/fleet.py b/elasticsearch/_sync/client/fleet.py index 141d79b2b..cadf5a4e1 100644 --- a/elasticsearch/_sync/client/fleet.py +++ b/elasticsearch/_sync/client/fleet.py @@ -489,6 +489,17 @@ def search( __path = f"/{_quote(index)}/_fleet/_fleet_search" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if aggregations is not None: __body["aggregations"] = aggregations if aggs is not None: diff --git a/elasticsearch/_sync/client/indices.py b/elasticsearch/_sync/client/indices.py index 4dfe793d1..b13a71484 100644 --- a/elasticsearch/_sync/client/indices.py +++ b/elasticsearch/_sync/client/indices.py @@ -304,7 +304,7 @@ def clone( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -389,7 +389,7 @@ def close( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -458,7 +458,7 @@ def create( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -794,20 +794,28 @@ def delete_data_stream( def delete_index_template( self, *, - name: str, + name: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] ] = None, human: t.Optional[bool] = None, + master_timeout: t.Optional[t.Union[int, str]] = None, pretty: t.Optional[bool] = None, + timeout: t.Optional[t.Union[int, str]] = None, ) -> ObjectApiResponse[t.Any]: """ Deletes an index template. ``_ - :param name: The name of the template + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'name'") @@ -819,8 +827,12 @@ def delete_index_template( __query["filter_path"] = filter_path if human is not None: __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout __headers = {"accept": "application/json"} return self.perform_request( # type: ignore[return-value] "DELETE", __path, params=__query, headers=__headers @@ -1236,7 +1248,7 @@ def exists_template( def field_usage_stats( self, *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, + index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], allow_no_indices: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, expand_wildcards: t.Optional[ @@ -1269,7 +1281,7 @@ def field_usage_stats( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -1301,6 +1313,8 @@ def field_usage_stats( before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") __path = f"/{_quote(index)}/_field_usage_stats" __query: t.Dict[str, t.Any] = {} if allow_no_indices is not None: @@ -2172,7 +2186,7 @@ def open( pretty: t.Optional[bool] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3025,7 +3039,7 @@ def rollover( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3269,7 +3283,7 @@ def shrink( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -3491,7 +3505,7 @@ def split( settings: t.Optional[t.Mapping[str, t.Any]] = None, timeout: t.Optional[t.Union[int, str]] = None, wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all']", str]] + t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] ] = None, ) -> ObjectApiResponse[t.Any]: """ diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index 808ad4dee..5cc02a745 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -166,7 +166,7 @@ def delete_calendar_job( self, *, calendar_id: str, - job_id: str, + job_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -1464,7 +1464,9 @@ def get_datafeeds( def get_filters( self, *, - filter_id: t.Optional[str] = None, + filter_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -2028,7 +2030,9 @@ def get_trained_models( def get_trained_models_stats( self, *, - model_id: t.Optional[str] = None, + model_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, allow_no_match: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index 2e29de082..4305d34c3 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -1848,6 +1848,17 @@ def query_api_keys( __path = "/_security/_query/api_key" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_sync/client/sql.py b/elasticsearch/_sync/client/sql.py index 9e72ed190..6f0205bc2 100644 --- a/elasticsearch/_sync/client/sql.py +++ b/elasticsearch/_sync/client/sql.py @@ -199,11 +199,12 @@ def get_async_status( @_rewrite_parameters( body_fields=True, - ignore_deprecated_options={"request_timeout"}, + ignore_deprecated_options={"params", "request_timeout"}, ) def query( self, *, + catalog: t.Optional[str] = None, columnar: t.Optional[bool] = None, cursor: t.Optional[str] = None, error_trace: t.Optional[bool] = None, @@ -215,17 +216,36 @@ def query( ] = None, format: t.Optional[str] = None, human: t.Optional[bool] = None, + index_using_frozen: t.Optional[bool] = None, + keep_alive: t.Optional[t.Union[int, str]] = None, + keep_on_completion: t.Optional[bool] = None, page_timeout: t.Optional[t.Union[int, str]] = None, + params: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, query: t.Optional[str] = None, request_timeout: t.Optional[t.Union[int, str]] = None, + runtime_mappings: t.Optional[ + t.Mapping[ + str, + t.Union[ + t.Mapping[str, t.Any], + t.Union[ + t.List[t.Mapping[str, t.Any]], + t.Tuple[t.Mapping[str, t.Any], ...], + ], + ], + ] + ] = None, time_zone: t.Optional[str] = None, + wait_for_completion_timeout: t.Optional[t.Union[int, str]] = None, ) -> ObjectApiResponse[t.Any]: """ Executes a SQL request ``_ + :param catalog: Default catalog (cluster) for queries. If unspecified, the queries + execute on the data in the local cluster only. :param columnar: :param cursor: :param fetch_size: The maximum number of rows (or entries) to return in one response @@ -235,15 +255,29 @@ def query( in natural ascending order). :param filter: Optional Elasticsearch query DSL for additional filtering. :param format: a short version of the Accept header, e.g. json, yaml + :param index_using_frozen: If true, the search can run on frozen indices. Defaults + to false. + :param keep_alive: Retention period for an async or saved synchronous search. + :param keep_on_completion: If true, Elasticsearch stores synchronous searches + if you also specify the wait_for_completion_timeout parameter. If false, + Elasticsearch only stores async searches that don’t finish before the wait_for_completion_timeout. :param page_timeout: The timeout before a pagination request fails. + :param params: Values for parameters in the query. :param query: SQL query to execute :param request_timeout: The timeout before the request fails. + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. :param time_zone: Time-zone in ISO 8601 used for executing the query on the server. More information available here. + :param wait_for_completion_timeout: Period to wait for complete results. Defaults + to no timeout, meaning the request waits for complete search results. If + the search doesn’t finish within this period, the search becomes async. """ __path = "/_sql" __body: t.Dict[str, t.Any] = {} __query: t.Dict[str, t.Any] = {} + if catalog is not None: + __body["catalog"] = catalog if columnar is not None: __body["columnar"] = columnar if cursor is not None: @@ -262,16 +296,28 @@ def query( __query["format"] = format if human is not None: __query["human"] = human + if index_using_frozen is not None: + __body["index_using_frozen"] = index_using_frozen + if keep_alive is not None: + __body["keep_alive"] = keep_alive + if keep_on_completion is not None: + __body["keep_on_completion"] = keep_on_completion if page_timeout is not None: __body["page_timeout"] = page_timeout + if params is not None: + __body["params"] = params if pretty is not None: __query["pretty"] = pretty if query is not None: __body["query"] = query if request_timeout is not None: __body["request_timeout"] = request_timeout + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings if time_zone is not None: __body["time_zone"] = time_zone + if wait_for_completion_timeout is not None: + __body["wait_for_completion_timeout"] = wait_for_completion_timeout __headers = {"accept": "application/json", "content-type": "application/json"} return self.perform_request( # type: ignore[return-value] "POST", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch/_sync/client/transform.py b/elasticsearch/_sync/client/transform.py index 51046b8ef..79a7537aa 100644 --- a/elasticsearch/_sync/client/transform.py +++ b/elasticsearch/_sync/client/transform.py @@ -77,7 +77,9 @@ def delete_transform( def get_transform( self, *, - transform_id: t.Optional[str] = None, + transform_id: t.Optional[ + t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] + ] = None, allow_no_match: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, exclude_generated: t.Optional[bool] = None, diff --git a/elasticsearch/_sync/client/watcher.py b/elasticsearch/_sync/client/watcher.py index 11b09356d..837d651f3 100644 --- a/elasticsearch/_sync/client/watcher.py +++ b/elasticsearch/_sync/client/watcher.py @@ -443,6 +443,17 @@ def query_watches( __path = "/_watcher/_query/watches" __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = {} + # The 'sort' parameter with a colon can't be encoded to the body. + if sort is not None and ( + (isinstance(sort, str) and ":" in sort) + or ( + isinstance(sort, (list, tuple)) + and all(isinstance(_x, str) for _x in sort) + and any(":" in _x for _x in sort) + ) + ): + __query["sort"] = sort + sort = None if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/test_elasticsearch/test_client/test_overrides.py b/test_elasticsearch/test_client/test_overrides.py index c2897dc01..fd8ad9f65 100644 --- a/test_elasticsearch/test_client/test_overrides.py +++ b/test_elasticsearch/test_client/test_overrides.py @@ -71,3 +71,40 @@ def test_from_in_search(self, param_name): self.client.search(index="i", **{param_name: 10}) calls = self.assert_url_called("POST", "/i/_search") assert calls[0]["body"] == {"from": 10} + + def test_sort_in_search(self): + self.client.search(index="i", sort="@timestamp:asc") + calls = self.assert_url_called("POST", "/i/_search?sort=%40timestamp%3Aasc") + assert calls[0]["body"] is None + + self.client.search(index="i", sort=["@timestamp:asc", "field"]) + calls = self.assert_url_called( + "POST", "/i/_search?sort=%40timestamp%3Aasc,field" + ) + assert calls[0]["body"] is None + + self.client.search(index="i", sort=("field", "@timestamp:asc")) + calls = self.assert_url_called( + "POST", "/i/_search?sort=field,%40timestamp%3Aasc" + ) + assert calls[0]["body"] is None + + self.client.search(index="i", sort=("field", "@timestamp")) + calls = self.assert_url_called("POST", "/i/_search") + assert calls[-1]["body"] == {"sort": ("field", "@timestamp")} + + self.client.search(index="i2", sort=["@timestamp", "field"]) + calls = self.assert_url_called("POST", "/i2/_search") + assert calls[-1]["body"] == {"sort": ["@timestamp", "field"]} + + self.client.search( + index="i3", sort=("field", "@timestamp:asc", {"field": "desc"}) + ) + calls = self.assert_url_called("POST", "/i3/_search") + assert calls[-1]["body"] == { + "sort": ("field", "@timestamp:asc", {"field": "desc"}) + } + + self.client.search(index="i4", sort=["@timestamp:asc", {"field": "desc"}]) + calls = self.assert_url_called("POST", "/i4/_search") + assert calls[-1]["body"] == {"sort": ["@timestamp:asc", {"field": "desc"}]}