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

Adjust Generator for Updated OpenSearch API Spec #738

Merged
merged 1 commit into from
May 1, 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 @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Updated code generator to use native OpenAPI specification ([#721](https://github.com/opensearch-project/opensearch-py/pull/721))
### Updated APIs
- Updated opensearch-py APIs to reflect [opensearch-api-specification@d3783f1](https://github.com/opensearch-project/opensearch-api-specification/commit/d3783f1200fdc5799eba861842ee611f2c7e30e7)
- Updated opensearch-py APIs to reflect [opensearch-api-specification@3ed6aaf](https://github.com/opensearch-project/opensearch-api-specification/commit/3ed6aaff0ce51af3aad00fe57c34d1a7056bd6d1)
- Updated opensearch-py APIs to reflect [opensearch-api-specification@af4a34f](https://github.com/opensearch-project/opensearch-api-specification/commit/af4a34f9847d36709b5a394be7c76fda4649ccc8)
- Updated opensearch-py APIs to reflect [opensearch-api-specification@e02c076](https://github.com/opensearch-project/opensearch-api-specification/commit/e02c076ef63f7a9b650ca1416380120cc640620a)
Expand Down
15 changes: 14 additions & 1 deletion opensearchpy/_async/client/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from typing import Any

from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params


class SecurityClient(NamespacedClient):
Expand Down Expand Up @@ -244,6 +244,7 @@ async def patch_action_group(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "actiongroups", action_group),
Expand Down Expand Up @@ -277,6 +278,7 @@ async def patch_action_groups(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/actiongroups",
Expand Down Expand Up @@ -439,6 +441,7 @@ async def patch_user(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "internalusers", username),
Expand Down Expand Up @@ -472,6 +475,7 @@ async def patch_users(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/internalusers",
Expand Down Expand Up @@ -631,6 +635,7 @@ async def patch_role(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "roles", role),
Expand Down Expand Up @@ -664,6 +669,7 @@ async def patch_roles(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/roles",
Expand Down Expand Up @@ -826,6 +832,7 @@ async def patch_role_mapping(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "rolesmapping", role),
Expand Down Expand Up @@ -859,6 +866,7 @@ async def patch_role_mappings(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/rolesmapping",
Expand Down Expand Up @@ -1018,6 +1026,7 @@ async def patch_tenant(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "tenants", tenant),
Expand Down Expand Up @@ -1051,6 +1060,7 @@ async def patch_tenants(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/tenants/",
Expand Down Expand Up @@ -1145,6 +1155,7 @@ async def patch_configuration(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/securityconfig",
Expand Down Expand Up @@ -1468,6 +1479,7 @@ async def patch_audit_configuration(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/audit",
Expand Down Expand Up @@ -1501,6 +1513,7 @@ async def patch_distinguished_names(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return await self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/nodesdn",
Expand Down
15 changes: 14 additions & 1 deletion opensearchpy/client/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from typing import Any

from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params


class SecurityClient(NamespacedClient):
Expand Down Expand Up @@ -244,6 +244,7 @@ def patch_action_group(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "actiongroups", action_group),
Expand Down Expand Up @@ -277,6 +278,7 @@ def patch_action_groups(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/actiongroups",
Expand Down Expand Up @@ -439,6 +441,7 @@ def patch_user(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "internalusers", username),
Expand Down Expand Up @@ -472,6 +475,7 @@ def patch_users(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/internalusers",
Expand Down Expand Up @@ -631,6 +635,7 @@ def patch_role(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "roles", role),
Expand Down Expand Up @@ -664,6 +669,7 @@ def patch_roles(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/roles",
Expand Down Expand Up @@ -826,6 +832,7 @@ def patch_role_mapping(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "rolesmapping", role),
Expand Down Expand Up @@ -859,6 +866,7 @@ def patch_role_mappings(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/rolesmapping",
Expand Down Expand Up @@ -1018,6 +1026,7 @@ def patch_tenant(
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
_make_path("_plugins", "_security", "api", "tenants", tenant),
Expand Down Expand Up @@ -1051,6 +1060,7 @@ def patch_tenants(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/tenants/",
Expand Down Expand Up @@ -1145,6 +1155,7 @@ def patch_configuration(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/securityconfig",
Expand Down Expand Up @@ -1468,6 +1479,7 @@ def patch_audit_configuration(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/audit",
Expand Down Expand Up @@ -1501,6 +1513,7 @@ def patch_distinguished_names(
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"PATCH",
"/_plugins/_security/api/nodesdn",
Expand Down
27 changes: 18 additions & 9 deletions utils/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,24 @@ def read_modules() -> Any:
]["required"]
}
)
q = data["components"]["requestBodies"][requestbody_ref]["content"][
"application/json"
][
"schema"
] # pylint: disable=invalid-name
if "description" in q:
body.update({"description": q["description"]})
if "x-serialize" in q:
body.update({"serialize": q["x-serialize"]})

if (
"application/x-ndjson"
in data["components"]["requestBodies"][requestbody_ref][
"content"
]
):
requestbody_schema = data["components"]["requestBodies"][
requestbody_ref
]["content"]["application/x-ndjson"]["schema"]
body.update({"serialize": True})
else:
requestbody_schema = data["components"]["requestBodies"][
requestbody_ref
]["content"]["application/json"]["schema"]

if "description" in requestbody_schema:
body.update({"description": requestbody_schema["description"]})

api.update({"body": body})

Expand Down
2 changes: 1 addition & 1 deletion utils/templates/base
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% endif %}
{% include "substitutions" %}
{% include "required" %}
{% if api.body.serialize == "bulk" %}
{% if api.body.serialize %}
body = _bulk_body(self.transport.serializer, body)
{% endif %}
{% block request %}
Expand Down
Loading