{"action":"created","comment":{"url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/comments/191425535","pull_request_review_id":123994009,"id":191425535,"diff_hunk":"@@ -0,0 +1,164 @@\n+{\n+ \"cells\": [\n+  {\n+   \"cell_type\": \"markdown\",\n+   \"metadata\": {},\n+   \"source\": [\n+    \"### This notebook sets up workspaces for a new user. Can only be run by someone with sufficient access.\"\n+   ]\n+  },\n+  {\n+   \"cell_type\": \"code\",\n+   \"execution_count\": null,\n+   \"metadata\": {},\n+   \"outputs\": [],\n+   \"source\": [\n+    \"from adam import ConfigManager\\n\",\n+    \"from adam import Service\\n\",\n+    \"from adam import Permission\"\n+   ]\n+  },\n+  {\n+   \"cell_type\": \"markdown\",\n+   \"metadata\": {},\n+   \"source\": [\n+    \"Edit this to reflect the user and parent workspace for which you would like to add a workspace.\\n\",\n+    \"\\n\",\n+    \"Note: it's unusual for dev and prod to have the same uuids for anything - they happen to have the same uuids for a few objects created early on in the life of ADAM because at one point we copied the table contents. For newly created objects uuids will be assigned independently.\"\n+   ]\n+  },\n+  {\n+   \"cell_type\": \"code\",\n+   \"execution_count\": null,\n+   \"metadata\": {},\n+   \"outputs\": [],\n+   \"source\": [\n+    \"name = # Fill this in!\\n\",\n+    \"email = # Fill this in!\\n\",\n+    \"description = \\\"Workspace for \\\" + name + \\\" within Asteroid Institute\\\"\\n\",\n+    \"parent_project_prod = \\\"74020cfb-6528-4fb8-b170-5e7b2b0dc737\\\"  # The Asteroid Institute shared parent project.\\n\",\n+    \"parent_project_dev = \\\"74020cfb-6528-4fb8-b170-5e7b2b0dc737\\\"  # The Asteroid Institute shared parent project.\\n\",\n+    \"team_group_prod = \\\"ae62ec66-836c-4c4c-8e25-c643ec46b58c\\\"  # The Asteroid Institute team group.\\n\",\n+    \"team_group_dev = \\\"ae62ec66-836c-4c4c-8e25-c643ec46b58c\\\"  # The Asteroid Institute team group.\"\n+   ]\n+  },\n+  {\n+   \"cell_type\": \"markdown\",\n+   \"metadata\": {},\n+   \"source\": [\n+    \"This sets up a workspace in prod for the given user.\"\n+   ]\n+  },\n+  {\n+   \"cell_type\": \"code\",\n+   \"execution_count\": null,\n+   \"metadata\": {},\n+   \"outputs\": [],\n+   \"source\": [\n+    \"print(\\\"Setting up project and group membership for \\\" + name + \\\" in prod.\\\")\\n\",\n+    \"\\n\",\n+    \"config = ConfigManager(os.getcwd() + '/config.json').get_config('prod')\\n\",\n+    \"service = Service(config)\\n\",\n+    \"service.setup()\\n\",\n+    \"\\n\",\n+    \"# Adds the new project if there isn't one.\\n\",\n+    \"projects = service.get_projects_module()\\n\",\n+    \"project = None\\n\",\n+    \"for p in projects.get_sub_projects(parent_project_prod):\\n\",\n+    \"    if p.get_name() == name:\\n\",\n+    \"        project = p\\n\",\n+    \"        print(\\\"Found existing workspace for \\\" + name + \\\" with uuid \\\" + p.get_uuid())\\n\",\n+    \"if project is None:\\n\",\n+    \"    project = projects.new_project(parent_project_prod, name, description)\\n\",\n+    \"    print(\\\"Created workspace for \\\" + name + \\\" with uuid \\\" + project.get_uuid())\\n\",\n+    \"\\n\",\n+    \"    # Gives permission to the new project.\\n\",\n+    \"    permissions = service.get_permissions_module()\\n\",\n+    \"    permissions.grant_user_permission(email, Permission('ADMIN', 'PROJECT', project.get_uuid()))\\n\",\n+    \"    print(\\\"Granted admin permission to \\\" + email + \\\" on project \\\" + project.get_uuid())\\n\",\n+    \"\\n\",\n+    \"# Adds user to team group, if they're not already in it.\\n\",\n+    \"if team_group_prod is not None:\\n\",\n+    \"    groups = service.get_groups_module()\\n\",\n+    \"    if not email in [g.get_id() for g in groups.get_group_members(team_group_prod) if g.get_type() == \\\"USER\\\"]:\\n\",","path":"demos/create_workspace.ipynb","position":83,"original_position":83,"commit_id":"bfd95b031123719ed61cf40f979c538155241d47","original_commit_id":"bfd95b031123719ed61cf40f979c538155241d47","user":{"login":"laurahlark","id":35230484,"avatar_url":"https://avatars0.githubusercontent.com/u/35230484?v=4","gravatar_id":"","url":"https://api.github.com/users/laurahlark","html_url":"https://github.com/laurahlark","followers_url":"https://api.github.com/users/laurahlark/followers","following_url":"https://api.github.com/users/laurahlark/following{/other_user}","gists_url":"https://api.github.com/users/laurahlark/gists{/gist_id}","starred_url":"https://api.github.com/users/laurahlark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurahlark/subscriptions","organizations_url":"https://api.github.com/users/laurahlark/orgs","repos_url":"https://api.github.com/users/laurahlark/repos","events_url":"https://api.github.com/users/laurahlark/events{/privacy}","received_events_url":"https://api.github.com/users/laurahlark/received_events","type":"User","site_admin":false},"body":"I believe it is idempotent (and ran twice to see, seems to be fine), so we could avoid the check. That said, in this case I kinda like being able to report to the person running the notebook whether the new user was already part of the group. Any particular reason to check inclusion of group in user's groups rather than user in group's users? I set it up the other way so that if the person running is interested, it's easy to modify the code to list the group's users.","created_at":"2018-05-29T13:36:36Z","updated_at":"2018-05-29T13:36:37Z","html_url":"https://github.com/B612-Asteroid-Institute/adam/pull/37#discussion_r191425535","pull_request_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/comments/191425535"},"html":{"href":"https://github.com/B612-Asteroid-Institute/adam/pull/37#discussion_r191425535"},"pull_request":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37"}},"in_reply_to_id":191290418},"pull_request":{"url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37","id":189466410,"html_url":"https://github.com/B612-Asteroid-Institute/adam/pull/37","diff_url":"https://github.com/B612-Asteroid-Institute/adam/pull/37.diff","patch_url":"https://github.com/B612-Asteroid-Institute/adam/pull/37.patch","issue_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/37","number":37,"state":"open","locked":false,"title":"Add a notebook that can be used to generate workspace projects for a new user. ","user":{"login":"laurahlark","id":35230484,"avatar_url":"https://avatars0.githubusercontent.com/u/35230484?v=4","gravatar_id":"","url":"https://api.github.com/users/laurahlark","html_url":"https://github.com/laurahlark","followers_url":"https://api.github.com/users/laurahlark/followers","following_url":"https://api.github.com/users/laurahlark/following{/other_user}","gists_url":"https://api.github.com/users/laurahlark/gists{/gist_id}","starred_url":"https://api.github.com/users/laurahlark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurahlark/subscriptions","organizations_url":"https://api.github.com/users/laurahlark/orgs","repos_url":"https://api.github.com/users/laurahlark/repos","events_url":"https://api.github.com/users/laurahlark/events{/privacy}","received_events_url":"https://api.github.com/users/laurahlark/received_events","type":"User","site_admin":false},"body":"Note: can only be run by someone with the proper permissions on the parent workspace projects.","created_at":"2018-05-21T19:26:51Z","updated_at":"2018-05-29T13:36:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b26a445f3bcef5d26a73cbf954e6e2f50b68c38","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37/commits","review_comments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37/comments","review_comment_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/37/comments","statuses_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/statuses/bfd95b031123719ed61cf40f979c538155241d47","head":{"label":"B612-Asteroid-Institute:ll-createworkspace","ref":"ll-createworkspace","sha":"bfd95b031123719ed61cf40f979c538155241d47","user":{"login":"B612-Asteroid-Institute","id":32551062,"avatar_url":"https://avatars1.githubusercontent.com/u/32551062?v=4","gravatar_id":"","url":"https://api.github.com/users/B612-Asteroid-Institute","html_url":"https://github.com/B612-Asteroid-Institute","followers_url":"https://api.github.com/users/B612-Asteroid-Institute/followers","following_url":"https://api.github.com/users/B612-Asteroid-Institute/following{/other_user}","gists_url":"https://api.github.com/users/B612-Asteroid-Institute/gists{/gist_id}","starred_url":"https://api.github.com/users/B612-Asteroid-Institute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B612-Asteroid-Institute/subscriptions","organizations_url":"https://api.github.com/users/B612-Asteroid-Institute/orgs","repos_url":"https://api.github.com/users/B612-Asteroid-Institute/repos","events_url":"https://api.github.com/users/B612-Asteroid-Institute/events{/privacy}","received_events_url":"https://api.github.com/users/B612-Asteroid-Institute/received_events","type":"Organization","site_admin":false},"repo":{"id":122532890,"name":"adam","full_name":"B612-Asteroid-Institute/adam","owner":{"login":"B612-Asteroid-Institute","id":32551062,"avatar_url":"https://avatars1.githubusercontent.com/u/32551062?v=4","gravatar_id":"","url":"https://api.github.com/users/B612-Asteroid-Institute","html_url":"https://github.com/B612-Asteroid-Institute","followers_url":"https://api.github.com/users/B612-Asteroid-Institute/followers","following_url":"https://api.github.com/users/B612-Asteroid-Institute/following{/other_user}","gists_url":"https://api.github.com/users/B612-Asteroid-Institute/gists{/gist_id}","starred_url":"https://api.github.com/users/B612-Asteroid-Institute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B612-Asteroid-Institute/subscriptions","organizations_url":"https://api.github.com/users/B612-Asteroid-Institute/orgs","repos_url":"https://api.github.com/users/B612-Asteroid-Institute/repos","events_url":"https://api.github.com/users/B612-Asteroid-Institute/events{/privacy}","received_events_url":"https://api.github.com/users/B612-Asteroid-Institute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/B612-Asteroid-Institute/adam","description":"Asteroid Decision And Analysis Machine Client","fork":false,"url":"https://api.github.com/repos/B612-Asteroid-Institute/adam","forks_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/forks","keys_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/teams","hooks_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/hooks","issue_events_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/events{/number}","events_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/events","assignees_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/assignees{/user}","branches_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/branches{/branch}","tags_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/tags","blobs_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/refs{/sha}","trees_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/statuses/{sha}","languages_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/languages","stargazers_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/stargazers","contributors_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/contributors","subscribers_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/subscribers","subscription_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/subscription","commits_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/commits{/sha}","git_commits_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/commits{/sha}","comments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/comments{/number}","issue_comment_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/comments{/number}","contents_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/contents/{+path}","compare_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/merges","archive_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/downloads","issues_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues{/number}","pulls_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls{/number}","milestones_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/milestones{/number}","notifications_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/labels{/name}","releases_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/releases{/id}","deployments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/deployments","created_at":"2018-02-22T20:42:25Z","updated_at":"2018-05-25T05:16:54Z","pushed_at":"2018-05-25T05:17:01Z","git_url":"git://github.com/B612-Asteroid-Institute/adam.git","ssh_url":"git@github.com:B612-Asteroid-Institute/adam.git","clone_url":"https://github.com/B612-Asteroid-Institute/adam.git","svn_url":"https://github.com/B612-Asteroid-Institute/adam","homepage":null,"size":1606,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":1,"open_issues":6,"watchers":4,"default_branch":"master"}},"base":{"label":"B612-Asteroid-Institute:master","ref":"master","sha":"ed70ec060953805f1e39fea2ff86a226b1a94443","user":{"login":"B612-Asteroid-Institute","id":32551062,"avatar_url":"https://avatars1.githubusercontent.com/u/32551062?v=4","gravatar_id":"","url":"https://api.github.com/users/B612-Asteroid-Institute","html_url":"https://github.com/B612-Asteroid-Institute","followers_url":"https://api.github.com/users/B612-Asteroid-Institute/followers","following_url":"https://api.github.com/users/B612-Asteroid-Institute/following{/other_user}","gists_url":"https://api.github.com/users/B612-Asteroid-Institute/gists{/gist_id}","starred_url":"https://api.github.com/users/B612-Asteroid-Institute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B612-Asteroid-Institute/subscriptions","organizations_url":"https://api.github.com/users/B612-Asteroid-Institute/orgs","repos_url":"https://api.github.com/users/B612-Asteroid-Institute/repos","events_url":"https://api.github.com/users/B612-Asteroid-Institute/events{/privacy}","received_events_url":"https://api.github.com/users/B612-Asteroid-Institute/received_events","type":"Organization","site_admin":false},"repo":{"id":122532890,"name":"adam","full_name":"B612-Asteroid-Institute/adam","owner":{"login":"B612-Asteroid-Institute","id":32551062,"avatar_url":"https://avatars1.githubusercontent.com/u/32551062?v=4","gravatar_id":"","url":"https://api.github.com/users/B612-Asteroid-Institute","html_url":"https://github.com/B612-Asteroid-Institute","followers_url":"https://api.github.com/users/B612-Asteroid-Institute/followers","following_url":"https://api.github.com/users/B612-Asteroid-Institute/following{/other_user}","gists_url":"https://api.github.com/users/B612-Asteroid-Institute/gists{/gist_id}","starred_url":"https://api.github.com/users/B612-Asteroid-Institute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B612-Asteroid-Institute/subscriptions","organizations_url":"https://api.github.com/users/B612-Asteroid-Institute/orgs","repos_url":"https://api.github.com/users/B612-Asteroid-Institute/repos","events_url":"https://api.github.com/users/B612-Asteroid-Institute/events{/privacy}","received_events_url":"https://api.github.com/users/B612-Asteroid-Institute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/B612-Asteroid-Institute/adam","description":"Asteroid Decision And Analysis Machine Client","fork":false,"url":"https://api.github.com/repos/B612-Asteroid-Institute/adam","forks_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/forks","keys_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/teams","hooks_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/hooks","issue_events_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/events{/number}","events_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/events","assignees_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/assignees{/user}","branches_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/branches{/branch}","tags_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/tags","blobs_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/refs{/sha}","trees_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/statuses/{sha}","languages_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/languages","stargazers_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/stargazers","contributors_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/contributors","subscribers_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/subscribers","subscription_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/subscription","commits_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/commits{/sha}","git_commits_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/git/commits{/sha}","comments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/comments{/number}","issue_comment_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/comments{/number}","contents_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/contents/{+path}","compare_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/merges","archive_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/downloads","issues_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues{/number}","pulls_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls{/number}","milestones_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/milestones{/number}","notifications_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/labels{/name}","releases_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/releases{/id}","deployments_url":"https://api.github.com/repos/B612-Asteroid-Institute/adam/deployments","created_at":"2018-02-22T20:42:25Z","updated_at":"2018-05-25T05:16:54Z","pushed_at":"2018-05-25T05:17:01Z","git_url":"git://github.com/B612-Asteroid-Institute/adam.git","ssh_url":"git@github.com:B612-Asteroid-Institute/adam.git","clone_url":"https://github.com/B612-Asteroid-Institute/adam.git","svn_url":"https://github.com/B612-Asteroid-Institute/adam","homepage":null,"size":1606,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":1,"open_issues":6,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37"},"html":{"href":"https://github.com/B612-Asteroid-Institute/adam/pull/37"},"issue":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/37"},"comments":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/B612-Asteroid-Institute/adam/statuses/bfd95b031123719ed61cf40f979c538155241d47"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"laurahlark"}}