Override put_mapping definition to make index name optional. (#553)

Signed-off-by: dblock <dblock@amazon.com>
This commit is contained in:
Daniel (dB.) Doubrovkine
2023-10-26 11:31:13 -04:00
committed by GitHub
parent fe4b6d754c
commit ebd50e0515
5 changed files with 37 additions and 4 deletions
+1
View File
@@ -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"
+1 -1
View File
@@ -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'.")
+1 -1
View File
@@ -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'.")
+14 -2
View File
@@ -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()
@@ -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
}
}
}
]
}
}