diff --git a/CHANGELOG.md b/CHANGELOG.md index e53defe5..9ed463a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed - Updated code generator to use native OpenAPI specification ([#721](https://github.com/opensearch-project/opensearch-py/pull/721)) ### Updated APIs +- Updated opensearch-py APIs to reflect [opensearch-api-specification@9013205](https://github.com/opensearch-project/opensearch-api-specification/commit/90132054984b6a93089aeafd9ce6ad93c386eab7) - Updated opensearch-py APIs to reflect [opensearch-api-specification@b253667](https://github.com/opensearch-project/opensearch-api-specification/commit/b2536673227663e6ba7c757d36e30c7e0e78f684) - Updated opensearch-py APIs to reflect [opensearch-api-specification@deeb400](https://github.com/opensearch-project/opensearch-api-specification/commit/deeb4005291dd499d1e637dffb2db9cd3bfb14b6) - Updated opensearch-py APIs to reflect [opensearch-api-specification@de939d2](https://github.com/opensearch-project/opensearch-api-specification/commit/de939d2b116ae15f364fae588f67e139198d0c56) diff --git a/opensearchpy/_async/client/plugins.py b/opensearchpy/_async/client/plugins.py index b4f84f3f..c7d070fc 100644 --- a/opensearchpy/_async/client/plugins.py +++ b/opensearchpy/_async/client/plugins.py @@ -15,6 +15,7 @@ from ..plugins.knn import KnnClient from ..plugins.notifications import NotificationsClient from ..plugins.rollups import RollupsClient +from ..plugins.transforms import TransformsClient from .client import Client from .utils import NamespacedClient @@ -25,6 +26,7 @@ class PluginsClient(NamespacedClient): def __init__(self, client: Client) -> None: super(PluginsClient, self).__init__(client) + self.transforms = TransformsClient(client) self.rollups = RollupsClient(client) self.notifications = NotificationsClient(client) self.knn = KnnClient(client) diff --git a/opensearchpy/_async/plugins/transforms.py b/opensearchpy/_async/plugins/transforms.py new file mode 100644 index 00000000..231d02ee --- /dev/null +++ b/opensearchpy/_async/plugins/transforms.py @@ -0,0 +1,308 @@ +# 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 TransformsClient(NamespacedClient): + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def delete( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Delete an index transform. + + + :arg id: Transform to delete + :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", "_transform", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def explain( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns the status and metadata of a transform job. + + + :arg id: Transform to explain + :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", "_transform", id, "_explain"), + 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: + """ + Returns the status and metadata of a transform job. + + + :arg id: Transform to access + :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", "_transform", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def preview( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns a preview of what a transformed index would look like. + + + :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/_transform/_preview", params=params, headers=headers + ) + + @query_params( + "error_trace", + "filter_path", + "human", + "if_primary_term", + "if_seq_no", + "pretty", + "source", + ) + async def put( + self, + id: Any, + body: Any = None, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Create an index transform, or update a transform if if_seq_no and + if_primary_term are provided. + + + :arg id: Transform to create/update + :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 if_primary_term: Only perform the operation if the document + has this primary term. + :arg if_seq_no: Only perform the operation if the document has + this sequence number. + :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( + "PUT", + _make_path("_plugins", "_transform", id), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "error_trace", + "filter_path", + "from_", + "human", + "pretty", + "search", + "size", + "sortDirection", + "sortField", + "source", + ) + async def search( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns the details of all transform jobs. + + + :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 from_: The starting transform to return. Default is 0. + :arg human: Whether to return human readable values for + statistics. + :arg pretty: Whether to pretty format the returned JSON + response. + :arg search: The search term to use to filter results. + :arg size: Specifies the number of transforms to return. Default + is 10. + :arg sortDirection: Specifies the direction to sort results in. + Can be ASC or DESC. Default is ASC. + :arg sortField: The field to sort results with. + :arg source: The URL-encoded request definition. Useful for + libraries that do not accept a request body for non-POST requests. + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + return await self.transport.perform_request( + "GET", "/_plugins/_transform", params=params, headers=headers + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def start( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Start transform. + + + :arg id: Transform to start + :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( + "POST", + _make_path("_plugins", "_transform", id, "_start"), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + async def stop( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + stop transform. + + + :arg id: Transform to stop + :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( + "POST", + _make_path("_plugins", "_transform", id, "_stop"), + params=params, + headers=headers, + ) diff --git a/opensearchpy/client/plugins.py b/opensearchpy/client/plugins.py index b4f84f3f..c7d070fc 100644 --- a/opensearchpy/client/plugins.py +++ b/opensearchpy/client/plugins.py @@ -15,6 +15,7 @@ from ..plugins.knn import KnnClient from ..plugins.notifications import NotificationsClient from ..plugins.rollups import RollupsClient +from ..plugins.transforms import TransformsClient from .client import Client from .utils import NamespacedClient @@ -25,6 +26,7 @@ class PluginsClient(NamespacedClient): def __init__(self, client: Client) -> None: super(PluginsClient, self).__init__(client) + self.transforms = TransformsClient(client) self.rollups = RollupsClient(client) self.notifications = NotificationsClient(client) self.knn = KnnClient(client) diff --git a/opensearchpy/plugins/transforms.py b/opensearchpy/plugins/transforms.py new file mode 100644 index 00000000..9f8161ed --- /dev/null +++ b/opensearchpy/plugins/transforms.py @@ -0,0 +1,308 @@ +# 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 TransformsClient(NamespacedClient): + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def delete( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Delete an index transform. + + + :arg id: Transform to delete + :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", "_transform", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def explain( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns the status and metadata of a transform job. + + + :arg id: Transform to explain + :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", "_transform", id, "_explain"), + 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: + """ + Returns the status and metadata of a transform job. + + + :arg id: Transform to access + :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", "_transform", id), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def preview( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns a preview of what a transformed index would look like. + + + :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/_transform/_preview", params=params, headers=headers + ) + + @query_params( + "error_trace", + "filter_path", + "human", + "if_primary_term", + "if_seq_no", + "pretty", + "source", + ) + def put( + self, + id: Any, + body: Any = None, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Create an index transform, or update a transform if if_seq_no and + if_primary_term are provided. + + + :arg id: Transform to create/update + :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 if_primary_term: Only perform the operation if the document + has this primary term. + :arg if_seq_no: Only perform the operation if the document has + this sequence number. + :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( + "PUT", + _make_path("_plugins", "_transform", id), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "error_trace", + "filter_path", + "from_", + "human", + "pretty", + "search", + "size", + "sortDirection", + "sortField", + "source", + ) + def search( + self, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Returns the details of all transform jobs. + + + :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 from_: The starting transform to return. Default is 0. + :arg human: Whether to return human readable values for + statistics. + :arg pretty: Whether to pretty format the returned JSON + response. + :arg search: The search term to use to filter results. + :arg size: Specifies the number of transforms to return. Default + is 10. + :arg sortDirection: Specifies the direction to sort results in. + Can be ASC or DESC. Default is ASC. + :arg sortField: The field to sort results with. + :arg source: The URL-encoded request definition. Useful for + libraries that do not accept a request body for non-POST requests. + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + return self.transport.perform_request( + "GET", "/_plugins/_transform", params=params, headers=headers + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def start( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Start transform. + + + :arg id: Transform to start + :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( + "POST", + _make_path("_plugins", "_transform", id, "_start"), + params=params, + headers=headers, + ) + + @query_params("error_trace", "filter_path", "human", "pretty", "source") + def stop( + self, + id: Any, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + stop transform. + + + :arg id: Transform to stop + :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( + "POST", + _make_path("_plugins", "_transform", id, "_stop"), + params=params, + headers=headers, + )