Skip to content

Commit

Permalink
grant/revoke v2 optional db and collection params
Browse files Browse the repository at this point in the history
Signed-off-by: shaoting-huang <[email protected]>
  • Loading branch information
shaoting-huang committed Nov 27, 2024
1 parent 3449513 commit 45599fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion pymilvus/client/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def is_legal_db_name(db_name: Any) -> bool:
return isinstance(db_name, str)


def is_legal_collection_name(collection_name: Any) -> bool:
return isinstance(collection_name, str)


def is_legal_field_name(field_name: Any) -> bool:
return field_name and isinstance(field_name, str)

Expand Down Expand Up @@ -320,7 +324,7 @@ class ParamChecker(metaclass=Singleton):
def __init__(self) -> None:
self.check_dict = {
"db_name": is_legal_db_name,
"collection_name": is_legal_table_name,
"collection_name": is_legal_collection_name,
"alias": is_legal_table_name,
"field_name": is_legal_field_name,
"dimension": is_legal_dimension,
Expand Down
12 changes: 6 additions & 6 deletions pymilvus/orm/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ 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: str, collection_name: str):
def grant_v2(self, privilege: str, db_name: str = "", collection_name: str = ""):
"""Grant a privilege for the role
:param privilege: privilege name.
:type privilege: str
:param db_name: db name.
:param db_name: db name. Optional
:type db_name: str
:param collection_name: collection name.
:param collection_name: collection name. Optional
:type collection_name: str
:example:
Expand All @@ -196,13 +196,13 @@ def grant_v2(self, privilege: str, db_name: str, collection_name: str):
self._name, privilege, db_name, collection_name
)

def revoke_v2(self, privilege: str, db_name: str, collection_name: str):
def revoke_v2(self, privilege: str, db_name: str = "", collection_name: str = ""):
"""Revoke a privilege for the role
:param privilege: privilege name.
:type privilege: str
:param db_name: db name.
:param db_name: db name. Optional
:type db_name: str
:param collection_name: collection name.
:param collection_name: collection name. Optional
:type collection_name: str
:example:
Expand Down

0 comments on commit 45599fe

Please sign in to comment.