From 9b60b20f5d9fcfef0d93f5adf33bb781dfb21ae3 Mon Sep 17 00:00:00 2001 From: "xushuang.hu" <108672767+lentitude2tk@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:10:39 +0800 Subject: [PATCH] RevokeRolePrivilegeParam support dbName parameter (#1234) Signed-off-by: lentitude2tk --- .../client/AbstractMilvusGrpcClient.java | 18 +++++++++++------- .../param/role/RevokeRolePrivilegeParam.java | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java b/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java index 4a5d0c6dc..21c7a1cd3 100644 --- a/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java +++ b/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java @@ -2557,15 +2557,19 @@ public R revokeRolePrivilege(RevokeRolePrivilegeParam requestParam) { String title = String.format("RevokeRolePrivilegeRequest roleName:%s", requestParam.getRoleName()); try { + GrantEntity.Builder builder = GrantEntity.newBuilder() + .setRole(RoleEntity.newBuilder().setName(requestParam.getRoleName()).build()) + .setObjectName(requestParam.getObjectName()) + .setObject(ObjectEntity.newBuilder().setName(requestParam.getObject()).build()) + .setGrantor(GrantorEntity.newBuilder() + .setPrivilege(PrivilegeEntity.newBuilder().setName(requestParam.getPrivilege()).build()).build()); + if (StringUtils.isNotEmpty(requestParam.getDatabaseName())) { + builder.setDbName(requestParam.getDatabaseName()); + } + OperatePrivilegeRequest request = OperatePrivilegeRequest.newBuilder() .setType(OperatePrivilegeType.Revoke) - .setEntity(GrantEntity.newBuilder() - .setRole(RoleEntity.newBuilder().setName(requestParam.getRoleName()).build()) - .setObjectName(requestParam.getObjectName()) - .setObject(ObjectEntity.newBuilder().setName(requestParam.getObject()).build()) - .setGrantor(GrantorEntity.newBuilder() - .setPrivilege(PrivilegeEntity.newBuilder().setName(requestParam.getPrivilege()).build()).build()) - .build()) + .setEntity(builder.build()) .build(); Status response = blockingStub().operatePrivilege(request); diff --git a/sdk-core/src/main/java/io/milvus/param/role/RevokeRolePrivilegeParam.java b/sdk-core/src/main/java/io/milvus/param/role/RevokeRolePrivilegeParam.java index 8daf4426c..a17606d00 100644 --- a/sdk-core/src/main/java/io/milvus/param/role/RevokeRolePrivilegeParam.java +++ b/sdk-core/src/main/java/io/milvus/param/role/RevokeRolePrivilegeParam.java @@ -37,11 +37,14 @@ public class RevokeRolePrivilegeParam { private final String privilege; + private final String databaseName; + private RevokeRolePrivilegeParam(@NonNull RevokeRolePrivilegeParam.Builder builder) { this.roleName = builder.roleName; this.object = builder.object; this.objectName = builder.objectName; this.privilege = builder.privilege; + this.databaseName = builder.databaseName; } public static RevokeRolePrivilegeParam.Builder newBuilder() { @@ -56,11 +59,23 @@ public static final class Builder { private String object; private String objectName; private String privilege; + private String databaseName; private Builder() { } + /** + * Sets the databaseName. databaseName cannot be null. + * + * @param databaseName databaseName + * @return Builder + */ + public RevokeRolePrivilegeParam.Builder withDatabaseName(String databaseName) { + this.databaseName = databaseName; + return this; + } + /** * Sets the roleName. RoleName cannot be empty or null. *