From 58c7ce78097102d9c66d11f97506a25cd2fde4a4 Mon Sep 17 00:00:00 2001 From: Miriam Eid <93708060+miriam-eid@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:23:06 +0300 Subject: [PATCH] update api to 8.4 --- elasticsearch/_async/client/__init__.py | 4 ++ elasticsearch/_async/client/async_search.py | 4 ++ elasticsearch/_async/client/ml.py | 6 +++ elasticsearch/_async/client/security.py | 60 +++++++++++++++++++++ elasticsearch/_sync/client/__init__.py | 4 ++ elasticsearch/_sync/client/async_search.py | 4 ++ elasticsearch/_sync/client/ml.py | 6 +++ elasticsearch/_sync/client/security.py | 60 +++++++++++++++++++++ 8 files changed, 148 insertions(+) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index ef884d66c..fa9ca93ab 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -3409,6 +3409,7 @@ async def search( indices_boost: t.Optional[ t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]] ] = None, + knn: t.Optional[t.Mapping[str, t.Any]] = None, lenient: t.Optional[bool] = None, max_concurrent_shard_requests: t.Optional[int] = None, min_compatible_shard_node: t.Optional[str] = None, @@ -3538,6 +3539,7 @@ async def search( :param ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :param indices_boost: Boosts the _score of documents from specified indices. + :param knn: Defines the approximate kNN search to run. :param lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored :param max_concurrent_shard_requests: The number of concurrent shard requests @@ -3682,6 +3684,8 @@ async def search( __query["ignore_unavailable"] = ignore_unavailable if indices_boost is not None: __body["indices_boost"] = indices_boost + if knn is not None: + __body["knn"] = knn if lenient is not None: __query["lenient"] = lenient if max_concurrent_shard_requests is not None: diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index 7dc04e340..85cd99ffb 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -215,6 +215,7 @@ async def submit( ] = None, keep_alive: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, keep_on_completion: t.Optional[bool] = None, + knn: t.Optional[t.Mapping[str, t.Any]] = None, lenient: t.Optional[bool] = None, max_concurrent_shard_requests: t.Optional[int] = None, min_compatible_shard_node: t.Optional[str] = None, @@ -350,6 +351,7 @@ async def submit( :param keep_on_completion: Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + :param knn: Defines the approximate kNN search to run. :param lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored :param max_concurrent_shard_requests: The number of concurrent shard requests @@ -492,6 +494,8 @@ async def submit( __query["keep_alive"] = keep_alive if keep_on_completion is not None: __query["keep_on_completion"] = keep_on_completion + if knn is not None: + __body["knn"] = knn if lenient is not None: __query["lenient"] = lenient if max_concurrent_shard_requests is not None: diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 09a889984..95074fdb6 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -3671,6 +3671,7 @@ async def start_trained_model_deployment( self, *, model_id: str, + cache_size: t.Optional[t.Union[int, str]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -3692,6 +3693,9 @@ async def start_trained_model_deployment( :param model_id: The unique identifier of the trained model. Currently, only PyTorch models are supported. + :param cache_size: The inference cache size (in memory outside the JVM heap) + per node for the model. The default value is the same size as the `model_size_bytes`. + To disable the cache, `0b` can be provided. :param number_of_allocations: The number of model allocations on each node where the model is deployed. All allocations on a node share the same copy of the model in memory but use a separate set of threads to evaluate the model. @@ -3715,6 +3719,8 @@ async def start_trained_model_deployment( raise ValueError("Empty value passed for parameter 'model_id'") __path = f"/_ml/trained_models/{_quote(model_id)}/deployment/_start" __query: t.Dict[str, t.Any] = {} + if cache_size is not None: + __query["cache_size"] = cache_size if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 447b0ca41..b42ddca50 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -2502,6 +2502,66 @@ async def suggest_user_profiles( "POST", __path, params=__query, headers=__headers, body=__body ) + @_rewrite_parameters( + body_fields=True, + ) + async def update_api_key( + self, + *, + id: 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, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates attributes of an existing API key. + + ``_ + + :param id: The ID of the API key to update. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with _ are reserved for system usage. + :param role_descriptors: An array of role descriptors for this API key. This + parameter is optional. When it is not specified or is an empty array, then + the API key will have a point in time snapshot of permissions of the authenticated + user. If you supply role descriptors then the resultant permissions would + be an intersection of API keys permissions and authenticated user’s permissions + thereby limiting the access scope for API keys. The structure of role descriptor + is the same as the request for create role API. For more details, see create + or update roles API. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_security/api_key/{_quote(id)}" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if role_descriptors is not None: + __body["role_descriptors"] = role_descriptors + if not __body: + __body = None # type: ignore[assignment] + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self.perform_request( # type: ignore[return-value] + "PUT", __path, params=__query, headers=__headers, body=__body + ) + @_rewrite_parameters( body_fields=True, ) diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 0e75a998f..e65a709fe 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -3407,6 +3407,7 @@ def search( indices_boost: t.Optional[ t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]] ] = None, + knn: t.Optional[t.Mapping[str, t.Any]] = None, lenient: t.Optional[bool] = None, max_concurrent_shard_requests: t.Optional[int] = None, min_compatible_shard_node: t.Optional[str] = None, @@ -3536,6 +3537,7 @@ def search( :param ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :param indices_boost: Boosts the _score of documents from specified indices. + :param knn: Defines the approximate kNN search to run. :param lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored :param max_concurrent_shard_requests: The number of concurrent shard requests @@ -3680,6 +3682,8 @@ def search( __query["ignore_unavailable"] = ignore_unavailable if indices_boost is not None: __body["indices_boost"] = indices_boost + if knn is not None: + __body["knn"] = knn if lenient is not None: __query["lenient"] = lenient if max_concurrent_shard_requests is not None: diff --git a/elasticsearch/_sync/client/async_search.py b/elasticsearch/_sync/client/async_search.py index 7e7de0b66..c091ac230 100644 --- a/elasticsearch/_sync/client/async_search.py +++ b/elasticsearch/_sync/client/async_search.py @@ -215,6 +215,7 @@ def submit( ] = None, keep_alive: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, keep_on_completion: t.Optional[bool] = None, + knn: t.Optional[t.Mapping[str, t.Any]] = None, lenient: t.Optional[bool] = None, max_concurrent_shard_requests: t.Optional[int] = None, min_compatible_shard_node: t.Optional[str] = None, @@ -350,6 +351,7 @@ def submit( :param keep_on_completion: Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + :param knn: Defines the approximate kNN search to run. :param lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored :param max_concurrent_shard_requests: The number of concurrent shard requests @@ -492,6 +494,8 @@ def submit( __query["keep_alive"] = keep_alive if keep_on_completion is not None: __query["keep_on_completion"] = keep_on_completion + if knn is not None: + __body["knn"] = knn if lenient is not None: __query["lenient"] = lenient if max_concurrent_shard_requests is not None: diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index c30da0af2..3889e15fc 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -3671,6 +3671,7 @@ def start_trained_model_deployment( self, *, model_id: str, + cache_size: t.Optional[t.Union[int, str]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[ t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] @@ -3692,6 +3693,9 @@ def start_trained_model_deployment( :param model_id: The unique identifier of the trained model. Currently, only PyTorch models are supported. + :param cache_size: The inference cache size (in memory outside the JVM heap) + per node for the model. The default value is the same size as the `model_size_bytes`. + To disable the cache, `0b` can be provided. :param number_of_allocations: The number of model allocations on each node where the model is deployed. All allocations on a node share the same copy of the model in memory but use a separate set of threads to evaluate the model. @@ -3715,6 +3719,8 @@ def start_trained_model_deployment( raise ValueError("Empty value passed for parameter 'model_id'") __path = f"/_ml/trained_models/{_quote(model_id)}/deployment/_start" __query: t.Dict[str, t.Any] = {} + if cache_size is not None: + __query["cache_size"] = cache_size if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index 1834fe842..43eb53ed3 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -2502,6 +2502,66 @@ def suggest_user_profiles( "POST", __path, params=__query, headers=__headers, body=__body ) + @_rewrite_parameters( + body_fields=True, + ) + def update_api_key( + self, + *, + id: 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, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates attributes of an existing API key. + + ``_ + + :param id: The ID of the API key to update. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with _ are reserved for system usage. + :param role_descriptors: An array of role descriptors for this API key. This + parameter is optional. When it is not specified or is an empty array, then + the API key will have a point in time snapshot of permissions of the authenticated + user. If you supply role descriptors then the resultant permissions would + be an intersection of API keys permissions and authenticated user’s permissions + thereby limiting the access scope for API keys. The structure of role descriptor + is the same as the request for create role API. For more details, see create + or update roles API. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_security/api_key/{_quote(id)}" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if role_descriptors is not None: + __body["role_descriptors"] = role_descriptors + if not __body: + __body = None # type: ignore[assignment] + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self.perform_request( # type: ignore[return-value] + "PUT", __path, params=__query, headers=__headers, body=__body + ) + @_rewrite_parameters( body_fields=True, )