Skip to content

Commit

Permalink
Skip elements with titles. (opensearch-project#777)
Browse files Browse the repository at this point in the history
* Skip elements with titles.

Signed-off-by: dblock <dblock@amazon.com>

* Simplify and just skip by ref.

Signed-off-by: dblock <dblock@amazon.com>

* Re-generate API spec.

Signed-off-by: dblock <dblock@amazon.com>

* Do not skip alias tests.

Signed-off-by: dblock <dblock@amazon.com>

* Actually skip node_id_or_metric.

Signed-off-by: dblock <dblock@amazon.com>

---------

Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Aug 15, 2024
1 parent 6a48255 commit 3588ac1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions opensearchpy/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ async def delete(

@query_params(
"allow_no_indices",
"cluster_manager_timeout",
"error_trace",
"expand_wildcards",
"filter_path",
Expand Down Expand Up @@ -619,6 +620,8 @@ async def exists(
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
Expand Down Expand Up @@ -861,23 +864,23 @@ async def get_field_mapping(
)
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:
"""
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
Expand All @@ -898,10 +901,6 @@ async def put_alias(
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),
Expand Down
15 changes: 7 additions & 8 deletions opensearchpy/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def delete(

@query_params(
"allow_no_indices",
"cluster_manager_timeout",
"error_trace",
"expand_wildcards",
"filter_path",
Expand Down Expand Up @@ -619,6 +620,8 @@ def exists(
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
Expand Down Expand Up @@ -861,23 +864,23 @@ def get_field_mapping(
)
def put_alias(
self,
index: Any,
name: Any,
body: Any = None,
index: Any = None,
name: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
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
Expand All @@ -898,10 +901,6 @@ def put_alias(
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),
Expand Down
5 changes: 2 additions & 3 deletions test_opensearchpy/test_server/test_rest_api_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@
"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]",
Expand Down
20 changes: 14 additions & 6 deletions utils/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"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"]),
Expand Down Expand Up @@ -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]
Expand All @@ -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()
Expand Down

0 comments on commit 3588ac1

Please sign in to comment.