{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/harbor/pulls/comments/178499742","pull_request_review_id":108562837,"id":178499742,"diff_hunk":"@@ -0,0 +1,162 @@\n+// Copyright (c) 2017 VMware, Inc. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//    http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package api\n+\n+import (\n+\t\"fmt\"\n+\t\"net/http\"\n+\n+\t\"github.com/vmware/harbor/src/common\"\n+\t\"github.com/vmware/harbor/src/common/dao\"\n+\t\"github.com/vmware/harbor/src/common/dao/group\"\n+\t\"github.com/vmware/harbor/src/common/models\"\n+\t\"github.com/vmware/harbor/src/common/utils/log\"\n+\t\"github.com/vmware/harbor/src/ui/auth\"\n+)\n+\n+// UserGroupAPI ...\n+type UserGroupAPI struct {\n+\tBaseController\n+\tid            int\n+\tcurrentUserID int\n+}\n+\n+// Prepare validates the URL and parms\n+func (uga *UserGroupAPI) Prepare() {\n+\tuga.BaseController.Prepare()\n+\tif !uga.SecurityCtx.IsAuthenticated() {\n+\t\tuga.HandleUnauthorized()\n+\t\treturn\n+\t}\n+\tuser, err := dao.GetUser(models.User{\n+\t\tUsername: uga.SecurityCtx.GetUsername(),\n+\t})\n+\tif err != nil {\n+\t\tuga.HandleInternalServerError(\n+\t\t\tfmt.Sprintf(\"failed to get user %s: %v\",\n+\t\t\t\tuga.SecurityCtx.GetUsername(), err))\n+\t\treturn\n+\t}\n+\tuga.currentUserID = user.UserID\n+\n+\tugid, err := uga.GetInt64FromPath(\":ugid\")\n+\tif err != nil {\n+\t\tlog.Errorf(\"failed to parse user group id, error: %v\", err)\n+\t} else {\n+\t\tuga.id = int(ugid)\n+\t}\n+\n+}\n+\n+// Get ...\n+func (uga *UserGroupAPI) Get() {\n+\tID := uga.id\n+\tuga.Data[\"json\"] = make([]models.UserGroup, 0)\n+\tif ID == 0 {\n+\t\t//user group id not set, return all user group\n+\t\tquery := models.UserGroup{GroupType: common.LdapGroupType} //Current query LDAP group only\n+\t\tuserGroupList, err := group.QueryUserGroup(query)\n+\t\tif err != nil {\n+\t\t\tlog.Errorf(\"Failed to query database for user group list, error: %v\", err)\n+\t\t\tuga.RenderError(http.StatusInternalServerError, \"Internal Server Error\")\n+\t\t\treturn\n+\t\t}\n+\t\tif len(userGroupList) > 0 {\n+\t\t\tuga.Data[\"json\"] = userGroupList\n+\t\t}\n+\t} else {\n+\t\t//return a specific user group\n+\t\tuserGroup, err := group.GetUserGroup(ID)\n+\t\tif err != nil {\n+\t\t\tlog.Errorf(\"Failed to query database for user group list, error: %v\", err)\n+\t\t\tuga.RenderError(http.StatusInternalServerError, \"Internal Server Error\")\n+\t\t\treturn\n+\t\t}\n+\t\tif userGroup == nil {\n+\t\t\tlog.Errorf(\"Failed to query database for user group list, user group not found, id %v\", ID)\n+\t\t\tuga.RenderError(http.StatusInternalServerError, \"Internal Server Error\")\n+\t\t\treturn\n+\t\t}\n+\t\tuga.Data[\"json\"] = userGroup\n+\t}\n+\tuga.ServeJSON()\n+}\n+\n+// Post ... Create User Group\n+func (uga *UserGroupAPI) Post() {\n+\tuserGroup := models.UserGroup{}\n+\tuga.DecodeJSONReq(&userGroup)\n+\tuserGroup.ID = 0","path":"src/ui/api/usergroup.go","position":101,"original_position":101,"commit_id":"d7a2c67bf9cc261c91d711688cad091cdb542ea8","original_commit_id":"d7a2c67bf9cc261c91d711688cad091cdb542ea8","user":{"login":"stonezdj","id":2696760,"avatar_url":"https://avatars2.githubusercontent.com/u/2696760?v=4","gravatar_id":"","url":"https://api.github.com/users/stonezdj","html_url":"https://github.com/stonezdj","followers_url":"https://api.github.com/users/stonezdj/followers","following_url":"https://api.github.com/users/stonezdj/following{/other_user}","gists_url":"https://api.github.com/users/stonezdj/gists{/gist_id}","starred_url":"https://api.github.com/users/stonezdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonezdj/subscriptions","organizations_url":"https://api.github.com/users/stonezdj/orgs","repos_url":"https://api.github.com/users/stonezdj/repos","events_url":"https://api.github.com/users/stonezdj/events{/privacy}","received_events_url":"https://api.github.com/users/stonezdj/received_events","type":"User","site_admin":false},"body":"In case user send a request with id:123","created_at":"2018-04-02T07:20:07Z","updated_at":"2018-04-02T07:20:07Z","html_url":"https://github.com/vmware/harbor/pull/4483#discussion_r178499742","pull_request_url":"https://api.github.com/repos/vmware/harbor/pulls/4483","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/vmware/harbor/pulls/comments/178499742"},"html":{"href":"https://github.com/vmware/harbor/pull/4483#discussion_r178499742"},"pull_request":{"href":"https://api.github.com/repos/vmware/harbor/pulls/4483"}},"in_reply_to_id":178478806},"pull_request":{"url":"https://api.github.com/repos/vmware/harbor/pulls/4483","id":177361790,"html_url":"https://github.com/vmware/harbor/pull/4483","diff_url":"https://github.com/vmware/harbor/pull/4483.diff","patch_url":"https://github.com/vmware/harbor/pull/4483.patch","issue_url":"https://api.github.com/repos/vmware/harbor/issues/4483","number":4483,"state":"open","locked":false,"title":"Add REST API for assign role to group","user":{"login":"stonezdj","id":2696760,"avatar_url":"https://avatars2.githubusercontent.com/u/2696760?v=4","gravatar_id":"","url":"https://api.github.com/users/stonezdj","html_url":"https://github.com/stonezdj","followers_url":"https://api.github.com/users/stonezdj/followers","following_url":"https://api.github.com/users/stonezdj/following{/other_user}","gists_url":"https://api.github.com/users/stonezdj/gists{/gist_id}","starred_url":"https://api.github.com/users/stonezdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonezdj/subscriptions","organizations_url":"https://api.github.com/users/stonezdj/orgs","repos_url":"https://api.github.com/users/stonezdj/repos","events_url":"https://api.github.com/users/stonezdj/events{/privacy}","received_events_url":"https://api.github.com/users/stonezdj/received_events","type":"User","site_admin":false},"body":"Add REST API for assign role to user group","created_at":"2018-03-26T07:24:52Z","updated_at":"2018-04-02T07:20:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b65f4ea9a9f74a5ea26663e08607fcfaf449570","assignee":{"login":"reasonerjt","id":2390463,"avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false},"assignees":[{"login":"reasonerjt","id":2390463,"avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":350773817,"url":"https://api.github.com/repos/vmware/harbor/labels/cla-not-required","name":"cla-not-required","color":"159818","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/harbor/pulls/4483/commits","review_comments_url":"https://api.github.com/repos/vmware/harbor/pulls/4483/comments","review_comment_url":"https://api.github.com/repos/vmware/harbor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/harbor/issues/4483/comments","statuses_url":"https://api.github.com/repos/vmware/harbor/statuses/d7a2c67bf9cc261c91d711688cad091cdb542ea8","head":{"label":"stonezdj:api4assign_role_to_group4","ref":"api4assign_role_to_group4","sha":"d7a2c67bf9cc261c91d711688cad091cdb542ea8","user":{"login":"stonezdj","id":2696760,"avatar_url":"https://avatars2.githubusercontent.com/u/2696760?v=4","gravatar_id":"","url":"https://api.github.com/users/stonezdj","html_url":"https://github.com/stonezdj","followers_url":"https://api.github.com/users/stonezdj/followers","following_url":"https://api.github.com/users/stonezdj/following{/other_user}","gists_url":"https://api.github.com/users/stonezdj/gists{/gist_id}","starred_url":"https://api.github.com/users/stonezdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonezdj/subscriptions","organizations_url":"https://api.github.com/users/stonezdj/orgs","repos_url":"https://api.github.com/users/stonezdj/repos","events_url":"https://api.github.com/users/stonezdj/events{/privacy}","received_events_url":"https://api.github.com/users/stonezdj/received_events","type":"User","site_admin":false},"repo":{"id":102460256,"name":"harbor","full_name":"stonezdj/harbor","owner":{"login":"stonezdj","id":2696760,"avatar_url":"https://avatars2.githubusercontent.com/u/2696760?v=4","gravatar_id":"","url":"https://api.github.com/users/stonezdj","html_url":"https://github.com/stonezdj","followers_url":"https://api.github.com/users/stonezdj/followers","following_url":"https://api.github.com/users/stonezdj/following{/other_user}","gists_url":"https://api.github.com/users/stonezdj/gists{/gist_id}","starred_url":"https://api.github.com/users/stonezdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonezdj/subscriptions","organizations_url":"https://api.github.com/users/stonezdj/orgs","repos_url":"https://api.github.com/users/stonezdj/repos","events_url":"https://api.github.com/users/stonezdj/events{/privacy}","received_events_url":"https://api.github.com/users/stonezdj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stonezdj/harbor","description":"An enterprise-class container registry server based on Docker Distribution","fork":true,"url":"https://api.github.com/repos/stonezdj/harbor","forks_url":"https://api.github.com/repos/stonezdj/harbor/forks","keys_url":"https://api.github.com/repos/stonezdj/harbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stonezdj/harbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stonezdj/harbor/teams","hooks_url":"https://api.github.com/repos/stonezdj/harbor/hooks","issue_events_url":"https://api.github.com/repos/stonezdj/harbor/issues/events{/number}","events_url":"https://api.github.com/repos/stonezdj/harbor/events","assignees_url":"https://api.github.com/repos/stonezdj/harbor/assignees{/user}","branches_url":"https://api.github.com/repos/stonezdj/harbor/branches{/branch}","tags_url":"https://api.github.com/repos/stonezdj/harbor/tags","blobs_url":"https://api.github.com/repos/stonezdj/harbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stonezdj/harbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stonezdj/harbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/stonezdj/harbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stonezdj/harbor/statuses/{sha}","languages_url":"https://api.github.com/repos/stonezdj/harbor/languages","stargazers_url":"https://api.github.com/repos/stonezdj/harbor/stargazers","contributors_url":"https://api.github.com/repos/stonezdj/harbor/contributors","subscribers_url":"https://api.github.com/repos/stonezdj/harbor/subscribers","subscription_url":"https://api.github.com/repos/stonezdj/harbor/subscription","commits_url":"https://api.github.com/repos/stonezdj/harbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/stonezdj/harbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/stonezdj/harbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/stonezdj/harbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/stonezdj/harbor/contents/{+path}","compare_url":"https://api.github.com/repos/stonezdj/harbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stonezdj/harbor/merges","archive_url":"https://api.github.com/repos/stonezdj/harbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stonezdj/harbor/downloads","issues_url":"https://api.github.com/repos/stonezdj/harbor/issues{/number}","pulls_url":"https://api.github.com/repos/stonezdj/harbor/pulls{/number}","milestones_url":"https://api.github.com/repos/stonezdj/harbor/milestones{/number}","notifications_url":"https://api.github.com/repos/stonezdj/harbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stonezdj/harbor/labels{/name}","releases_url":"https://api.github.com/repos/stonezdj/harbor/releases{/id}","deployments_url":"https://api.github.com/repos/stonezdj/harbor/deployments","created_at":"2017-09-05T09:12:25Z","updated_at":"2018-03-28T09:29:52Z","pushed_at":"2018-03-30T09:57:34Z","git_url":"git://github.com/stonezdj/harbor.git","ssh_url":"git@github.com:stonezdj/harbor.git","clone_url":"https://github.com/stonezdj/harbor.git","svn_url":"https://github.com/stonezdj/harbor","homepage":"http://vmware.github.io/harbor/","size":68396,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"199ebdb751fda38a53719c3fb3aa89d5814e95a7","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars0.githubusercontent.com/u/473334?v=4","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":50613991,"name":"harbor","full_name":"vmware/harbor","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars0.githubusercontent.com/u/473334?v=4","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/harbor","description":"An enterprise-class container registry server based on Docker Distribution","fork":false,"url":"https://api.github.com/repos/vmware/harbor","forks_url":"https://api.github.com/repos/vmware/harbor/forks","keys_url":"https://api.github.com/repos/vmware/harbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/harbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/harbor/teams","hooks_url":"https://api.github.com/repos/vmware/harbor/hooks","issue_events_url":"https://api.github.com/repos/vmware/harbor/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/harbor/events","assignees_url":"https://api.github.com/repos/vmware/harbor/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/harbor/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/harbor/tags","blobs_url":"https://api.github.com/repos/vmware/harbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/harbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/harbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/harbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/harbor/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/harbor/languages","stargazers_url":"https://api.github.com/repos/vmware/harbor/stargazers","contributors_url":"https://api.github.com/repos/vmware/harbor/contributors","subscribers_url":"https://api.github.com/repos/vmware/harbor/subscribers","subscription_url":"https://api.github.com/repos/vmware/harbor/subscription","commits_url":"https://api.github.com/repos/vmware/harbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/harbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/harbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/harbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/harbor/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/harbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/harbor/merges","archive_url":"https://api.github.com/repos/vmware/harbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/harbor/downloads","issues_url":"https://api.github.com/repos/vmware/harbor/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/harbor/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/harbor/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/harbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/harbor/labels{/name}","releases_url":"https://api.github.com/repos/vmware/harbor/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/harbor/deployments","created_at":"2016-01-28T21:10:28Z","updated_at":"2018-04-02T06:54:23Z","pushed_at":"2018-04-02T06:48:42Z","git_url":"git://github.com/vmware/harbor.git","ssh_url":"git@github.com:vmware/harbor.git","clone_url":"https://github.com/vmware/harbor.git","svn_url":"https://github.com/vmware/harbor","homepage":"http://vmware.github.io/harbor/","size":79556,"stargazers_count":3945,"watchers_count":3945,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1098,"mirror_url":null,"archived":false,"open_issues_count":510,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1098,"open_issues":510,"watchers":3945,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/harbor/pulls/4483"},"html":{"href":"https://github.com/vmware/harbor/pull/4483"},"issue":{"href":"https://api.github.com/repos/vmware/harbor/issues/4483"},"comments":{"href":"https://api.github.com/repos/vmware/harbor/issues/4483/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/harbor/pulls/4483/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/harbor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/harbor/pulls/4483/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/harbor/statuses/d7a2c67bf9cc261c91d711688cad091cdb542ea8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stonezdj"}}