Updated opensearch-py to reflect the latest OpenSearch API spec (2024-06-17) (#763)

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: saimedhi <saimedhi@users.noreply.github.com>
This commit is contained in:
opensearch-trigger-bot[bot]
2024-06-17 15:33:14 -07:00
committed by GitHub
parent 1739a988d3
commit f7cac3033d
15 changed files with 567 additions and 72 deletions
+1
View File
@@ -9,6 +9,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed
### Fixed
### Updated APIs
- Updated opensearch-py APIs to reflect [opensearch-api-specification@49cd814](https://github.com/opensearch-project/opensearch-api-specification/commit/49cd8140663f32f7c8b638ddc295683344edba61)
### Security
### Dependencies
+28 -28
View File
@@ -358,7 +358,7 @@ class AsyncOpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -446,7 +446,7 @@ class AsyncOpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -532,7 +532,7 @@ class AsyncOpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -682,8 +682,8 @@ class AsyncOpenSearch(Client):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.
"""
return await self.transport.perform_request(
"POST",
@@ -733,7 +733,7 @@ class AsyncOpenSearch(Client):
this sequence number.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -860,7 +860,7 @@ class AsyncOpenSearch(Client):
:arg pretty: Whether to pretty format the returned JSON
response.
:arg q: Query in the Lucene query string syntax.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg request_cache: If `true`, the request cache is used for
this request.Defaults to the index-level setting.
@@ -885,10 +885,10 @@ class AsyncOpenSearch(Client):
:arg stats: Specific `tag` of the request for logging and
statistical purposes.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.
:arg timeout: Period each deletion request waits for active
@@ -1053,7 +1053,7 @@ class AsyncOpenSearch(Client):
response.
:arg realtime: If `true`, the request is real-time as opposed to
near-real-time.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg routing: Target the specified primary shard.
:arg source: The URL-encoded request definition. Useful for
@@ -1125,7 +1125,7 @@ class AsyncOpenSearch(Client):
response.
:arg realtime: If true, the request is real-time as opposed to
near-real-time.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg routing: Target the specified primary shard.
:arg source: The URL-encoded request definition. Useful for
@@ -1339,7 +1339,7 @@ class AsyncOpenSearch(Client):
response.
:arg realtime: If `true`, the request is real-time as opposed to
near-real-time.
:arg refresh: If true, Opensearch refreshes the affected shards
:arg refresh: If true, OpenSearch refreshes the affected shards
to make this operation visible to search. If false, do nothing with
refreshes.
:arg routing: Target the specified primary shard.
@@ -1453,7 +1453,7 @@ class AsyncOpenSearch(Client):
response.
:arg realtime: Boolean) If true, the request is real-time as
opposed to near-real-time.
:arg refresh: If true, Opensearch refreshes the affected shards
:arg refresh: If true, OpenSearch refreshes the affected shards
to make this operation visible to search. If false, do nothing with
refreshes.
:arg routing: Target the specified primary shard.
@@ -2264,7 +2264,7 @@ class AsyncOpenSearch(Client):
targets more than 128 shards;the request targets one or more read-only
index;the primary sort of the query targets an indexed field.
:arg preference: Nodes and shards used for the search.By
default, Opensearch selects from eligible nodes and shards using
default, OpenSearch selects from eligible nodes and shards using
adaptive replica selection, accounting for allocation awareness. Valid
values are:`_only_local` to run the search only on shards on the local
node;`_local` to, if possible, run the search on shards on the local
@@ -2284,7 +2284,7 @@ class AsyncOpenSearch(Client):
response.
:arg q: Query in the Lucene query string syntax using query
parameter search.Query parameter searches do not support the full
Opensearch Query DSL but are handy for testing.
OpenSearch Query DSL but are handy for testing.
:arg request_cache: If `true`, the caching of search results is
enabled for requests where `size` is `0`.Defaults to index level
settings.
@@ -2331,10 +2331,10 @@ class AsyncOpenSearch(Client):
`suggest_field` and `suggest_text` query string parameters are
specified.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.If set to
`0` (default), the query does not terminate early.
@@ -2646,7 +2646,7 @@ class AsyncOpenSearch(Client):
:arg lang: The script language. Default is painless.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If 'true', Opensearch refreshes the affected
:arg refresh: If 'true', OpenSearch refreshes the affected
shards to make this operationvisible to search, if 'wait_for' then wait
for a refresh to make this operationvisible to search, if 'false' do
nothing with refreshes. Valid choices are true, false, wait_for.
@@ -2659,7 +2659,7 @@ class AsyncOpenSearch(Client):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg timeout: Period to wait for dynamic mapping updates and
active shards.This guarantees Opensearch waits for at least the timeout
active shards.This guarantees OpenSearch waits for at least the timeout
before failing.The actual wait time could be longer, particularly when
multiple waits occur.
:arg wait_for_active_shards: The number of shard copies that
@@ -2784,7 +2784,7 @@ class AsyncOpenSearch(Client):
:arg pretty: Whether to pretty format the returned JSON
response.
:arg q: Query in the Lucene query string syntax.
:arg refresh: If `true`, Opensearch refreshes affected shards to
:arg refresh: If `true`, OpenSearch refreshes affected shards to
make the operation visible to search.
:arg request_cache: If `true`, the request cache is used for
this request.
@@ -2808,10 +2808,10 @@ class AsyncOpenSearch(Client):
:arg stats: Specific `tag` of the request for logging and
statistical purposes.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.
:arg timeout: Period each update request waits for the following
+1 -1
View File
@@ -1249,7 +1249,7 @@ class CatClient(NamespacedClient):
:arg repository: A comma-separated list of snapshot repositories
used to limit the request. Accepts wildcard expressions. `_all` returns
all repositories. If any repository fails during the request, Opensearch
all repositories. If any repository fails during the request, OpenSearch
returns an error.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
+4 -4
View File
@@ -649,14 +649,14 @@ class ClusterClient(NamespacedClient):
Creates or updates a component template.
:arg name: Name of the component template to create. Opensearch
:arg name: Name of the component template to create. OpenSearch
includes the following built-in component templates: `logs-mappings`;
'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-
mapping`; `synthetics-settings`. Opensearch Agent uses these templates
to configure backing indices for its data streams. If you use Opensearch
mapping`; `synthetics-settings`. OpenSearch Agent uses these templates
to configure backing indices for its data streams. If you use OpenSearch
Agent and want to overwrite one of these templates, set the `version`
for your replacement template higher than the current version. If you
dont use Opensearch Agent and want to disable all built-in component
dont use OpenSearch Agent and want to disable all built-in component
and index templates, set `stack.templates.enabled` to `false` using the
cluster update settings API.
:arg body: The template definition
+2 -2
View File
@@ -174,7 +174,7 @@ class IndicesClient(NamespacedClient):
libraries that do not accept a request body for non-POST requests.
:arg wait_if_ongoing: If `true`, the flush operation blocks
until execution when another flush operation is running.If `false`,
Opensearch returns an error if you request a flush when another flush
OpenSearch returns an error if you request a flush when another flush
operation is running. Default is True.
"""
return await self.transport.perform_request(
@@ -1164,7 +1164,7 @@ class IndicesClient(NamespacedClient):
use 'cluster_manager_timeout' instead.): Period to wait for a connection
to the master node. If no response isreceived before the timeout
expires, the request fails and returns an error.
:arg order: Order in which Opensearch applies this template if
:arg order: Order in which OpenSearch applies this template if
indexmatches multiple templates.Templates with lower 'order' values are
merged first. Templates with higher'order' values are merged later,
overriding templates with lower values.
+2
View File
@@ -13,6 +13,7 @@ from typing import Any
from ..plugins.alerting import AlertingClient
from ..plugins.index_management import IndexManagementClient
from ..plugins.knn import KnnClient
from ..plugins.ml import MlClient
from ..plugins.notifications import NotificationsClient
from ..plugins.rollups import RollupsClient
from ..plugins.transforms import TransformsClient
@@ -26,6 +27,7 @@ class PluginsClient(NamespacedClient):
def __init__(self, client: Client) -> None:
super(PluginsClient, self).__init__(client)
self.ml = MlClient(client)
self.transforms = TransformsClient(client)
self.rollups = RollupsClient(client)
self.notifications = NotificationsClient(client)
+1 -1
View File
@@ -195,7 +195,7 @@ class SnapshotClient(NamespacedClient):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg verbose: If true, returns additional information about each
snapshot such as the version of Opensearch which took the snapshot, the
snapshot such as the version of OpenSearch which took the snapshot, the
start and end times of the snapshot, and the number of shards
snapshotted.
"""
+245
View File
@@ -0,0 +1,245 @@
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
# ------------------------------------------------------------------------------------------
# THIS CODE IS AUTOMATICALLY GENERATED AND MANUAL EDITS WILL BE LOST
#
# To contribute, kindly make modifications in the opensearch-py client generator
# or in the OpenSearch API specification, and run `nox -rs generate`. See DEVELOPER_GUIDE.md
# and https://github.com/opensearch-project/opensearch-api-specification for details.
# -----------------------------------------------------------------------------------------+
from typing import Any
from ..client.utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
class MlClient(NamespacedClient):
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def delete_model(
self,
model_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Deletes a model.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'model_id'.")
return await self.transport.perform_request(
"DELETE",
_make_path("_plugins", "_ml", "models", model_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def delete_model_group(
self,
model_group_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Deletes a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_group_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'model_group_id'."
)
return await self.transport.perform_request(
"DELETE",
_make_path("_plugins", "_ml", "model_groups", model_group_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def get_model_group(
self,
model_group_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Retrieves a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_group_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'model_group_id'."
)
return await self.transport.perform_request(
"GET",
_make_path("_plugins", "_ml", "model_groups", model_group_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def get_task(
self,
task_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Retrieves a task.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if task_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'task_id'.")
return await self.transport.perform_request(
"GET",
_make_path("_plugins", "_ml", "tasks", task_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def register_model(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Registers a model.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return await self.transport.perform_request(
"POST",
"/_plugins/_ml/models/_register",
params=params,
headers=headers,
body=body,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def register_model_group(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Registers a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return await self.transport.perform_request(
"POST",
"/_plugins/_ml/model_groups/_register",
params=params,
headers=headers,
body=body,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
async def search_models(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Searches for models.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return await self.transport.perform_request(
"GET",
"/_plugins/_ml/models/_search",
params=params,
headers=headers,
body=body,
)
+28 -28
View File
@@ -358,7 +358,7 @@ class OpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -446,7 +446,7 @@ class OpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -532,7 +532,7 @@ class OpenSearch(Client):
regardless of the value of this parameter.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -682,8 +682,8 @@ class OpenSearch(Client):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.
"""
return self.transport.perform_request(
"POST",
@@ -733,7 +733,7 @@ class OpenSearch(Client):
this sequence number.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If `true`, Opensearch refreshes the affected
:arg refresh: If `true`, OpenSearch refreshes the affected
shards to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false` do
nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
@@ -860,7 +860,7 @@ class OpenSearch(Client):
:arg pretty: Whether to pretty format the returned JSON
response.
:arg q: Query in the Lucene query string syntax.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg request_cache: If `true`, the request cache is used for
this request.Defaults to the index-level setting.
@@ -885,10 +885,10 @@ class OpenSearch(Client):
:arg stats: Specific `tag` of the request for logging and
statistical purposes.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.
:arg timeout: Period each deletion request waits for active
@@ -1053,7 +1053,7 @@ class OpenSearch(Client):
response.
:arg realtime: If `true`, the request is real-time as opposed to
near-real-time.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg routing: Target the specified primary shard.
:arg source: The URL-encoded request definition. Useful for
@@ -1125,7 +1125,7 @@ class OpenSearch(Client):
response.
:arg realtime: If true, the request is real-time as opposed to
near-real-time.
:arg refresh: If `true`, Opensearch refreshes all shards
:arg refresh: If `true`, OpenSearch refreshes all shards
involved in the delete by query after the request completes.
:arg routing: Target the specified primary shard.
:arg source: The URL-encoded request definition. Useful for
@@ -1339,7 +1339,7 @@ class OpenSearch(Client):
response.
:arg realtime: If `true`, the request is real-time as opposed to
near-real-time.
:arg refresh: If true, Opensearch refreshes the affected shards
:arg refresh: If true, OpenSearch refreshes the affected shards
to make this operation visible to search. If false, do nothing with
refreshes.
:arg routing: Target the specified primary shard.
@@ -1453,7 +1453,7 @@ class OpenSearch(Client):
response.
:arg realtime: Boolean) If true, the request is real-time as
opposed to near-real-time.
:arg refresh: If true, Opensearch refreshes the affected shards
:arg refresh: If true, OpenSearch refreshes the affected shards
to make this operation visible to search. If false, do nothing with
refreshes.
:arg routing: Target the specified primary shard.
@@ -2264,7 +2264,7 @@ class OpenSearch(Client):
targets more than 128 shards;the request targets one or more read-only
index;the primary sort of the query targets an indexed field.
:arg preference: Nodes and shards used for the search.By
default, Opensearch selects from eligible nodes and shards using
default, OpenSearch selects from eligible nodes and shards using
adaptive replica selection, accounting for allocation awareness. Valid
values are:`_only_local` to run the search only on shards on the local
node;`_local` to, if possible, run the search on shards on the local
@@ -2284,7 +2284,7 @@ class OpenSearch(Client):
response.
:arg q: Query in the Lucene query string syntax using query
parameter search.Query parameter searches do not support the full
Opensearch Query DSL but are handy for testing.
OpenSearch Query DSL but are handy for testing.
:arg request_cache: If `true`, the caching of search results is
enabled for requests where `size` is `0`.Defaults to index level
settings.
@@ -2331,10 +2331,10 @@ class OpenSearch(Client):
`suggest_field` and `suggest_text` query string parameters are
specified.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.If set to
`0` (default), the query does not terminate early.
@@ -2646,7 +2646,7 @@ class OpenSearch(Client):
:arg lang: The script language. Default is painless.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg refresh: If 'true', Opensearch refreshes the affected
:arg refresh: If 'true', OpenSearch refreshes the affected
shards to make this operationvisible to search, if 'wait_for' then wait
for a refresh to make this operationvisible to search, if 'false' do
nothing with refreshes. Valid choices are true, false, wait_for.
@@ -2659,7 +2659,7 @@ class OpenSearch(Client):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg timeout: Period to wait for dynamic mapping updates and
active shards.This guarantees Opensearch waits for at least the timeout
active shards.This guarantees OpenSearch waits for at least the timeout
before failing.The actual wait time could be longer, particularly when
multiple waits occur.
:arg wait_for_active_shards: The number of shard copies that
@@ -2784,7 +2784,7 @@ class OpenSearch(Client):
:arg pretty: Whether to pretty format the returned JSON
response.
:arg q: Query in the Lucene query string syntax.
:arg refresh: If `true`, Opensearch refreshes affected shards to
:arg refresh: If `true`, OpenSearch refreshes affected shards to
make the operation visible to search.
:arg request_cache: If `true`, the request cache is used for
this request.
@@ -2808,10 +2808,10 @@ class OpenSearch(Client):
:arg stats: Specific `tag` of the request for logging and
statistical purposes.
:arg terminate_after: Maximum number of documents to collect for
each shard.If a query reaches this limit, Opensearch terminates the
query early.Opensearch collects documents before sorting.Use with
caution.Opensearch applies this parameter to each shard handling the
request.When possible, let Opensearch perform early termination
each shard.If a query reaches this limit, OpenSearch terminates the
query early.OpenSearch collects documents before sorting.Use with
caution.OpenSearch applies this parameter to each shard handling the
request.When possible, let OpenSearch perform early termination
automatically.Avoid specifying this parameter for requests that target
data streams with backing indices across multiple data tiers.
:arg timeout: Period each update request waits for the following
+1 -1
View File
@@ -1249,7 +1249,7 @@ class CatClient(NamespacedClient):
:arg repository: A comma-separated list of snapshot repositories
used to limit the request. Accepts wildcard expressions. `_all` returns
all repositories. If any repository fails during the request, Opensearch
all repositories. If any repository fails during the request, OpenSearch
returns an error.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
+4 -4
View File
@@ -649,14 +649,14 @@ class ClusterClient(NamespacedClient):
Creates or updates a component template.
:arg name: Name of the component template to create. Opensearch
:arg name: Name of the component template to create. OpenSearch
includes the following built-in component templates: `logs-mappings`;
'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-
mapping`; `synthetics-settings`. Opensearch Agent uses these templates
to configure backing indices for its data streams. If you use Opensearch
mapping`; `synthetics-settings`. OpenSearch Agent uses these templates
to configure backing indices for its data streams. If you use OpenSearch
Agent and want to overwrite one of these templates, set the `version`
for your replacement template higher than the current version. If you
dont use Opensearch Agent and want to disable all built-in component
dont use OpenSearch Agent and want to disable all built-in component
and index templates, set `stack.templates.enabled` to `false` using the
cluster update settings API.
:arg body: The template definition
+2 -2
View File
@@ -174,7 +174,7 @@ class IndicesClient(NamespacedClient):
libraries that do not accept a request body for non-POST requests.
:arg wait_if_ongoing: If `true`, the flush operation blocks
until execution when another flush operation is running.If `false`,
Opensearch returns an error if you request a flush when another flush
OpenSearch returns an error if you request a flush when another flush
operation is running. Default is True.
"""
return self.transport.perform_request(
@@ -1164,7 +1164,7 @@ class IndicesClient(NamespacedClient):
use 'cluster_manager_timeout' instead.): Period to wait for a connection
to the master node. If no response isreceived before the timeout
expires, the request fails and returns an error.
:arg order: Order in which Opensearch applies this template if
:arg order: Order in which OpenSearch applies this template if
indexmatches multiple templates.Templates with lower 'order' values are
merged first. Templates with higher'order' values are merged later,
overriding templates with lower values.
+2
View File
@@ -13,6 +13,7 @@ from typing import Any
from ..plugins.alerting import AlertingClient
from ..plugins.index_management import IndexManagementClient
from ..plugins.knn import KnnClient
from ..plugins.ml import MlClient
from ..plugins.notifications import NotificationsClient
from ..plugins.rollups import RollupsClient
from ..plugins.transforms import TransformsClient
@@ -26,6 +27,7 @@ class PluginsClient(NamespacedClient):
def __init__(self, client: Client) -> None:
super(PluginsClient, self).__init__(client)
self.ml = MlClient(client)
self.transforms = TransformsClient(client)
self.rollups = RollupsClient(client)
self.notifications = NotificationsClient(client)
+1 -1
View File
@@ -195,7 +195,7 @@ class SnapshotClient(NamespacedClient):
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg verbose: If true, returns additional information about each
snapshot such as the version of Opensearch which took the snapshot, the
snapshot such as the version of OpenSearch which took the snapshot, the
start and end times of the snapshot, and the number of shards
snapshotted.
"""
+245
View File
@@ -0,0 +1,245 @@
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
# ------------------------------------------------------------------------------------------
# THIS CODE IS AUTOMATICALLY GENERATED AND MANUAL EDITS WILL BE LOST
#
# To contribute, kindly make modifications in the opensearch-py client generator
# or in the OpenSearch API specification, and run `nox -rs generate`. See DEVELOPER_GUIDE.md
# and https://github.com/opensearch-project/opensearch-api-specification for details.
# -----------------------------------------------------------------------------------------+
from typing import Any
from ..client.utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
class MlClient(NamespacedClient):
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def delete_model(
self,
model_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Deletes a model.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'model_id'.")
return self.transport.perform_request(
"DELETE",
_make_path("_plugins", "_ml", "models", model_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def delete_model_group(
self,
model_group_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Deletes a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_group_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'model_group_id'."
)
return self.transport.perform_request(
"DELETE",
_make_path("_plugins", "_ml", "model_groups", model_group_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def get_model_group(
self,
model_group_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Retrieves a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if model_group_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'model_group_id'."
)
return self.transport.perform_request(
"GET",
_make_path("_plugins", "_ml", "model_groups", model_group_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def get_task(
self,
task_id: Any,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Retrieves a task.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if task_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'task_id'.")
return self.transport.perform_request(
"GET",
_make_path("_plugins", "_ml", "tasks", task_id),
params=params,
headers=headers,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def register_model(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Registers a model.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return self.transport.perform_request(
"POST",
"/_plugins/_ml/models/_register",
params=params,
headers=headers,
body=body,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def register_model_group(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Registers a model group.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return self.transport.perform_request(
"POST",
"/_plugins/_ml/model_groups/_register",
params=params,
headers=headers,
body=body,
)
@query_params("error_trace", "filter_path", "human", "pretty", "source")
def search_models(
self,
body: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Searches for models.
:arg error_trace: Whether to include the stack trace of returned
errors.
:arg filter_path: Comma-separated list of filters used to reduce
the response.
:arg human: Whether to return human readable values for
statistics.
:arg pretty: Whether to pretty format the returned JSON
response.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
return self.transport.perform_request(
"GET",
"/_plugins/_ml/models/_search",
params=params,
headers=headers,
body=body,
)