Skip to content

Commit 58c7ce7

Browse files
authored
update api to 8.4
1 parent 54cd023 commit 58c7ce7

File tree

8 files changed

+148
-0
lines changed

8 files changed

+148
-0
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,6 +3409,7 @@ async def search(
34093409
indices_boost: t.Optional[
34103410
t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]]
34113411
] = None,
3412+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
34123413
lenient: t.Optional[bool] = None,
34133414
max_concurrent_shard_requests: t.Optional[int] = None,
34143415
min_compatible_shard_node: t.Optional[str] = None,
@@ -3538,6 +3539,7 @@ async def search(
35383539
:param ignore_unavailable: Whether specified concrete indices should be ignored
35393540
when unavailable (missing or closed)
35403541
:param indices_boost: Boosts the _score of documents from specified indices.
3542+
:param knn: Defines the approximate kNN search to run.
35413543
:param lenient: Specify whether format-based query failures (such as providing
35423544
text to a numeric field) should be ignored
35433545
:param max_concurrent_shard_requests: The number of concurrent shard requests
@@ -3682,6 +3684,8 @@ async def search(
36823684
__query["ignore_unavailable"] = ignore_unavailable
36833685
if indices_boost is not None:
36843686
__body["indices_boost"] = indices_boost
3687+
if knn is not None:
3688+
__body["knn"] = knn
36853689
if lenient is not None:
36863690
__query["lenient"] = lenient
36873691
if max_concurrent_shard_requests is not None:

elasticsearch/_async/client/async_search.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ async def submit(
215215
] = None,
216216
keep_alive: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
217217
keep_on_completion: t.Optional[bool] = None,
218+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
218219
lenient: t.Optional[bool] = None,
219220
max_concurrent_shard_requests: t.Optional[int] = None,
220221
min_compatible_shard_node: t.Optional[str] = None,
@@ -350,6 +351,7 @@ async def submit(
350351
:param keep_on_completion: Control whether the response should be stored in the
351352
cluster if it completed within the provided [wait_for_completion] time (default:
352353
false)
354+
:param knn: Defines the approximate kNN search to run.
353355
:param lenient: Specify whether format-based query failures (such as providing
354356
text to a numeric field) should be ignored
355357
:param max_concurrent_shard_requests: The number of concurrent shard requests
@@ -492,6 +494,8 @@ async def submit(
492494
__query["keep_alive"] = keep_alive
493495
if keep_on_completion is not None:
494496
__query["keep_on_completion"] = keep_on_completion
497+
if knn is not None:
498+
__body["knn"] = knn
495499
if lenient is not None:
496500
__query["lenient"] = lenient
497501
if max_concurrent_shard_requests is not None:

elasticsearch/_async/client/ml.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,6 +3671,7 @@ async def start_trained_model_deployment(
36713671
self,
36723672
*,
36733673
model_id: str,
3674+
cache_size: t.Optional[t.Union[int, str]] = None,
36743675
error_trace: t.Optional[bool] = None,
36753676
filter_path: t.Optional[
36763677
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
@@ -3692,6 +3693,9 @@ async def start_trained_model_deployment(
36923693
36933694
:param model_id: The unique identifier of the trained model. Currently, only
36943695
PyTorch models are supported.
3696+
:param cache_size: The inference cache size (in memory outside the JVM heap)
3697+
per node for the model. The default value is the same size as the `model_size_bytes`.
3698+
To disable the cache, `0b` can be provided.
36953699
:param number_of_allocations: The number of model allocations on each node where
36963700
the model is deployed. All allocations on a node share the same copy of the
36973701
model in memory but use a separate set of threads to evaluate the model.
@@ -3715,6 +3719,8 @@ async def start_trained_model_deployment(
37153719
raise ValueError("Empty value passed for parameter 'model_id'")
37163720
__path = f"/_ml/trained_models/{_quote(model_id)}/deployment/_start"
37173721
__query: t.Dict[str, t.Any] = {}
3722+
if cache_size is not None:
3723+
__query["cache_size"] = cache_size
37183724
if error_trace is not None:
37193725
__query["error_trace"] = error_trace
37203726
if filter_path is not None:

elasticsearch/_async/client/security.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,66 @@ async def suggest_user_profiles(
25022502
"POST", __path, params=__query, headers=__headers, body=__body
25032503
)
25042504

2505+
@_rewrite_parameters(
2506+
body_fields=True,
2507+
)
2508+
async def update_api_key(
2509+
self,
2510+
*,
2511+
id: str,
2512+
error_trace: t.Optional[bool] = None,
2513+
filter_path: t.Optional[
2514+
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
2515+
] = None,
2516+
human: t.Optional[bool] = None,
2517+
metadata: t.Optional[t.Mapping[str, t.Any]] = None,
2518+
pretty: t.Optional[bool] = None,
2519+
role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
2520+
) -> ObjectApiResponse[t.Any]:
2521+
"""
2522+
Updates attributes of an existing API key.
2523+
2524+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.4/security-api-update-api-key.html>`_
2525+
2526+
:param id: The ID of the API key to update.
2527+
:param metadata: Arbitrary metadata that you want to associate with the API key.
2528+
It supports nested data structure. Within the metadata object, keys beginning
2529+
with _ are reserved for system usage.
2530+
:param role_descriptors: An array of role descriptors for this API key. This
2531+
parameter is optional. When it is not specified or is an empty array, then
2532+
the API key will have a point in time snapshot of permissions of the authenticated
2533+
user. If you supply role descriptors then the resultant permissions would
2534+
be an intersection of API keys permissions and authenticated user’s permissions
2535+
thereby limiting the access scope for API keys. The structure of role descriptor
2536+
is the same as the request for create role API. For more details, see create
2537+
or update roles API.
2538+
"""
2539+
if id in SKIP_IN_PATH:
2540+
raise ValueError("Empty value passed for parameter 'id'")
2541+
__path = f"/_security/api_key/{_quote(id)}"
2542+
__query: t.Dict[str, t.Any] = {}
2543+
__body: t.Dict[str, t.Any] = {}
2544+
if error_trace is not None:
2545+
__query["error_trace"] = error_trace
2546+
if filter_path is not None:
2547+
__query["filter_path"] = filter_path
2548+
if human is not None:
2549+
__query["human"] = human
2550+
if metadata is not None:
2551+
__body["metadata"] = metadata
2552+
if pretty is not None:
2553+
__query["pretty"] = pretty
2554+
if role_descriptors is not None:
2555+
__body["role_descriptors"] = role_descriptors
2556+
if not __body:
2557+
__body = None # type: ignore[assignment]
2558+
__headers = {"accept": "application/json"}
2559+
if __body is not None:
2560+
__headers["content-type"] = "application/json"
2561+
return await self.perform_request( # type: ignore[return-value]
2562+
"PUT", __path, params=__query, headers=__headers, body=__body
2563+
)
2564+
25052565
@_rewrite_parameters(
25062566
body_fields=True,
25072567
)

elasticsearch/_sync/client/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,7 @@ def search(
34073407
indices_boost: t.Optional[
34083408
t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]]
34093409
] = None,
3410+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
34103411
lenient: t.Optional[bool] = None,
34113412
max_concurrent_shard_requests: t.Optional[int] = None,
34123413
min_compatible_shard_node: t.Optional[str] = None,
@@ -3536,6 +3537,7 @@ def search(
35363537
:param ignore_unavailable: Whether specified concrete indices should be ignored
35373538
when unavailable (missing or closed)
35383539
:param indices_boost: Boosts the _score of documents from specified indices.
3540+
:param knn: Defines the approximate kNN search to run.
35393541
:param lenient: Specify whether format-based query failures (such as providing
35403542
text to a numeric field) should be ignored
35413543
:param max_concurrent_shard_requests: The number of concurrent shard requests
@@ -3680,6 +3682,8 @@ def search(
36803682
__query["ignore_unavailable"] = ignore_unavailable
36813683
if indices_boost is not None:
36823684
__body["indices_boost"] = indices_boost
3685+
if knn is not None:
3686+
__body["knn"] = knn
36833687
if lenient is not None:
36843688
__query["lenient"] = lenient
36853689
if max_concurrent_shard_requests is not None:

elasticsearch/_sync/client/async_search.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def submit(
215215
] = None,
216216
keep_alive: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
217217
keep_on_completion: t.Optional[bool] = None,
218+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
218219
lenient: t.Optional[bool] = None,
219220
max_concurrent_shard_requests: t.Optional[int] = None,
220221
min_compatible_shard_node: t.Optional[str] = None,
@@ -350,6 +351,7 @@ def submit(
350351
:param keep_on_completion: Control whether the response should be stored in the
351352
cluster if it completed within the provided [wait_for_completion] time (default:
352353
false)
354+
:param knn: Defines the approximate kNN search to run.
353355
:param lenient: Specify whether format-based query failures (such as providing
354356
text to a numeric field) should be ignored
355357
:param max_concurrent_shard_requests: The number of concurrent shard requests
@@ -492,6 +494,8 @@ def submit(
492494
__query["keep_alive"] = keep_alive
493495
if keep_on_completion is not None:
494496
__query["keep_on_completion"] = keep_on_completion
497+
if knn is not None:
498+
__body["knn"] = knn
495499
if lenient is not None:
496500
__query["lenient"] = lenient
497501
if max_concurrent_shard_requests is not None:

elasticsearch/_sync/client/ml.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,6 +3671,7 @@ def start_trained_model_deployment(
36713671
self,
36723672
*,
36733673
model_id: str,
3674+
cache_size: t.Optional[t.Union[int, str]] = None,
36743675
error_trace: t.Optional[bool] = None,
36753676
filter_path: t.Optional[
36763677
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
@@ -3692,6 +3693,9 @@ def start_trained_model_deployment(
36923693
36933694
:param model_id: The unique identifier of the trained model. Currently, only
36943695
PyTorch models are supported.
3696+
:param cache_size: The inference cache size (in memory outside the JVM heap)
3697+
per node for the model. The default value is the same size as the `model_size_bytes`.
3698+
To disable the cache, `0b` can be provided.
36953699
:param number_of_allocations: The number of model allocations on each node where
36963700
the model is deployed. All allocations on a node share the same copy of the
36973701
model in memory but use a separate set of threads to evaluate the model.
@@ -3715,6 +3719,8 @@ def start_trained_model_deployment(
37153719
raise ValueError("Empty value passed for parameter 'model_id'")
37163720
__path = f"/_ml/trained_models/{_quote(model_id)}/deployment/_start"
37173721
__query: t.Dict[str, t.Any] = {}
3722+
if cache_size is not None:
3723+
__query["cache_size"] = cache_size
37183724
if error_trace is not None:
37193725
__query["error_trace"] = error_trace
37203726
if filter_path is not None:

elasticsearch/_sync/client/security.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,66 @@ def suggest_user_profiles(
25022502
"POST", __path, params=__query, headers=__headers, body=__body
25032503
)
25042504

2505+
@_rewrite_parameters(
2506+
body_fields=True,
2507+
)
2508+
def update_api_key(
2509+
self,
2510+
*,
2511+
id: str,
2512+
error_trace: t.Optional[bool] = None,
2513+
filter_path: t.Optional[
2514+
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
2515+
] = None,
2516+
human: t.Optional[bool] = None,
2517+
metadata: t.Optional[t.Mapping[str, t.Any]] = None,
2518+
pretty: t.Optional[bool] = None,
2519+
role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
2520+
) -> ObjectApiResponse[t.Any]:
2521+
"""
2522+
Updates attributes of an existing API key.
2523+
2524+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.4/security-api-update-api-key.html>`_
2525+
2526+
:param id: The ID of the API key to update.
2527+
:param metadata: Arbitrary metadata that you want to associate with the API key.
2528+
It supports nested data structure. Within the metadata object, keys beginning
2529+
with _ are reserved for system usage.
2530+
:param role_descriptors: An array of role descriptors for this API key. This
2531+
parameter is optional. When it is not specified or is an empty array, then
2532+
the API key will have a point in time snapshot of permissions of the authenticated
2533+
user. If you supply role descriptors then the resultant permissions would
2534+
be an intersection of API keys permissions and authenticated user’s permissions
2535+
thereby limiting the access scope for API keys. The structure of role descriptor
2536+
is the same as the request for create role API. For more details, see create
2537+
or update roles API.
2538+
"""
2539+
if id in SKIP_IN_PATH:
2540+
raise ValueError("Empty value passed for parameter 'id'")
2541+
__path = f"/_security/api_key/{_quote(id)}"
2542+
__query: t.Dict[str, t.Any] = {}
2543+
__body: t.Dict[str, t.Any] = {}
2544+
if error_trace is not None:
2545+
__query["error_trace"] = error_trace
2546+
if filter_path is not None:
2547+
__query["filter_path"] = filter_path
2548+
if human is not None:
2549+
__query["human"] = human
2550+
if metadata is not None:
2551+
__body["metadata"] = metadata
2552+
if pretty is not None:
2553+
__query["pretty"] = pretty
2554+
if role_descriptors is not None:
2555+
__body["role_descriptors"] = role_descriptors
2556+
if not __body:
2557+
__body = None # type: ignore[assignment]
2558+
__headers = {"accept": "application/json"}
2559+
if __body is not None:
2560+
__headers["content-type"] = "application/json"
2561+
return self.perform_request( # type: ignore[return-value]
2562+
"PUT", __path, params=__query, headers=__headers, body=__body
2563+
)
2564+
25052565
@_rewrite_parameters(
25062566
body_fields=True,
25072567
)

0 commit comments

Comments
 (0)