Override put_mapping definition to make index name optional. (#553)
Signed-off-by: dblock <[email protected]>
This commit is contained in:
@@ -7,6 +7,7 @@ sphinx<7.3
|
|||||||
sphinx_rtd_theme
|
sphinx_rtd_theme
|
||||||
jinja2
|
jinja2
|
||||||
pytz
|
pytz
|
||||||
|
deepmerge
|
||||||
|
|
||||||
# No wheels for Python 3.10 yet!
|
# No wheels for Python 3.10 yet!
|
||||||
numpy; python_version<"3.10"
|
numpy; python_version<"3.10"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class RemoteStoreClient(NamespacedClient):
|
|||||||
:arg cluster_manager_timeout: Operation timeout for connection
|
:arg cluster_manager_timeout: Operation timeout for connection
|
||||||
to cluster-manager node.
|
to cluster-manager node.
|
||||||
:arg wait_for_completion: Should this request wait until the
|
: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:
|
if body in SKIP_IN_PATH:
|
||||||
raise ValueError("Empty value passed for a required argument 'body'.")
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class RemoteStoreClient(NamespacedClient):
|
|||||||
:arg cluster_manager_timeout: Operation timeout for connection
|
:arg cluster_manager_timeout: Operation timeout for connection
|
||||||
to cluster-manager node.
|
to cluster-manager node.
|
||||||
:arg wait_for_completion: Should this request wait until the
|
: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:
|
if body in SKIP_IN_PATH:
|
||||||
raise ValueError("Empty value passed for a required argument 'body'.")
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|||||||
+14
-2
@@ -25,6 +25,7 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
@@ -33,6 +34,7 @@ from operator import itemgetter
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import black
|
import black
|
||||||
|
import deepmerge
|
||||||
import requests
|
import requests
|
||||||
import unasync
|
import unasync
|
||||||
import urllib3
|
import urllib3
|
||||||
@@ -645,8 +647,7 @@ def read_modules():
|
|||||||
if all_paths_have_deprecation and x_deprecation_message is not None:
|
if all_paths_have_deprecation and x_deprecation_message is not None:
|
||||||
api.update({"deprecation_message": x_deprecation_message})
|
api.update({"deprecation_message": x_deprecation_message})
|
||||||
|
|
||||||
if namespace == "indices" and name == "put_mapping":
|
api = apply_patch(namespace, name, api)
|
||||||
api["url"]["paths"][0]["parts"]["index"].update({"required": False})
|
|
||||||
|
|
||||||
if namespace not in modules:
|
if namespace not in modules:
|
||||||
modules[namespace] = Module(namespace)
|
modules[namespace] = Module(namespace)
|
||||||
@@ -657,6 +658,17 @@ def read_modules():
|
|||||||
return 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):
|
def dump_modules(modules):
|
||||||
for mod in modules.values():
|
for mod in modules.values():
|
||||||
mod.dump()
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user