milvus-logo
LFAI
< Docs
  • Java

grantRolePrivilege()

MilvusClient interface. This method grants the role privilege.

R<RpcStatus> grantRolePrivilege(GrantRolePrivilegeParam requestParam);

GrantRolePrivilegeParam

Use the GrantRolePrivilegeParam.Builder to construct a GrantRolePrivilegeParam object.

import io.milvus.param.GrantRolePrivilegeParam;
GrantRolePrivilegeParam.Builder builder = GrantRolePrivilegeParam.newBuilder();

Methods of GrantRolePrivilegeParam.Builder:

Method

Description

Parameters

withDatabaseName(String databaseName)

Set the database name.

databaseName: The database name.

withRoleName(String roleName)

Sets the roleName. RoleName cannot be empty or null.

roleName: The role name.

withObject(String object)

Sets the object. object cannot be empty or null.

object: A granted object in Milvus, such as collection, partition, and database.

withObjectName(String objectName)

Sets the objectName. objectName cannot be empty or null.

objectName: The object name.

withPrivilege(String privilege)

Sets the privilege. privilege cannot be empty or null.

privilege: A concrete permission for accessing some object.

withDatabaseName(String databaseName)

Sets the name of the target database.

databaseName: Name of an existing database.

build()

Construct a GrantRolePrivilegeParam object.

N/A

The GrantRolePrivilegeParam.Builder.build() can throw the following exceptions:

  • ParamException: error if the parameter is invalid.

Returns

This method catches all the exceptions and returns an R<RpcStatus> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and error message of the exception.

  • If the API succeeds, it returns R.Status.Success.

Example

import io.milvus.param.GrantRolePrivilegeParam;

R<RpcStatus> response = client.grantRolePrivilege(GrantRolePrivilegeParam.newBuilder()
        .withRoleName(roleName)
        .withObject(objectType)
        .withObjectName(objectName)
        .withPrivilege(privilege)
        .build());

if (response.getStatus() != R.Status.Success.getCode()) {
    throw new RuntimeException(response.getMessage());
}

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?