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

Skip elements with titles. #777

Merged
merged 5 commits into from
Jul 18, 2024
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 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,
Comment on lines -864 to +869
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This is a breaking change for anybody that were calling the method without naming the arguments.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a miss :(

Care to open a bug, or if you have time fix the code generator?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of users affected by this is probably limited, but perhaps it's worth calling it out in the release notes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a bug for it here: #803.

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
Loading