GrantPrivilegeV2Async()

Grants a privilege to a role using the v2 object/privilege model.

public async Task GrantPrivilegeV2Async(GrantPrivilegeReqV2 request, CancellationToken cancellationToken = default)

Request Syntax

var request = new GrantPrivilegeReqV2
{
    RoleName = "read_only",
    Privilege = "Search",
    DatabaseName = "default",
    CollectionName = "my_collection"
};

await client.GrantPrivilegeV2Async(request);

REQUEST PARAMETERS:

  • RoleName (string) -

    The name of the role to which the privilege is granted.

  • Privilege (string) -

    The privilege to grant, e.g. "Search" or "CreateIndex".

  • DatabaseName (string) -

    The name of the database the privilege applies to.

  • CollectionName (string) -

    The name of the collection the privilege applies to.

RETURN TYPE:

Task

RETURNS:

This method does not return a value.

EXCEPTIONS:

  • MilvusException

    Thrown when the RPC fails or the server returns an error. Inspect the exception message for details.

Example

using Milvus.Client.V2;
using Milvus.Client.V2.Requests.Rbac;

using var client = new MilvusClientV2(new ConnectConfig
{
    Uri = "localhost:19530",
    Username = "root",
    Password = "Milvus"
});
await client.ConnectAsync();

await client.GrantPrivilegeV2Async(new GrantPrivilegeReqV2
{
    RoleName = "read_only",
    Privilege = "Search",
    DatabaseName = "default",
    CollectionName = "my_collection"
});

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?