From 31cde42fa477349fee8f68bf4ef6a87b6f1fa318 Mon Sep 17 00:00:00 2001 From: sthuang <167743503+shaoting-huang@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:56:24 +0800 Subject: [PATCH] fix: [2.4] RBAC fix privilege group orm (#2367) cherry-pick from master: https://github.com/milvus-io/pymilvus/pull/2366 issue: https://github.com/milvus-io/milvus/issues/37031 Signed-off-by: shaoting-huang --- pymilvus/orm/role.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pymilvus/orm/role.py b/pymilvus/orm/role.py index 66c68dd77..989ef8c73 100644 --- a/pymilvus/orm/role.py +++ b/pymilvus/orm/role.py @@ -272,9 +272,9 @@ def create_privilege_group(self, privilege_group: str): >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.create_privilege_group(privilege_group) + >>> role.create_privilege_group(privilege_group="privilege_group") """ - return self._get_connection().create_privilege_group(self._name, privilege_group) + return self._get_connection().create_privilege_group(privilege_group) def drop_privilege_group(self, privilege_group: str): """Drop a privilege group for the role @@ -286,9 +286,9 @@ def drop_privilege_group(self, privilege_group: str): >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.drop_privilege_group(privilege_group) + >>> role.drop_privilege_group(privilege_group="privilege_group") """ - return self._get_connection().drop_privilege_group(self._name, privilege_group) + return self._get_connection().drop_privilege_group(privilege_group) def list_privilege_groups(self): """List all privilege groups for the role @@ -305,7 +305,7 @@ def list_privilege_groups(self): >>> role = Role(role_name) >>> role.list_privilege_groups() """ - return self._get_connection().list_privilege_groups(self._name) + return self._get_connection().list_privilege_groups() def add_privileges_to_group(self, privilege_group: str, privileges: list): """Add privileges to a privilege group for the role @@ -319,11 +319,10 @@ def add_privileges_to_group(self, privilege_group: str, privileges: list): >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.add_privileges_to_group(privilege_group, ["Insert", "Select"]) + >>> role.add_privileges_to_group(privilege_group="privilege_group", + >>> privileges=["Insert","Select"]) """ - return self._get_connection().add_privileges_to_group( - self._name, privilege_group, privileges - ) + return self._get_connection().add_privileges_to_group(privilege_group, privileges) def remove_privileges_from_group(self, privilege_group: str, privileges: list): """Remove privileges from a privilege group for the role @@ -337,8 +336,7 @@ def remove_privileges_from_group(self, privilege_group: str, privileges: list): >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.remove_privileges_from_group(privilege_group, ["Insert", "Select"]) + >>> role.remove_privileges_from_group(privilege_group="privilege_group", + >>> privileges=["Insert","Select"]) """ - return self._get_connection().remove_privileges_from_group( - self._name, privilege_group, privileges - ) + return self._get_connection().remove_privileges_from_group(privilege_group, privileges)