diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 9f143ef20..81d324a1c 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1868,8 +1868,8 @@ def grant_privilege_v2( self, role_name: str, privilege: str, + collection_name: str, db_name: Optional[str] = None, - collection_name: Optional[str] = None, timeout: Optional[float] = None, **kwargs, ): @@ -1888,8 +1888,8 @@ def revoke_privilege_v2( self, role_name: str, privilege: str, + collection_name: str, db_name: Optional[str] = None, - collection_name: Optional[str] = None, timeout: Optional[float] = None, **kwargs, ): diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index ef99ab213..942f30a26 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -1337,12 +1337,11 @@ def operate_privilege_v2_request( check_pass_param( role_name=role_name, privilege=privilege, + collection_name=collection_name, operate_privilege_type=operate_privilege_type, ) if db_name: check_pass_param(db_name=db_name) - if collection_name: - check_pass_param(collection_name=collection_name) return milvus_types.OperatePrivilegeV2Request( role=milvus_types.RoleEntity(name=role_name), grantor=milvus_types.GrantorEntity( diff --git a/pymilvus/milvus_client/milvus_client.py b/pymilvus/milvus_client/milvus_client.py index c05a519a4..4f090fe17 100644 --- a/pymilvus/milvus_client/milvus_client.py +++ b/pymilvus/milvus_client/milvus_client.py @@ -1008,8 +1008,8 @@ def grant_privilege_v2( self, role_name: str, privilege: str, + collection_name: str, db_name: Optional[str] = None, - collection_name: Optional[str] = None, timeout: Optional[float] = None, **kwargs, ): @@ -1017,8 +1017,8 @@ def grant_privilege_v2( conn.grant_privilege_v2( role_name, privilege, + collection_name, db_name=db_name, - collection_name=collection_name, timeout=timeout, **kwargs, ) @@ -1027,8 +1027,8 @@ def revoke_privilege_v2( self, role_name: str, privilege: str, + collection_name: str, db_name: Optional[str] = None, - collection_name: Optional[str] = None, timeout: Optional[float] = None, **kwargs, ): @@ -1036,8 +1036,8 @@ def revoke_privilege_v2( conn.revoke_privilege_v2( role_name, privilege, + collection_name, db_name=db_name, - collection_name=collection_name, timeout=timeout, **kwargs, ) diff --git a/pymilvus/orm/role.py b/pymilvus/orm/role.py index 313231ad4..21e1b935f 100644 --- a/pymilvus/orm/role.py +++ b/pymilvus/orm/role.py @@ -178,48 +178,50 @@ def revoke(self, object: str, object_name: str, privilege: str, db_name: str = " self._name, object, object_name, privilege, db_name ) - def grant_v2( - self, privilege: str, db_name: Optional[str] = None, collection_name: Optional[str] = None - ): + def grant_v2(self, privilege: str, collection_name: str, db_name: Optional[str] = None): """Grant a privilege for the role :param privilege: privilege name. :type privilege: str - :param db_name: db name. Optional - :type db_name: str - :param collection_name: collection name. Optional + :param collection_name: collection name. :type collection_name: str + :param db_name: db name. Optional. If None, use the default db. + :type db_name: str :example: >>> from pymilvus import connections >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.grant_v2("Insert", db_name, collection_name) + >>> role.grant_v2("Insert", collection_name, db_name=db_name) """ return self._get_connection().grant_privilege_v2( - self._name, privilege, db_name=db_name, collection_name=collection_name + self._name, + privilege, + collection_name, + db_name=db_name, ) - def revoke_v2( - self, privilege: str, db_name: Optional[str] = None, collection_name: Optional[str] = None - ): + def revoke_v2(self, privilege: str, collection_name: str, db_name: Optional[str] = None): """Revoke a privilege for the role :param privilege: privilege name. :type privilege: str - :param db_name: db name. Optional - :type db_name: str - :param collection_name: collection name. Optional + :param collection_name: collection name. :type collection_name: str + :param db_name: db name. Optional. If None, use the default db. + :type db_name: str :example: >>> from pymilvus import connections >>> from pymilvus.orm.role import Role >>> connections.connect() >>> role = Role(role_name) - >>> role.revoke_v2("Insert", db_name, collection_name) + >>> role.revoke_v2("Insert", collection_name, db_name=db_name) """ return self._get_connection().revoke_privilege_v2( - self._name, privilege, db_name=db_name, collection_name=collection_name + self._name, + privilege, + collection_name, + db_name=db_name, ) def list_grant(self, object: str, object_name: str, db_name: str = ""): diff --git a/pymilvus/orm/utility.py b/pymilvus/orm/utility.py index 7844dbb66..e94866156 100644 --- a/pymilvus/orm/utility.py +++ b/pymilvus/orm/utility.py @@ -774,7 +774,7 @@ def list_aliases(collection_name: str, timeout: Optional[float] = None, using: s ['tom'] """ conn = _get_connection(using) - resp = conn.describe_collection(collection_name, timeout=timeout) + resp = conn.list_aliases(collection_name, timeout=timeout) return resp["aliases"]