diff --git a/CHANGELOG.md b/CHANGELOG.md index c89dbbbd7..25443c331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/opensearchpy/_async/client/security.py b/opensearchpy/_async/client/security.py index e24e293f2..eff252eef 100644 --- a/opensearchpy/_async/client/security.py +++ b/opensearchpy/_async/client/security.py @@ -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): @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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/", @@ -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", @@ -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", @@ -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", diff --git a/opensearchpy/client/security.py b/opensearchpy/client/security.py index b2945fc0b..f6002e43b 100644 --- a/opensearchpy/client/security.py +++ b/opensearchpy/client/security.py @@ -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): @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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", @@ -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), @@ -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/", @@ -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", @@ -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", @@ -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", diff --git a/utils/generate_api.py b/utils/generate_api.py index 6d6fa4ead..4ba41c15c 100644 --- a/utils/generate_api.py +++ b/utils/generate_api.py @@ -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}) diff --git a/utils/templates/base b/utils/templates/base index fa0ba2137..7e6be8751 100644 --- a/utils/templates/base +++ b/utils/templates/base @@ -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 %}