Skip to content

Commit

Permalink
update api to 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
miriam-eid committed Aug 9, 2022
1 parent 54cd023 commit 58c7ce7
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
4 changes: 4 additions & 0 deletions elasticsearch/_async/client/__init__.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/_async/client/async_search.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/_async/client/ml.py
Expand Up @@ -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, ...]]]
Expand All @@ -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.
Expand All @@ -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:
Expand Down
60 changes: 60 additions & 0 deletions elasticsearch/_async/client/security.py
Expand Up @@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.4/security-api-update-api-key.html>`_
: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,
)
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/_sync/client/__init__.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/_sync/client/async_search.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/_sync/client/ml.py
Expand Up @@ -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, ...]]]
Expand All @@ -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.
Expand All @@ -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:
Expand Down
60 changes: 60 additions & 0 deletions elasticsearch/_sync/client/security.py
Expand Up @@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.4/security-api-update-api-key.html>`_
: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,
)
Expand Down

0 comments on commit 58c7ce7

Please sign in to comment.