From 783869d3db4b59e21dd7ea879144a7595d53d898 Mon Sep 17 00:00:00 2001 From: saimedhi Date: Thu, 14 Dec 2023 13:46:34 -0800 Subject: [PATCH] Updated the get_policy API in the index_management plugin to allow the policy_id argument as optional Signed-off-by: saimedhi --- CHANGELOG.md | 1 + opensearchpy/_async/plugins/index_management.py | 6 ++---- opensearchpy/plugins/index_management.py | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab691fae..ca900448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a log collection guide ([#579](https://github.com/opensearch-project/opensearch-py/pull/579)) - Added GHA release ([#614](https://github.com/opensearch-project/opensearch-py/pull/614)) ### Changed +- Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) ### Deprecated ### Removed - Removed unnecessary `# -*- coding: utf-8 -*-` headers from .py files ([#615](https://github.com/opensearch-project/opensearch-py/pull/615), [#617](https://github.com/opensearch-project/opensearch-py/pull/617)) diff --git a/opensearchpy/_async/plugins/index_management.py b/opensearchpy/_async/plugins/index_management.py index cf15c4eb..c5084a37 100644 --- a/opensearchpy/_async/plugins/index_management.py +++ b/opensearchpy/_async/plugins/index_management.py @@ -56,15 +56,13 @@ async def add_policy( @query_params() async def get_policy( - self, policy: Any, params: Any = None, headers: Any = None + self, policy: Any = None, params: Any = None, headers: Any = None ) -> Any: """ - Gets the policy by `policy_id`. + Gets the policy by `policy_id`; returns all policies if no policy_id is provided. :arg policy: The name of the policy """ - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") return await self.transport.perform_request( "GET", diff --git a/opensearchpy/plugins/index_management.py b/opensearchpy/plugins/index_management.py index 0683b006..2d3551ab 100644 --- a/opensearchpy/plugins/index_management.py +++ b/opensearchpy/plugins/index_management.py @@ -55,14 +55,14 @@ def add_policy( ) @query_params() - def get_policy(self, policy: Any, params: Any = None, headers: Any = None) -> Any: + def get_policy( + self, policy: Any = None, params: Any = None, headers: Any = None + ) -> Any: """ - Gets the policy by `policy_id`. + Gets the policy by `policy_id`; returns all policies if no policy_id is provided. :arg policy: The name of the policy """ - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") return self.transport.perform_request( "GET",