vernedeng commented on code in PR #8488:
URL: https://github.com/apache/inlong/pull/8488#discussion_r1259461128
##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/UpdateCommand.java:
##########
@@ -205,4 +213,87 @@ void run() {
}
}
}
+
+ @Parameters(commandDescription = "Update Tenant")
+ private static class UpdateTenant extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-n", "--name"}, description = "name to be modify")
+ private String name;
+
+ @Parameter(names = {"-d", "--description"}, description = "new
description")
+ private String description;
+
+ @Override
+ void run() {
+ try {
+ InlongTenantRequest request = new InlongTenantRequest();
+ request.setName(name);
+ ClientUtils.initClientFactory();
+ InlongTenantClient tenantClient =
ClientUtils.clientFactory.getInlongTenantClient();
+ InlongTenantInfo tenantInfo =
tenantClient.getTenantByName(name);
+ if (tenantInfo == null) {
+ throw new BusinessException(name + " not exist, please
check.");
+ }
+ request.setId(tenantInfo.getId());
+ request.setDescription(description);
+ request.setVersion(tenantInfo.getVersion());
+ if (tenantClient.update(request)) {
+ System.out.println("Update user success!");
+ }
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
+
+ @Parameters(commandDescription = "Update Tenant Role")
+ private static class UpdateTenantRole extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-id", "--id"}, description = "id to be modify")
+ private Integer id;
+
+ @Parameter(names = {"-rc", "--role-code"}, description = "new role
code")
+ private String roleCode;
+
+ @Parameter(names = {"-t", "--tenant"}, description = "new tenant")
+ private String tenant;
+
+ @Override
+ void run() {
+ try {
+ TenantRoleRequest request = new TenantRoleRequest();
+ request.setId(id);
+ ClientUtils.initClientFactory();
+ InlongTenantRoleClient roleClient =
ClientUtils.clientFactory.getInlongTenantRoleClient();
+ TenantRoleInfo roleInfo = roleClient.get(id);
+ if (roleInfo == null) {
+ throw new BusinessException(id + " not exist, please
check.");
+ }
+ request.setUsername(roleInfo.getUsername());
+ request.setDisabled(roleInfo.getDisabled());
+ request.setVersion(roleInfo.getVersion());
+ if (StringUtils.isNotEmpty(roleCode)) {
+ request.setRoleCode(roleCode);
+ } else {
+ request.setRoleCode(roleInfo.getRoleCode());
+ }
+ if (StringUtils.isNotEmpty(tenant)) {
+ request.setTenant(tenant);
Review Comment:
Usually, we don't update the tenant of UserRole record.
Just create new role in the target user or change the role in the current
tenant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]