From f7cac3033dcd7775a4217ab7cdb48c2c606df4c3 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:33:14 -0700 Subject: [PATCH] Updated opensearch-py to reflect the latest OpenSearch API spec (2024-06-17) (#763) Signed-off-by: GitHub Co-authored-by: saimedhi --- CHANGELOG.md | 1 + opensearchpy/_async/client/__init__.py | 56 +++--- opensearchpy/_async/client/cat.py | 2 +- opensearchpy/_async/client/cluster.py | 8 +- opensearchpy/_async/client/indices.py | 4 +- opensearchpy/_async/client/plugins.py | 2 + opensearchpy/_async/client/snapshot.py | 2 +- opensearchpy/_async/plugins/ml.py | 245 +++++++++++++++++++++++++ opensearchpy/client/__init__.py | 56 +++--- opensearchpy/client/cat.py | 2 +- opensearchpy/client/cluster.py | 8 +- opensearchpy/client/indices.py | 4 +- opensearchpy/client/plugins.py | 2 + opensearchpy/client/snapshot.py | 2 +- opensearchpy/plugins/ml.py | 245 +++++++++++++++++++++++++ 15 files changed, 567 insertions(+), 72 deletions(-) create mode 100644 opensearchpy/_async/plugins/ml.py create mode 100644 opensearchpy/plugins/ml.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f70460ec..814c6baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/opensearchpy/_async/client/__init__.py b/opensearchpy/_async/client/__init__.py index abca3067..05904b27 100644 --- a/opensearchpy/_async/client/__init__.py +++ b/opensearchpy/_async/client/__init__.py @@ -358,7 +358,7 @@ async def create( 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 @@ async def index( 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 @@ async def bulk( 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 @@ async def count( :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 @@ async def delete( 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 @@ async def delete_by_query( :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 @@ async def delete_by_query( :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 @@ async def exists( 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 @@ async def exists_source( 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 @@ async def get( 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 @@ async def get_source( 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 @@ async def search( 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 @@ async def search( 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 @@ async def search( `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 @@ async def update( :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 @@ async def update( :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 @@ async def update_by_query( :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 @@ async def update_by_query( :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 diff --git a/opensearchpy/_async/client/cat.py b/opensearchpy/_async/client/cat.py index 8e89206a..b5b64a5c 100644 --- a/opensearchpy/_async/client/cat.py +++ b/opensearchpy/_async/client/cat.py @@ -1249,7 +1249,7 @@ async def snapshots( :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. diff --git a/opensearchpy/_async/client/cluster.py b/opensearchpy/_async/client/cluster.py index 04682b26..2f873a90 100644 --- a/opensearchpy/_async/client/cluster.py +++ b/opensearchpy/_async/client/cluster.py @@ -649,14 +649,14 @@ async def put_component_template( 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 - don’t use Opensearch Agent and want to disable all built-in component + don’t 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 diff --git a/opensearchpy/_async/client/indices.py b/opensearchpy/_async/client/indices.py index 66e4e60f..5be0770e 100644 --- a/opensearchpy/_async/client/indices.py +++ b/opensearchpy/_async/client/indices.py @@ -174,7 +174,7 @@ async def flush( 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 @@ async def put_template( 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. diff --git a/opensearchpy/_async/client/plugins.py b/opensearchpy/_async/client/plugins.py index c7d070fc..5d79d20e 100644 --- a/opensearchpy/_async/client/plugins.py +++ b/opensearchpy/_async/client/plugins.py @@ -13,6 +13,7 @@ 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) diff --git a/opensearchpy/_async/client/snapshot.py b/opensearchpy/_async/client/snapshot.py index 80813d16..5a2da968 100644 --- a/opensearchpy/_async/client/snapshot.py +++ b/opensearchpy/_async/client/snapshot.py @@ -195,7 +195,7 @@ async def get( :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. """ diff --git a/opensearchpy/_async/plugins/ml.py b/opensearchpy/_async/plugins/ml.py new file mode 100644 index 00000000..0111915d --- /dev/null +++ b/opensearchpy/_async/plugins/ml.py @@ -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, + ) diff --git a/opensearchpy/client/__init__.py b/opensearchpy/client/__init__.py index c43b54a2..eb513048 100644 --- a/opensearchpy/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -358,7 +358,7 @@ def create( 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 @@ def index( 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 @@ def bulk( 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 @@ def count( :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 @@ def delete( 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 @@ def delete_by_query( :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 @@ def delete_by_query( :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 @@ def exists( 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 @@ def exists_source( 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 @@ def get( 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 @@ def get_source( 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 @@ def search( 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 @@ def search( 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 @@ def search( `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 @@ def update( :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 @@ def update( :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 @@ def update_by_query( :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 @@ def update_by_query( :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 diff --git a/opensearchpy/client/cat.py b/opensearchpy/client/cat.py index ff90d061..0962b3b2 100644 --- a/opensearchpy/client/cat.py +++ b/opensearchpy/client/cat.py @@ -1249,7 +1249,7 @@ def snapshots( :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. diff --git a/opensearchpy/client/cluster.py b/opensearchpy/client/cluster.py index 159aea49..f1b01e81 100644 --- a/opensearchpy/client/cluster.py +++ b/opensearchpy/client/cluster.py @@ -649,14 +649,14 @@ def put_component_template( 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 - don’t use Opensearch Agent and want to disable all built-in component + don’t 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 diff --git a/opensearchpy/client/indices.py b/opensearchpy/client/indices.py index 6d07837b..7bb81c01 100644 --- a/opensearchpy/client/indices.py +++ b/opensearchpy/client/indices.py @@ -174,7 +174,7 @@ def flush( 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 @@ def put_template( 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. diff --git a/opensearchpy/client/plugins.py b/opensearchpy/client/plugins.py index c7d070fc..5d79d20e 100644 --- a/opensearchpy/client/plugins.py +++ b/opensearchpy/client/plugins.py @@ -13,6 +13,7 @@ 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) diff --git a/opensearchpy/client/snapshot.py b/opensearchpy/client/snapshot.py index 2f0cd1d7..0c68d75c 100644 --- a/opensearchpy/client/snapshot.py +++ b/opensearchpy/client/snapshot.py @@ -195,7 +195,7 @@ def get( :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. """ diff --git a/opensearchpy/plugins/ml.py b/opensearchpy/plugins/ml.py new file mode 100644 index 00000000..979e3bb0 --- /dev/null +++ b/opensearchpy/plugins/ml.py @@ -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, + )