diff --git a/CHANGELOG.md b/CHANGELOG.md index eb2d2c41..a259f485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed - Fixed Search helper to ensure proper retention of the _collapse attribute in chained operations. ([#771](https://github.com/opensearch-project/opensearch-py/pull/771)) ### Updated APIs +- Updated opensearch-py APIs to reflect [opensearch-api-specification@0453dbe](https://github.com/opensearch-project/opensearch-api-specification/commit/0453dbe35080bf31eebac1d75f8022667d019e9f) - Updated opensearch-py APIs to reflect [opensearch-api-specification@0b033a9](https://github.com/opensearch-project/opensearch-api-specification/commit/0b033a92cac4cb20ec3fb51350c139afc753b089) - Updated opensearch-py APIs to reflect [opensearch-api-specification@d5ca873](https://github.com/opensearch-project/opensearch-api-specification/commit/d5ca873d20ff54be16ec48e7bd629cda7c4a6332) - Updated opensearch-py APIs to reflect [opensearch-api-specification@7452827](https://github.com/opensearch-project/opensearch-api-specification/commit/745282767026703ea27967d2705633c3e2661c97) diff --git a/opensearchpy/_async/client/indices.py b/opensearchpy/_async/client/indices.py index 2f421ebf..3e2cee26 100644 --- a/opensearchpy/_async/client/indices.py +++ b/opensearchpy/_async/client/indices.py @@ -592,6 +592,7 @@ class IndicesClient(NamespacedClient): @query_params( "allow_no_indices", + "cluster_manager_timeout", "error_trace", "expand_wildcards", "filter_path", @@ -619,6 +620,8 @@ class IndicesClient(NamespacedClient): if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. Default is false. + :arg cluster_manager_timeout: Operation timeout for connection + to cluster-manager node. :arg error_trace: Whether to include the stack trace of returned errors. :arg expand_wildcards: Type of index that wildcard patterns can @@ -861,9 +864,9 @@ class IndicesClient(NamespacedClient): ) async def put_alias( self, - index: Any, - name: Any, body: Any = None, + index: Any = None, + name: Any = None, params: Any = None, headers: Any = None, ) -> Any: @@ -871,13 +874,13 @@ class IndicesClient(NamespacedClient): Creates or updates an alias. + :arg body: The settings for the alias, such as `routing` or + `filter` :arg index: Comma-separated list of data streams or indices to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indices return an error. :arg name: Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. - :arg body: The settings for the alias, such as `routing` or - `filter` :arg cluster_manager_timeout: Operation timeout for connection to cluster-manager node. :arg error_trace: Whether to include the stack trace of returned @@ -898,10 +901,6 @@ class IndicesClient(NamespacedClient): received before the timeout expires, the request fails and returns an error. """ - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - return await self.transport.perform_request( "PUT", _make_path(index, "_alias", name), diff --git a/opensearchpy/client/indices.py b/opensearchpy/client/indices.py index 5e5aa27c..221df970 100644 --- a/opensearchpy/client/indices.py +++ b/opensearchpy/client/indices.py @@ -592,6 +592,7 @@ class IndicesClient(NamespacedClient): @query_params( "allow_no_indices", + "cluster_manager_timeout", "error_trace", "expand_wildcards", "filter_path", @@ -619,6 +620,8 @@ class IndicesClient(NamespacedClient): if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. Default is false. + :arg cluster_manager_timeout: Operation timeout for connection + to cluster-manager node. :arg error_trace: Whether to include the stack trace of returned errors. :arg expand_wildcards: Type of index that wildcard patterns can @@ -861,9 +864,9 @@ class IndicesClient(NamespacedClient): ) def put_alias( self, - index: Any, - name: Any, body: Any = None, + index: Any = None, + name: Any = None, params: Any = None, headers: Any = None, ) -> Any: @@ -871,13 +874,13 @@ class IndicesClient(NamespacedClient): Creates or updates an alias. + :arg body: The settings for the alias, such as `routing` or + `filter` :arg index: Comma-separated list of data streams or indices to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indices return an error. :arg name: Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. - :arg body: The settings for the alias, such as `routing` or - `filter` :arg cluster_manager_timeout: Operation timeout for connection to cluster-manager node. :arg error_trace: Whether to include the stack trace of returned @@ -898,10 +901,6 @@ class IndicesClient(NamespacedClient): received before the timeout expires, the request fails and returns an error. """ - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( "PUT", _make_path(index, "_alias", name), diff --git a/test_opensearchpy/test_server/test_rest_api_spec.py b/test_opensearchpy/test_server/test_rest_api_spec.py index 1f014135..046b4208 100644 --- a/test_opensearchpy/test_server/test_rest_api_spec.py +++ b/test_opensearchpy/test_server/test_rest_api_spec.py @@ -79,9 +79,8 @@ SKIP_TESTS = { "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/cluster/put_settings/10_basic[2]", "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/cluster/put_settings/10_basic[3]", "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/index/90_unsigned_long[1]", - "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/put_alias/10_basic[0]", - "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/put_alias/10_basic[8]", - "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/put_alias/10_basic[9]", + "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/put_alias/all_path_options[5]", + "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/put_alias/all_path_options[6]", "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/stats/50_noop_update[0]", "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/search/340_doc_values_field[0]", "OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/search/340_doc_values_field[1]", diff --git a/utils/generate_api.py b/utils/generate_api.py index 32754ca1..9bb8674c 100644 --- a/utils/generate_api.py +++ b/utils/generate_api.py @@ -72,6 +72,11 @@ GLOBAL_QUERY_PARAMS = { "api_key": "Optional[Union[str, Tuple[str, str]]]", } +IGNORED_PARAM_REFS = [ + # https://github.com/opensearch-project/opensearch-api-specification/pull/416 + "#/components/parameters/nodes.info::path.node_id_or_metric", +] + jinja_env = Environment( autoescape=select_autoescape(["html", "xml"]), loader=FileSystemLoader([CODE_ROOT / "utils" / "templates"]), @@ -584,9 +589,13 @@ def read_modules() -> Any: # Iterate over the list of parameters and update them for param_ref in endpoint["parameters"]: - param = data["components"]["parameters"][ - param_ref["$ref"].split("/")[-1] - ] + + if param_ref["$ref"] in IGNORED_PARAM_REFS: + continue + + param_ref = param_ref["$ref"].split("/")[-1] + param = data["components"]["parameters"][param_ref] + if "schema" in param and "$ref" in param["schema"]: schema_path_ref = param["schema"]["$ref"].split("/")[-1] param["schema"] = data["components"]["schemas"][schema_path_ref] @@ -597,9 +606,8 @@ def read_modules() -> Any: param["schema"] = data["components"]["schemas"][ common_schema_path_ref ] - params.append(param) - else: - params.append(param) + + params.append(param) # Iterate over the list of updated parameters to separate "parts" from "params" params_copy = params.copy()