diff --git a/dev-requirements.txt b/dev-requirements.txt index 04cfb3e8..a79a1a0b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -7,6 +7,7 @@ sphinx<7.3 sphinx_rtd_theme jinja2 pytz +deepmerge # No wheels for Python 3.10 yet! numpy; python_version<"3.10" diff --git a/opensearchpy/_async/client/remote_store.py b/opensearchpy/_async/client/remote_store.py index 731d1233..457369ac 100644 --- a/opensearchpy/_async/client/remote_store.py +++ b/opensearchpy/_async/client/remote_store.py @@ -30,7 +30,7 @@ class RemoteStoreClient(NamespacedClient): :arg cluster_manager_timeout: Operation timeout for connection to cluster-manager node. :arg wait_for_completion: Should this request wait until the - operation has completed before returning. (default: false) + operation has completed before returning. Default is false. """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") diff --git a/opensearchpy/client/remote_store.py b/opensearchpy/client/remote_store.py index a8fcfe06..38d8a1c6 100644 --- a/opensearchpy/client/remote_store.py +++ b/opensearchpy/client/remote_store.py @@ -30,7 +30,7 @@ class RemoteStoreClient(NamespacedClient): :arg cluster_manager_timeout: Operation timeout for connection to cluster-manager node. :arg wait_for_completion: Should this request wait until the - operation has completed before returning. (default: false) + operation has completed before returning. Default is false. """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") diff --git a/utils/generate-api.py b/utils/generate-api.py index 2cc95013..a4032765 100644 --- a/utils/generate-api.py +++ b/utils/generate-api.py @@ -25,6 +25,7 @@ # specific language governing permissions and limitations # under the License. +import json import os import re from functools import lru_cache @@ -33,6 +34,7 @@ from operator import itemgetter from pathlib import Path import black +import deepmerge import requests import unasync import urllib3 @@ -645,8 +647,7 @@ def read_modules(): if all_paths_have_deprecation and x_deprecation_message is not None: api.update({"deprecation_message": x_deprecation_message}) - if namespace == "indices" and name == "put_mapping": - api["url"]["paths"][0]["parts"]["index"].update({"required": False}) + api = apply_patch(namespace, name, api) if namespace not in modules: modules[namespace] = Module(namespace) @@ -657,6 +658,17 @@ def read_modules(): return modules +def apply_patch(namespace, name, api): + override_file_path = ( + CODE_ROOT / "utils/templates/overrides" / namespace / f"{name}.json" + ) + if os.path.exists(override_file_path): + with open(override_file_path) as f: + override_json = json.load(f) + api = deepmerge.always_merger.merge(api, override_json) + return api + + def dump_modules(modules): for mod in modules.values(): mod.dump() diff --git a/utils/templates/overrides/indices/put_mapping.json b/utils/templates/overrides/indices/put_mapping.json new file mode 100644 index 00000000..4409c446 --- /dev/null +++ b/utils/templates/overrides/indices/put_mapping.json @@ -0,0 +1,20 @@ +{ + "url": { + "paths": [ + { + "path": "/{index}/_mapping", + "methods": [ + "POST", + "PUT" + ], + "parts": { + "index": { + "type": "string", + "description": "Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.", + "required": false + } + } + } + ] + } +} \ No newline at end of file