You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/04/08 06:16:29 UTC

[GitHub] [incubator-inlong] haifxu commented on a diff in pull request #3525: [INLONG-3524][Manager] Add 'describe' and 'list' command

haifxu commented on code in PR #3525:
URL: https://github.com/apache/incubator-inlong/pull/3525#discussion_r845769155


##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CommandList.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.github.pagehelper.PageInfo;
+import org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient;
+import org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse;
+import org.apache.inlong.manager.common.pojo.sink.SinkListResponse;
+import org.apache.inlong.manager.common.pojo.source.SourceListResponse;
+import org.apache.inlong.manager.common.pojo.stream.FullStreamResponse;
+
+import java.util.List;
+
+@Parameters(commandDescription = "Displays main information for one or more resources.")
+public class CommandList extends CommandBase {
+
+    public CommandList() {
+        super("list");
+        jcommander.addCommand("stream", new CommandList.ListStream());
+        jcommander.addCommand("group", new CommandList.ListGroup());
+        jcommander.addCommand("sink", new CommandList.ListSink());
+        jcommander.addCommand("source", new CommandList.ListSource());
+    }
+
+    @Parameter()
+    private java.util.List<String> params;
+
+    @Parameters(commandDescription = "Get stream main information")
+    private class ListStream extends CommandUtil {
+
+        @Parameter()
+        private java.util.List<String> params;
+
+        @Parameter(names = {"-g", "--group"}, required = true, description = "Get stream main information by group id.")
+        private String groupId;
+
+        @Override
+        void run() {
+            InnerInlongManagerClient managerClient = connect();
+            try {
+                List<FullStreamResponse> fullStreamResponseList = managerClient.listStreamInfo(groupId);
+                print(fullStreamResponseList, FullStreamResponse.class);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+            }
+        }
+    }
+
+    @Parameters(commandDescription = "Get group details")
+    private class ListGroup extends CommandUtil {
+
+        @Parameter()
+        private java.util.List<String> params;
+
+        @Parameter(names = {"-s", "--status"})

Review Comment:
   I will optimize it in the next feature.



##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CommandDescribe.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.github.pagehelper.PageInfo;
+import org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient;
+import org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse;
+import org.apache.inlong.manager.common.pojo.sink.SinkListResponse;
+import org.apache.inlong.manager.common.pojo.source.SourceListResponse;
+import org.apache.inlong.manager.common.pojo.stream.FullStreamResponse;
+
+import java.util.List;
+
+@Parameters(commandDescription = "Display details of one or more resources.")
+public class CommandDescribe extends CommandBase {
+
+    public CommandDescribe() {
+        super("describe");
+        jcommander.addCommand("stream", new DescribeStream());
+        jcommander.addCommand("group", new DescribeGroup());
+        jcommander.addCommand("sink", new DescribeSink());
+        jcommander.addCommand("source", new DescribeSource());
+    }
+
+    @Parameter()
+    private java.util.List<String> params;
+
+    @Parameters(commandDescription = "Get stream details")
+    private class DescribeStream extends CommandUtil {
+
+        @Parameter()
+        private java.util.List<String> params;
+
+        @Parameter(names = {"-g", "--group"}, required = true, description = "Get stream details by group id.")
+        private String groupId;
+
+        @Override
+        void run() {
+            InnerInlongManagerClient managerClient = connect();
+            List<FullStreamResponse> fullStreamResponseList = managerClient.listStreamInfo(groupId);
+            fullStreamResponseList.forEach(response -> printJson(response.getStreamInfo()));
+        }
+    }
+
+    @Parameters(commandDescription = "Get group details")
+    private class DescribeGroup extends CommandUtil {
+
+        @Parameter()
+        private java.util.List<String> params;
+
+        @Parameter(names = {"-s", "--status"}, description = "Get group details by status.")
+        private int status;

Review Comment:
   I will optimize it in the next feature.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org