{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/comments/103578205","pull_request_review_id":24368058,"id":103578205,"diff_hunk":"@@ -0,0 +1,169 @@\n+package com.mesosphere.sdk.kafka.api;\n+\n+import com.mesosphere.sdk.kafka.cmd.CmdExecutor;\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.json.JSONArray;\n+import org.json.JSONObject;\n+\n+import javax.ws.rs.GET;\n+import javax.ws.rs.Path;\n+import javax.ws.rs.DELETE;\n+import javax.ws.rs.POST;\n+import javax.ws.rs.PUT;\n+import javax.ws.rs.PathParam;\n+import javax.ws.rs.QueryParam;\n+import javax.ws.rs.core.MediaType;\n+import javax.ws.rs.core.Response;\n+\n+import java.util.Arrays;\n+import java.util.List;\n+\n+/**\n+ * Topic Resource executing commands through command executor.\n+ * Kafka package should also be deployed with framework to enable Kafka commands.\n+ */\n+\n+@Path(\"/v1/topics\")\n+public class TopicResource {\n+    private static final Log log = LogFactory.getLog(TopicResource.class);\n+\n+    private final KafkaZKClient kafkaZkClient;\n+    private final CmdExecutor cmdExecutor;\n+\n+    public TopicResource(CmdExecutor cmdExecutor, KafkaZKClient kafkaZkClient) {\n+        this.kafkaZkClient = kafkaZkClient;\n+        this.cmdExecutor = cmdExecutor;\n+    }\n+\n+    @GET\n+    public Response topics() {\n+        try {\n+            return Response.ok(kafkaZkClient.listTopics(), MediaType.APPLICATION_JSON).build();\n+        } catch (Exception ex) {\n+            log.error(\"Failed to fetch topics with exception: \" + ex);\n+            return Response.serverError().build();\n+        }\n+    }\n+\n+    @GET\n+    @Path(\"/{name}\")\n+    public Response getTopic(@PathParam(\"name\") String topicName) {\n+        try {\n+            return Response.ok(kafkaZkClient.getTopic(topicName), MediaType.APPLICATION_JSON).build();\n+        } catch (Exception ex) {\n+            log.error(\"Failed to fetch topic: \" + topicName + \" with exception: \" + ex);\n+            return Response.serverError().build();\n+        }\n+    }\n+\n+    @POST\n+    @Path(\"/create\")\n+    public Response createTopic(\n+            @QueryParam(\"name\") String name,\n+            @QueryParam(\"partitions\") String partitionCount,\n+            @QueryParam(\"replication\") String replicationFactor) {\n+        try {\n+            int partCount = Integer.parseInt(partitionCount);\n+            int replFactor = Integer.parseInt(replicationFactor);\n+            JSONObject result = cmdExecutor.createTopic(name, partCount, replFactor);\n+            return Response.ok(result.toString(), MediaType.APPLICATION_JSON).build();\n+        } catch (Exception ex) {\n+            log.error(\"Failed to create topic: \" + name + \" with exception: \" + ex);\n+            return Response.serverError().build();\n+        }\n+    }\n+\n+    @GET\n+    @Path(\"/unavailable_partitions\")","path":"frameworks/kafka/src/main/java/com/mesosphere/sdk/kafka/api/TopicResource.java","position":78,"original_position":78,"commit_id":"0957d15aa7aca71fa915122efc0b3ba11c180547","original_commit_id":"0957d15aa7aca71fa915122efc0b3ba11c180547","user":{"login":"mrbrowning","id":3465239,"avatar_url":"https://avatars3.githubusercontent.com/u/3465239?v=3","gravatar_id":"","url":"https://api.github.com/users/mrbrowning","html_url":"https://github.com/mrbrowning","followers_url":"https://api.github.com/users/mrbrowning/followers","following_url":"https://api.github.com/users/mrbrowning/following{/other_user}","gists_url":"https://api.github.com/users/mrbrowning/gists{/gist_id}","starred_url":"https://api.github.com/users/mrbrowning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrbrowning/subscriptions","organizations_url":"https://api.github.com/users/mrbrowning/orgs","repos_url":"https://api.github.com/users/mrbrowning/repos","events_url":"https://api.github.com/users/mrbrowning/events{/privacy}","received_events_url":"https://api.github.com/users/mrbrowning/received_events","type":"User","site_admin":false},"body":"It is slightly unfortunate that a topic can never be named `unavailable_partitions` without stepping on toes here... @nickbp what do you think?","created_at":"2017-02-28T23:33:27Z","updated_at":"2017-02-28T23:34:42Z","html_url":"https://github.com/mesosphere/dcos-commons/pull/610#discussion_r103578205","pull_request_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/comments/103578205"},"html":{"href":"https://github.com/mesosphere/dcos-commons/pull/610#discussion_r103578205"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610"}}},"pull_request":{"url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610","id":108111796,"html_url":"https://github.com/mesosphere/dcos-commons/pull/610","diff_url":"https://github.com/mesosphere/dcos-commons/pull/610.diff","patch_url":"https://github.com/mesosphere/dcos-commons/pull/610.patch","issue_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/610","number":610,"state":"open","locked":false,"title":"[KAFKA] Add TopicController endpoint API and Command Executor class","user":{"login":"mbdcos","id":22774486,"avatar_url":"https://avatars1.githubusercontent.com/u/22774486?v=3","gravatar_id":"","url":"https://api.github.com/users/mbdcos","html_url":"https://github.com/mbdcos","followers_url":"https://api.github.com/users/mbdcos/followers","following_url":"https://api.github.com/users/mbdcos/following{/other_user}","gists_url":"https://api.github.com/users/mbdcos/gists{/gist_id}","starred_url":"https://api.github.com/users/mbdcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbdcos/subscriptions","organizations_url":"https://api.github.com/users/mbdcos/orgs","repos_url":"https://api.github.com/users/mbdcos/repos","events_url":"https://api.github.com/users/mbdcos/events{/privacy}","received_events_url":"https://api.github.com/users/mbdcos/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-02-27T13:16:27Z","updated_at":"2017-02-28T23:34:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e661425194d5cf95b0abc158dbdafedc9478f16","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610/commits","review_comments_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610/comments","review_comment_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/610/comments","statuses_url":"https://api.github.com/repos/mesosphere/dcos-commons/statuses/0957d15aa7aca71fa915122efc0b3ba11c180547","head":{"label":"mesosphere:kafka594","ref":"kafka594","sha":"0957d15aa7aca71fa915122efc0b3ba11c180547","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars3.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":60286497,"name":"dcos-commons","full_name":"mesosphere/dcos-commons","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars3.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/dcos-commons","description":null,"fork":false,"url":"https://api.github.com/repos/mesosphere/dcos-commons","forks_url":"https://api.github.com/repos/mesosphere/dcos-commons/forks","keys_url":"https://api.github.com/repos/mesosphere/dcos-commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/dcos-commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/dcos-commons/teams","hooks_url":"https://api.github.com/repos/mesosphere/dcos-commons/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/dcos-commons/events","assignees_url":"https://api.github.com/repos/mesosphere/dcos-commons/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/dcos-commons/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/dcos-commons/tags","blobs_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/dcos-commons/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/dcos-commons/languages","stargazers_url":"https://api.github.com/repos/mesosphere/dcos-commons/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/dcos-commons/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/dcos-commons/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/dcos-commons/subscription","commits_url":"https://api.github.com/repos/mesosphere/dcos-commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/dcos-commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/dcos-commons/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/dcos-commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/dcos-commons/merges","archive_url":"https://api.github.com/repos/mesosphere/dcos-commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/dcos-commons/downloads","issues_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/dcos-commons/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/dcos-commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/dcos-commons/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/dcos-commons/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/dcos-commons/deployments","created_at":"2016-06-02T18:09:08Z","updated_at":"2017-02-21T10:53:48Z","pushed_at":"2017-02-28T23:15:05Z","git_url":"git://github.com/mesosphere/dcos-commons.git","ssh_url":"git@github.com:mesosphere/dcos-commons.git","clone_url":"https://github.com/mesosphere/dcos-commons.git","svn_url":"https://github.com/mesosphere/dcos-commons","homepage":"https://mesosphere.github.io/dcos-commons/","size":25765,"stargazers_count":49,"watchers_count":49,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":35,"forks":37,"open_issues":35,"watchers":49,"default_branch":"master"}},"base":{"label":"mesosphere:master","ref":"master","sha":"813bfa5f3e4cb9d1ec856cf131bf0d269e3701e1","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars3.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":60286497,"name":"dcos-commons","full_name":"mesosphere/dcos-commons","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars3.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/dcos-commons","description":null,"fork":false,"url":"https://api.github.com/repos/mesosphere/dcos-commons","forks_url":"https://api.github.com/repos/mesosphere/dcos-commons/forks","keys_url":"https://api.github.com/repos/mesosphere/dcos-commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/dcos-commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/dcos-commons/teams","hooks_url":"https://api.github.com/repos/mesosphere/dcos-commons/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/dcos-commons/events","assignees_url":"https://api.github.com/repos/mesosphere/dcos-commons/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/dcos-commons/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/dcos-commons/tags","blobs_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/dcos-commons/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/dcos-commons/languages","stargazers_url":"https://api.github.com/repos/mesosphere/dcos-commons/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/dcos-commons/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/dcos-commons/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/dcos-commons/subscription","commits_url":"https://api.github.com/repos/mesosphere/dcos-commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/dcos-commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/dcos-commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/dcos-commons/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/dcos-commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/dcos-commons/merges","archive_url":"https://api.github.com/repos/mesosphere/dcos-commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/dcos-commons/downloads","issues_url":"https://api.github.com/repos/mesosphere/dcos-commons/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/dcos-commons/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/dcos-commons/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/dcos-commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/dcos-commons/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/dcos-commons/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/dcos-commons/deployments","created_at":"2016-06-02T18:09:08Z","updated_at":"2017-02-21T10:53:48Z","pushed_at":"2017-02-28T23:15:05Z","git_url":"git://github.com/mesosphere/dcos-commons.git","ssh_url":"git@github.com:mesosphere/dcos-commons.git","clone_url":"https://github.com/mesosphere/dcos-commons.git","svn_url":"https://github.com/mesosphere/dcos-commons","homepage":"https://mesosphere.github.io/dcos-commons/","size":25765,"stargazers_count":49,"watchers_count":49,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":35,"forks":37,"open_issues":35,"watchers":49,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610"},"html":{"href":"https://github.com/mesosphere/dcos-commons/pull/610"},"issue":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/issues/610"},"comments":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/issues/610/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/pulls/610/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/dcos-commons/statuses/0957d15aa7aca71fa915122efc0b3ba11c180547"}}}}
{"actor":{"display_login":"mrbrowning"}}