milvus-logo
LFAI
< Docs
  • Python

grant()

This operation grants a privilege to the current role.

notes

To complete this operation, you need to enable authentication on your Milvus instance. For details, refer to Authenticate User Access.

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, and possible options are Collection, Global, and User. 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.

    Applicable privileges vary with the specified object. For details, refer to refer to Users & Roles.

    notes

    • To grant all privileges to a kind of object, like Collection, Global, User, use for privilege name.

    • When object is set to Global, setting privilege to is not equivalent to setting it to All. The All 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")

Feedback

Was this page helpful?