milvus-logo
LFAI
< Docs
  • Java

createRole()

This operation creates a custom role.

public void createRole(CreateRoleReq request)

Request Syntax

createRole(CreateRoleReq.builder()
    .roleName(String roleName)
    .build()
)

BUILDER METHODS:

  • roleName(String roleName)

    The name of the role to create.

RETURNS:

void

EXCEPTIONS:

  • MilvusClientExceptions

    This exception will be raised when any error occurs during this operation.

Example

import io.milvus.v2.client.ConnectConfig
import io.milvus.v2.client.MilvusClientV2
import io.milvus.v2.service.rbac.request.CreateRoleReq

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
        .uri("http://localhost:19530")
        .token("root:Milvus")
        .build();
        
MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. Create a role
CreateRoleReq createRoleReq = CreateRoleReq.builder()
        .roleName("read_only")
        .build();
        
client.createRole(createRoleReq);

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?