grant()
This operation grants a privilege to the current role.
Request Syntax
grant(
object: str,
object_name: str,
privilege: str,
db_name: str
)
PARAMETERS:
-
object (string)
[REQUIRED]
The type of the object to grant the privilege.
The value is case-sensitive. For details, refer to Users & Roles.
-
object_name (string)
[REQUIRED]
The name of a target object of the type specified in object.
It can be a collection name, a user name, or a wild card (*).
-
privilege (string)
[REQUIRED]
The name of the privilege to grant.
For details, refer to Users & Roles.
📘NotesTo grant all privileges to a kind of object, like Collection, Global, User, use
*
for privilege name.When
object
is set toGlobal
, settingprivilege
to*
is not equivalent to setting it toAll
. TheAll
privilege includes all permissions, including any collection and user object.
-
db_name (string)
The name of a database the object belongs to. If left unspecified, the default database applies.
RETURN TYPE:
NoneType
RETURNS:
None
EXCEPTIONS:
-
MilvusException
This exception will be raised when any error occurs during this operation.
Examples
from pymilvus import Role
# Get an existing role
role = Role(role_name)
# Grant a privilege to the current role
role.grant("Collection", collection_name, "Insert")
Related operations
The following operations are related to grant()
: