haifxu commented on code in PR #8488:
URL: https://github.com/apache/inlong/pull/8488#discussion_r1259116031
##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java:
##########
@@ -267,4 +273,76 @@ void run() {
}
}
}
+
+ @Parameters(commandDescription = "Create tenant")
+ private static class CreateTenant extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-n", "--name"}, description = "tenant name")
+ private String name;
+
+ @Parameter(names = {"-d", "--description"}, description = "tenant
description")
+ private String description;
+
+ @Parameter(names = {"-v", "--version"}, description = "tenant version
number")
+ private Integer version;
+
+ @Override
+ void run() {
+ try {
+ InlongTenantRequest request = new InlongTenantRequest();
+ request.setName(name);
+ request.setDescription(description);
+ request.setVersion(version);
+ ClientUtils.initClientFactory();
+ InlongTenantClient tenantClient =
ClientUtils.clientFactory.getInlongTenantClient();
+ Integer userId = tenantClient.save(request);
+ if (userId != null) {
+ System.out.println("Create tenant success! ID: " + userId);
+ }
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
+
+ @Parameters(commandDescription = "Create user")
Review Comment:
Create tenant role
##########
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 = {"-role-code", "--role-code"}, description = "new
role code")
Review Comment:
`-rs` may be better for `--role-code`.
##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/pojo/TenantInfo.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.cli.pojo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+public class TenantInfo {
Review Comment:
Is this class referenced?
##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/pojo/TenantRoleInfo.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.cli.pojo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+public class TenantRoleInfo {
Review Comment:
ditto
--
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]