diff --git a/CHANGELOG.md b/CHANGELOG.md index 672fd065..4a3823db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed the use of `minimum_should_match` with `Bool` to allow the use of string-based value (percent string, combination). ([#780](https://github.com/opensearch-project/opensearch-py/pull/780)) - Fixed incorrect `retry_on_conflict` type ([#795](https://github.com/opensearch-project/opensearch-py/pull/795)) ### Updated APIs +- Updated opensearch-py APIs to reflect [opensearch-api-specification@147e77e](https://github.com/opensearch-project/opensearch-api-specification/commit/147e77e366bb4bdc090d89e086182b4e7a24fe08) - Updated opensearch-py APIs to reflect [opensearch-api-specification@9d3bc34](https://github.com/opensearch-project/opensearch-api-specification/commit/9d3bc340ccd7d049e7d6e14a4aff2293780cb446) ### Dependencies - Bump `pytest-asyncio` from <=0.23.7 to <=0.23.8 ([#787](https://github.com/opensearch-project/opensearch-py/pull/787)) diff --git a/opensearchpy/_async/client/plugins.py b/opensearchpy/_async/client/plugins.py index acf1ec57..ef81da3a 100644 --- a/opensearchpy/_async/client/plugins.py +++ b/opensearchpy/_async/client/plugins.py @@ -11,6 +11,7 @@ from typing import Any from ..plugins.alerting import AlertingClient +from ..plugins.asynchronous_search import AsynchronousSearchClient from ..plugins.index_management import IndexManagementClient from ..plugins.knn import KnnClient from ..plugins.ml import MlClient @@ -26,6 +27,7 @@ class PluginsClient(NamespacedClient): + asynchronous_search: Any alerting: Any index_management: Any knn: Any @@ -41,6 +43,7 @@ class PluginsClient(NamespacedClient): def __init__(self, client: Client) -> None: super().__init__(client) + self.asynchronous_search = AsynchronousSearchClient(client) self.alerting = AlertingClient(client) self.index_management = IndexManagementClient(client) self.knn = KnnClient(client) @@ -59,6 +62,7 @@ def _dynamic_lookup(self, client: Any) -> None: # Issue : https://github.com/opensearch-project/opensearch-py/issues/90#issuecomment-1003396742 plugins = [ + "asynchronous_search", "alerting", "index_management", "knn", diff --git a/opensearchpy/_async/plugins/asynchronous_search.py b/opensearchpy/_async/plugins/asynchronous_search.py new file mode 100644 index 00000000..d14b2351 --- /dev/null +++ b/opensearchpy/_async/plugins/asynchronous_search.py @@ -0,0 +1,163 @@ +# 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 AsynchronousSearchClient(NamespacedClient): + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def delete( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Delete asynchronous search. + + + :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 id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return await self.transport.perform_request( + "DELETE", + _make_path("_plugins", "_asynchronous_search", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def get( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Get partial responses from asynchronous search. + + + :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 id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return await self.transport.perform_request( + "GET", + _make_path("_plugins", "_asynchronous_search", id), + params=params, + headers=headers, + ) + + @query_params( + "error_trace", + "filter_path", + "human", + "index", + "keep_alive", + "keep_on_completion", + "pretty", + "source", + "wait_for_completion_timeout", + ) + async def search( + self, + body: Any = None, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Perform an asynchronous search. + + + :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 index: The name of the index to be searched. + :arg keep_alive: The amount of time that the result is saved in + the cluster. + :arg keep_on_completion: Whether you want to save the results in + the cluster after the search is complete. + :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. + :arg wait_for_completion_timeout: The amount of time that you + plan to wait for the results. + """ + return await self.transport.perform_request( + "POST", + "/_plugins/_asynchronous_search", + params=params, + headers=headers, + body=body, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def stats( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Monitoring of asynchronous searches that are running, completed, and/or + persisted. + + + :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/_asynchronous_search/stats", + params=params, + headers=headers, + ) diff --git a/opensearchpy/_async/plugins/ml.py b/opensearchpy/_async/plugins/ml.py index b48bf775..6bcee98c 100644 --- a/opensearchpy/_async/plugins/ml.py +++ b/opensearchpy/_async/plugins/ml.py @@ -307,3 +307,35 @@ async def undeploy_model( params=params, headers=headers, ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def delete_task( + self, + task_id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Deletes 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( + "DELETE", + _make_path("_plugins", "_ml", "tasks", task_id), + params=params, + headers=headers, + ) diff --git a/opensearchpy/client/plugins.py b/opensearchpy/client/plugins.py index 526e1cab..ef81da3a 100644 --- a/opensearchpy/client/plugins.py +++ b/opensearchpy/client/plugins.py @@ -11,6 +11,7 @@ from typing import Any from ..plugins.alerting import AlertingClient +from ..plugins.asynchronous_search import AsynchronousSearchClient from ..plugins.index_management import IndexManagementClient from ..plugins.knn import KnnClient from ..plugins.ml import MlClient @@ -26,12 +27,23 @@ class PluginsClient(NamespacedClient): + asynchronous_search: Any alerting: Any index_management: Any + knn: Any + ml: Any + notifications: Any + observability: Any + ppl: Any + query: Any + rollups: Any + sql: Any + transforms: Any def __init__(self, client: Client) -> None: super().__init__(client) + self.asynchronous_search = AsynchronousSearchClient(client) self.alerting = AlertingClient(client) self.index_management = IndexManagementClient(client) self.knn = KnnClient(client) @@ -50,13 +62,18 @@ def _dynamic_lookup(self, client: Any) -> None: # Issue : https://github.com/opensearch-project/opensearch-py/issues/90#issuecomment-1003396742 plugins = [ - # "query_workbench", - # "reporting", - # "notebooks", + "asynchronous_search", "alerting", - # "anomaly_detection", - # "trace_analytics", "index_management", + "knn", + "ml", + "notifications", + "observability", + "ppl", + "query", + "rollups", + "sql", + "transforms", ] for plugin in plugins: if not hasattr(client, plugin): diff --git a/opensearchpy/plugins/asynchronous_search.py b/opensearchpy/plugins/asynchronous_search.py new file mode 100644 index 00000000..de90e7b3 --- /dev/null +++ b/opensearchpy/plugins/asynchronous_search.py @@ -0,0 +1,163 @@ +# 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 AsynchronousSearchClient(NamespacedClient): + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def delete( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Delete asynchronous search. + + + :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 id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return self.transport.perform_request( + "DELETE", + _make_path("_plugins", "_asynchronous_search", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def get( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Get partial responses from asynchronous search. + + + :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 id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return self.transport.perform_request( + "GET", + _make_path("_plugins", "_asynchronous_search", id), + params=params, + headers=headers, + ) + + @query_params( + "error_trace", + "filter_path", + "human", + "index", + "keep_alive", + "keep_on_completion", + "pretty", + "source", + "wait_for_completion_timeout", + ) + def search( + self, + body: Any = None, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Perform an asynchronous search. + + + :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 index: The name of the index to be searched. + :arg keep_alive: The amount of time that the result is saved in + the cluster. + :arg keep_on_completion: Whether you want to save the results in + the cluster after the search is complete. + :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. + :arg wait_for_completion_timeout: The amount of time that you + plan to wait for the results. + """ + return self.transport.perform_request( + "POST", + "/_plugins/_asynchronous_search", + params=params, + headers=headers, + body=body, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def stats( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Monitoring of asynchronous searches that are running, completed, and/or + persisted. + + + :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/_asynchronous_search/stats", + params=params, + headers=headers, + ) diff --git a/opensearchpy/plugins/ml.py b/opensearchpy/plugins/ml.py index 1183bf5e..0f6daa8f 100644 --- a/opensearchpy/plugins/ml.py +++ b/opensearchpy/plugins/ml.py @@ -307,3 +307,35 @@ def undeploy_model( params=params, headers=headers, ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def delete_task( + self, + task_id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Deletes 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( + "DELETE", + _make_path("_plugins", "_ml", "tasks", task_id), + params=params, + headers=headers, + )