From 0256cf11a7f38bfb7a7e52fb81d543ee6cb5c580 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Tue, 26 Mar 2024 06:06:48 +0000 Subject: [PATCH 1/2] Auto-generated API code --- elasticsearch/_async/client/inference.py | 12 +++----- elasticsearch/_async/client/security.py | 39 +++++++++++++++++++++--- elasticsearch/_sync/client/__init__.py | 4 +-- elasticsearch/_sync/client/inference.py | 12 +++----- elasticsearch/_sync/client/security.py | 39 +++++++++++++++++++++--- 5 files changed, 78 insertions(+), 28 deletions(-) diff --git a/elasticsearch/_async/client/inference.py b/elasticsearch/_async/client/inference.py index 6a08345fe..ac0bb7908 100644 --- a/elasticsearch/_async/client/inference.py +++ b/elasticsearch/_async/client/inference.py @@ -214,14 +214,14 @@ async def put_model( self, *, inference_id: str, + model_config: t.Optional[t.Mapping[str, t.Any]] = None, + body: t.Optional[t.Mapping[str, t.Any]] = None, task_type: t.Optional[ t.Union["t.Literal['sparse_embedding', 'text_embedding']", str] ] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, - model_config: t.Optional[t.Mapping[str, t.Any]] = None, - body: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -230,8 +230,8 @@ async def put_model( ``_ :param inference_id: The inference Id - :param task_type: The task type :param model_config: + :param task_type: The task type """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") @@ -263,11 +263,7 @@ async def put_model( if pretty is not None: __query["pretty"] = pretty __body = model_config if model_config is not None else body - if not __body: - __body = None - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" + __headers = {"accept": "application/json", "content-type": "application/json"} return await self.perform_request( # type: ignore[return-value] "PUT", __path, diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 523ed0d89..71ca4e4c3 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -2343,12 +2343,22 @@ async def put_user( ) @_rewrite_parameters( - body_fields=("from_", "query", "search_after", "size", "sort"), + body_fields=( + "aggregations", + "aggs", + "from_", + "query", + "search_after", + "size", + "sort", + ), parameter_aliases={"from": "from_"}, ) async def query_api_keys( self, *, + aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, from_: t.Optional[int] = None, @@ -2373,13 +2383,28 @@ async def query_api_keys( ``_ + :param aggregations: Any aggregations to run over the corpus of returned API + keys. Aggregations and queries work together. Aggregations are computed only + on the API keys that match the query. This supports only a subset of aggregation + types, namely: `terms`, `range`, `date_range`, `missing`, `cardinality`, + `value_count`, `composite`, `filter`, and `filters`. Additionally, aggregations + only run over the same subset of fields that query works with. + :param aggs: Any aggregations to run over the corpus of returned API keys. Aggregations + and queries work together. Aggregations are computed only on the API keys + that match the query. This supports only a subset of aggregation types, namely: + `terms`, `range`, `date_range`, `missing`, `cardinality`, `value_count`, + `composite`, `filter`, and `filters`. Additionally, aggregations only run + over the same subset of fields that query works with. :param from_: Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the `search_after` parameter. - :param query: A query to filter which API keys to return. The query supports - a subset of query types, including `match_all`, `bool`, `term`, `terms`, - `ids`, `prefix`, `wildcard`, and `range`. You can query all public information - associated with an API key. + :param query: A query to filter which API keys to return. If the query parameter + is missing, it is equivalent to a `match_all` query. The query supports a + subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`, + `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`. + You can query the following public information associated with an API key: + `id`, `type`, `name`, `creation`, `expiration`, `invalidated`, `invalidation`, + `username`, `realm`, and `metadata`. :param search_after: Search after definition :param size: The number of hits to return. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through @@ -2417,6 +2442,10 @@ async def query_api_keys( if with_limited_by is not None: __query["with_limited_by"] = with_limited_by if not __body: + if aggregations is not None: + __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if from_ is not None: __body["from"] = from_ if query is not None: diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index d342466b8..d0b710367 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -122,12 +122,12 @@ class Elasticsearch(BaseClient): # Set 'api_key' on the constructor client = Elasticsearch( "http://localhost:9200", - api_key="api_key", + api_key=("id", "api_key") ) client.search(...) # Set 'api_key' per request - client.options(api_key="api_key").search(...) + client.options(api_key=("id", "api_key")).search(...) """ def __init__( diff --git a/elasticsearch/_sync/client/inference.py b/elasticsearch/_sync/client/inference.py index 361bcc405..8490cbd9e 100644 --- a/elasticsearch/_sync/client/inference.py +++ b/elasticsearch/_sync/client/inference.py @@ -214,14 +214,14 @@ def put_model( self, *, inference_id: str, + model_config: t.Optional[t.Mapping[str, t.Any]] = None, + body: t.Optional[t.Mapping[str, t.Any]] = None, task_type: t.Optional[ t.Union["t.Literal['sparse_embedding', 'text_embedding']", str] ] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, - model_config: t.Optional[t.Mapping[str, t.Any]] = None, - body: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -230,8 +230,8 @@ def put_model( ``_ :param inference_id: The inference Id - :param task_type: The task type :param model_config: + :param task_type: The task type """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") @@ -263,11 +263,7 @@ def put_model( if pretty is not None: __query["pretty"] = pretty __body = model_config if model_config is not None else body - if not __body: - __body = None - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" + __headers = {"accept": "application/json", "content-type": "application/json"} return self.perform_request( # type: ignore[return-value] "PUT", __path, diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index 6d744981f..3f0f021d4 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -2343,12 +2343,22 @@ def put_user( ) @_rewrite_parameters( - body_fields=("from_", "query", "search_after", "size", "sort"), + body_fields=( + "aggregations", + "aggs", + "from_", + "query", + "search_after", + "size", + "sort", + ), parameter_aliases={"from": "from_"}, ) def query_api_keys( self, *, + aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, from_: t.Optional[int] = None, @@ -2373,13 +2383,28 @@ def query_api_keys( ``_ + :param aggregations: Any aggregations to run over the corpus of returned API + keys. Aggregations and queries work together. Aggregations are computed only + on the API keys that match the query. This supports only a subset of aggregation + types, namely: `terms`, `range`, `date_range`, `missing`, `cardinality`, + `value_count`, `composite`, `filter`, and `filters`. Additionally, aggregations + only run over the same subset of fields that query works with. + :param aggs: Any aggregations to run over the corpus of returned API keys. Aggregations + and queries work together. Aggregations are computed only on the API keys + that match the query. This supports only a subset of aggregation types, namely: + `terms`, `range`, `date_range`, `missing`, `cardinality`, `value_count`, + `composite`, `filter`, and `filters`. Additionally, aggregations only run + over the same subset of fields that query works with. :param from_: Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the `search_after` parameter. - :param query: A query to filter which API keys to return. The query supports - a subset of query types, including `match_all`, `bool`, `term`, `terms`, - `ids`, `prefix`, `wildcard`, and `range`. You can query all public information - associated with an API key. + :param query: A query to filter which API keys to return. If the query parameter + is missing, it is equivalent to a `match_all` query. The query supports a + subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`, + `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`. + You can query the following public information associated with an API key: + `id`, `type`, `name`, `creation`, `expiration`, `invalidated`, `invalidation`, + `username`, `realm`, and `metadata`. :param search_after: Search after definition :param size: The number of hits to return. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through @@ -2417,6 +2442,10 @@ def query_api_keys( if with_limited_by is not None: __query["with_limited_by"] = with_limited_by if not __body: + if aggregations is not None: + __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if from_ is not None: __body["from"] = from_ if query is not None: From dcabc1034604ae035dc904ad958aea49a01a6e7f Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 26 Mar 2024 17:56:02 +0400 Subject: [PATCH 2/2] Restore api_key change --- elasticsearch/_sync/client/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index d0b710367..d342466b8 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -122,12 +122,12 @@ class Elasticsearch(BaseClient): # Set 'api_key' on the constructor client = Elasticsearch( "http://localhost:9200", - api_key=("id", "api_key") + api_key="api_key", ) client.search(...) # Set 'api_key' per request - client.options(api_key=("id", "api_key")).search(...) + client.options(api_key="api_key").search(...) """ def __init__(