yashmayya commented on code in PR #13424:
URL: https://github.com/apache/kafka/pull/13424#discussion_r1144727886


##########
connect/runtime/src/test/java/org/apache/kafka/connect/util/clusters/EmbeddedConnectCluster.java:
##########
@@ -553,6 +570,54 @@ public ActiveTopicsInfo connectorTopics(String 
connectorName) {
                 "Could not read connector state. Error response: " + 
responseToString(response));
     }
 
+    /**
+     * Get the info of a connector running in this cluster (retrieved via the 
<code>GET /connectors/{connector}</code> endpoint).
+
+     * @param connectorName name of the connector
+     * @return an instance of {@link ConnectorInfo} populated with state 
information of the connector and its tasks.
+     */
+    public ConnectorInfo connectorInfo(String connectorName) {
+        ObjectMapper mapper = new ObjectMapper();
+        String url = endpointForResource(String.format("connectors/%s", 
connectorName));
+        Response response = requestGet(url);
+        try {
+            if (response.getStatus() < 
Response.Status.BAD_REQUEST.getStatusCode()) {
+                return mapper.readValue(responseToString(response), 
ConnectorInfo.class);
+            }
+        } catch (IOException e) {
+            log.error("Could not read connector info from response: {}",
+                    responseToString(response), e);
+            throw new ConnectException("Could not not parse connector info", 
e);
+        }
+        throw new ConnectRestException(response.getStatus(),
+                "Could not read connector info. Error response: " + 
responseToString(response));
+    }
+
+    /**
+     * Get the task configs of a connector running in this cluster.
+
+     * @param connectorName name of the connector
+     * @return a map from task ID (connector name + "-" + task number) to task 
config
+     */
+    public Map<String, Map<String, String>> taskConfigs(String connectorName) {
+        ObjectMapper mapper = new ObjectMapper();
+        String url = 
endpointForResource(String.format("connectors/%s/tasks-config", connectorName));

Review Comment:
   I'm a little confused as to why we have a `GET 
/connectors/{connector}/tasks` as well as a `GET 
/connectors/{connector}/tasks-config` API? Looks like the only difference 
between them is that the former returns "raw" task configurations (i.e. before 
externalized secrets are replaced using config transformers) - in which case 
the names of the two APIs don't really help to distinguish between them much 
(same with the Herder methods - `Herder::taskConfigs` and 
`Herder::tasksConfig`).



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to