Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override put_mapping definition to make index name optional. #553

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion opensearchpy/_async/client/remote_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def restore(self, body, params=None, headers=None):
: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'.")
Expand Down
2 changes: 1 addition & 1 deletion opensearchpy/client/remote_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def restore(self, body, params=None, headers=None):
: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'.")
Expand Down
16 changes: 14 additions & 2 deletions utils/generate-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# specific language governing permissions and limitations
# under the License.

import json
import os
import re
from functools import lru_cache
Expand All @@ -33,6 +34,7 @@
from pathlib import Path

import black
import deepmerge
import requests
import unasync
import urllib3
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions utils/templates/overrides/indices/put_mapping.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
}
}
Loading