{"action":"created","comment":{"url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/comments/175096825","pull_request_review_id":104573415,"id":175096825,"diff_hunk":"@@ -0,0 +1,134 @@\n+from flask import abort, request\n+from marshmallow import ValidationError\n+\n+from dataservice.extensions import db\n+from dataservice.api.common.pagination import paginated, Pagination\n+from dataservice.api.study.models import Study\n+from dataservice.api.study.schemas import StudySchema\n+from dataservice.api.common.views import CRUDView\n+\n+\n+class StudyListAPI(CRUDView):\n+    \"\"\"\n+    Study API\n+    \"\"\"\n+    endpoint = 'studies_list'\n+    rule = '/studies'\n+    schemas = {'Study': StudySchema}\n+\n+    @paginated\n+    def get(self, after, limit):\n+        \"\"\"\n+        Get a paginated studies\n+        ---\n+        template:\n+          path:\n+            get_list.yml\n+          properties:\n+            resource:\n+              Study\n+        \"\"\"\n+        q = Study.query\n+\n+        return (StudySchema(many=True)\n+                .jsonify(Pagination(q, after, limit)))\n+\n+    def post(self):\n+        \"\"\"\n+        Create a new study\n+        ---\n+        template:\n+          path:\n+            new_resource.yml\n+          properties:\n+            resource:\n+              Study\n+        \"\"\"\n+        try:\n+            st = StudySchema(strict=True).load(request.json).data\n+        except ValidationError as err:\n+            abort(400, 'could not create study: {}'.format(err.messages))\n+\n+        db.session.add(st)\n+        db.session.commit()\n+        return StudySchema(\n+            201, 'study {} created'.format(st.kf_id)\n+        ).jsonify(st), 201\n+\n+\n+class StudyAPI(CRUDView):\n+    \"\"\"\n+    Study API\n+    \"\"\"\n+    endpoint = 'studies'\n+    rule = '/studies/<string:kf_id>'\n+    schemas = {'Study': StudySchema}\n+\n+    def get(self, kf_id):\n+        \"\"\"\n+        Get a study by id\n+        ---\n+        template:\n+          path:\n+            get_by_id.yml\n+          properties:\n+            resource:\n+              Study\n+        \"\"\"\n+        st = Study.query.get(kf_id)\n+        if st is None:\n+            abort(404, 'could not find {} `{}`'\n+                  .format('study', kf_id))\n+        return StudySchema().jsonify(st)\n+\n+    def patch(self, kf_id):\n+        \"\"\"\n+        Update fields in a study and preserve existing fields.\n+        ---\n+        template:\n+          path:\n+            update_by_id.yml\n+          properties:\n+            resource:\n+              Study\n+        \"\"\"\n+        body = request.json\n+        st = Study.query.get(kf_id)\n+        if st is None:\n+            abort(404, 'could not find {} `{}`'\n+                  .format('study', kf_id))\n+\n+        try:\n+            st = (StudySchema(strict=True).load(body, instance=st,\n+                                                partial=True).data)\n+        except ValidationError as err:\n+            abort(400, 'could not update participant: {}'.format(err.messages))","path":"dataservice/api/study/resources.py","position":105,"original_position":105,"commit_id":"c70cd06127c44df0a88344b231fe9e54468c7c85","original_commit_id":"c70cd06127c44df0a88344b231fe9e54468c7c85","user":{"login":"znatty22","id":10283712,"avatar_url":"https://avatars2.githubusercontent.com/u/10283712?v=4","gravatar_id":"","url":"https://api.github.com/users/znatty22","html_url":"https://github.com/znatty22","followers_url":"https://api.github.com/users/znatty22/followers","following_url":"https://api.github.com/users/znatty22/following{/other_user}","gists_url":"https://api.github.com/users/znatty22/gists{/gist_id}","starred_url":"https://api.github.com/users/znatty22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znatty22/subscriptions","organizations_url":"https://api.github.com/users/znatty22/orgs","repos_url":"https://api.github.com/users/znatty22/repos","events_url":"https://api.github.com/users/znatty22/events{/privacy}","received_events_url":"https://api.github.com/users/znatty22/received_events","type":"User","site_admin":false},"body":"Prob copy/paste error, change `could not update participant` to `could not update study`","created_at":"2018-03-16T13:57:00Z","updated_at":"2018-03-16T14:00:28Z","html_url":"https://github.com/kids-first/kf-api-dataservice/pull/175#discussion_r175096825","pull_request_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/comments/175096825"},"html":{"href":"https://github.com/kids-first/kf-api-dataservice/pull/175#discussion_r175096825"},"pull_request":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175"}}},"pull_request":{"url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175","id":173843419,"html_url":"https://github.com/kids-first/kf-api-dataservice/pull/175","diff_url":"https://github.com/kids-first/kf-api-dataservice/pull/175.diff","patch_url":"https://github.com/kids-first/kf-api-dataservice/pull/175.patch","issue_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/175","number":175,"state":"open","locked":false,"title":"✨ Study resource","user":{"login":"dankolbman","id":2495894,"avatar_url":"https://avatars0.githubusercontent.com/u/2495894?v=4","gravatar_id":"","url":"https://api.github.com/users/dankolbman","html_url":"https://github.com/dankolbman","followers_url":"https://api.github.com/users/dankolbman/followers","following_url":"https://api.github.com/users/dankolbman/following{/other_user}","gists_url":"https://api.github.com/users/dankolbman/gists{/gist_id}","starred_url":"https://api.github.com/users/dankolbman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankolbman/subscriptions","organizations_url":"https://api.github.com/users/dankolbman/orgs","repos_url":"https://api.github.com/users/dankolbman/repos","events_url":"https://api.github.com/users/dankolbman/events{/privacy}","received_events_url":"https://api.github.com/users/dankolbman/received_events","type":"User","site_admin":false},"body":"Adds endpoints for the study resource.\r\n\r\nAddresses #161 ","created_at":"2018-03-08T20:35:42Z","updated_at":"2018-03-16T14:00:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e138154a62ca71f5217857715b4fd6eec3d91dbf","assignee":{"login":"dankolbman","id":2495894,"avatar_url":"https://avatars0.githubusercontent.com/u/2495894?v=4","gravatar_id":"","url":"https://api.github.com/users/dankolbman","html_url":"https://github.com/dankolbman","followers_url":"https://api.github.com/users/dankolbman/followers","following_url":"https://api.github.com/users/dankolbman/following{/other_user}","gists_url":"https://api.github.com/users/dankolbman/gists{/gist_id}","starred_url":"https://api.github.com/users/dankolbman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankolbman/subscriptions","organizations_url":"https://api.github.com/users/dankolbman/orgs","repos_url":"https://api.github.com/users/dankolbman/repos","events_url":"https://api.github.com/users/dankolbman/events{/privacy}","received_events_url":"https://api.github.com/users/dankolbman/received_events","type":"User","site_admin":false},"assignees":[{"login":"dankolbman","id":2495894,"avatar_url":"https://avatars0.githubusercontent.com/u/2495894?v=4","gravatar_id":"","url":"https://api.github.com/users/dankolbman","html_url":"https://github.com/dankolbman","followers_url":"https://api.github.com/users/dankolbman/followers","following_url":"https://api.github.com/users/dankolbman/following{/other_user}","gists_url":"https://api.github.com/users/dankolbman/gists{/gist_id}","starred_url":"https://api.github.com/users/dankolbman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankolbman/subscriptions","organizations_url":"https://api.github.com/users/dankolbman/orgs","repos_url":"https://api.github.com/users/dankolbman/repos","events_url":"https://api.github.com/users/dankolbman/events{/privacy}","received_events_url":"https://api.github.com/users/dankolbman/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"parimalak","id":20447220,"avatar_url":"https://avatars2.githubusercontent.com/u/20447220?v=4","gravatar_id":"","url":"https://api.github.com/users/parimalak","html_url":"https://github.com/parimalak","followers_url":"https://api.github.com/users/parimalak/followers","following_url":"https://api.github.com/users/parimalak/following{/other_user}","gists_url":"https://api.github.com/users/parimalak/gists{/gist_id}","starred_url":"https://api.github.com/users/parimalak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parimalak/subscriptions","organizations_url":"https://api.github.com/users/parimalak/orgs","repos_url":"https://api.github.com/users/parimalak/repos","events_url":"https://api.github.com/users/parimalak/events{/privacy}","received_events_url":"https://api.github.com/users/parimalak/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":799831732,"url":"https://api.github.com/repos/kids-first/kf-api-dataservice/labels/feature","name":"feature","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175/commits","review_comments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175/comments","review_comment_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/175/comments","statuses_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/statuses/c70cd06127c44df0a88344b231fe9e54468c7c85","head":{"label":"kids-first:study-resource","ref":"study-resource","sha":"c70cd06127c44df0a88344b231fe9e54468c7c85","user":{"login":"kids-first","id":29782953,"avatar_url":"https://avatars2.githubusercontent.com/u/29782953?v=4","gravatar_id":"","url":"https://api.github.com/users/kids-first","html_url":"https://github.com/kids-first","followers_url":"https://api.github.com/users/kids-first/followers","following_url":"https://api.github.com/users/kids-first/following{/other_user}","gists_url":"https://api.github.com/users/kids-first/gists{/gist_id}","starred_url":"https://api.github.com/users/kids-first/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kids-first/subscriptions","organizations_url":"https://api.github.com/users/kids-first/orgs","repos_url":"https://api.github.com/users/kids-first/repos","events_url":"https://api.github.com/users/kids-first/events{/privacy}","received_events_url":"https://api.github.com/users/kids-first/received_events","type":"Organization","site_admin":false},"repo":{"id":116870795,"name":"kf-api-dataservice","full_name":"kids-first/kf-api-dataservice","owner":{"login":"kids-first","id":29782953,"avatar_url":"https://avatars2.githubusercontent.com/u/29782953?v=4","gravatar_id":"","url":"https://api.github.com/users/kids-first","html_url":"https://github.com/kids-first","followers_url":"https://api.github.com/users/kids-first/followers","following_url":"https://api.github.com/users/kids-first/following{/other_user}","gists_url":"https://api.github.com/users/kids-first/gists{/gist_id}","starred_url":"https://api.github.com/users/kids-first/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kids-first/subscriptions","organizations_url":"https://api.github.com/users/kids-first/orgs","repos_url":"https://api.github.com/users/kids-first/repos","events_url":"https://api.github.com/users/kids-first/events{/privacy}","received_events_url":"https://api.github.com/users/kids-first/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kids-first/kf-api-dataservice","description":":file_cabinet: Primary API for interacting with the Kids First data","fork":false,"url":"https://api.github.com/repos/kids-first/kf-api-dataservice","forks_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/forks","keys_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/teams","hooks_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/hooks","issue_events_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/events{/number}","events_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/events","assignees_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/assignees{/user}","branches_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/branches{/branch}","tags_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/tags","blobs_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/statuses/{sha}","languages_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/languages","stargazers_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/stargazers","contributors_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/contributors","subscribers_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/subscribers","subscription_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/subscription","commits_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/contents/{+path}","compare_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/merges","archive_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/downloads","issues_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues{/number}","pulls_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls{/number}","milestones_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/milestones{/number}","notifications_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/labels{/name}","releases_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/releases{/id}","deployments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/deployments","created_at":"2018-01-09T21:06:39Z","updated_at":"2018-03-15T22:00:07Z","pushed_at":"2018-03-16T13:39:38Z","git_url":"git://github.com/kids-first/kf-api-dataservice.git","ssh_url":"git@github.com:kids-first/kf-api-dataservice.git","clone_url":"https://github.com/kids-first/kf-api-dataservice.git","svn_url":"https://github.com/kids-first/kf-api-dataservice","homepage":"http://kf-api-dataservice-qa.kids-first.io","size":3647,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":32,"watchers":1,"default_branch":"master"}},"base":{"label":"kids-first:master","ref":"master","sha":"4e7876d73f04edae8866cb472116919702199636","user":{"login":"kids-first","id":29782953,"avatar_url":"https://avatars2.githubusercontent.com/u/29782953?v=4","gravatar_id":"","url":"https://api.github.com/users/kids-first","html_url":"https://github.com/kids-first","followers_url":"https://api.github.com/users/kids-first/followers","following_url":"https://api.github.com/users/kids-first/following{/other_user}","gists_url":"https://api.github.com/users/kids-first/gists{/gist_id}","starred_url":"https://api.github.com/users/kids-first/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kids-first/subscriptions","organizations_url":"https://api.github.com/users/kids-first/orgs","repos_url":"https://api.github.com/users/kids-first/repos","events_url":"https://api.github.com/users/kids-first/events{/privacy}","received_events_url":"https://api.github.com/users/kids-first/received_events","type":"Organization","site_admin":false},"repo":{"id":116870795,"name":"kf-api-dataservice","full_name":"kids-first/kf-api-dataservice","owner":{"login":"kids-first","id":29782953,"avatar_url":"https://avatars2.githubusercontent.com/u/29782953?v=4","gravatar_id":"","url":"https://api.github.com/users/kids-first","html_url":"https://github.com/kids-first","followers_url":"https://api.github.com/users/kids-first/followers","following_url":"https://api.github.com/users/kids-first/following{/other_user}","gists_url":"https://api.github.com/users/kids-first/gists{/gist_id}","starred_url":"https://api.github.com/users/kids-first/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kids-first/subscriptions","organizations_url":"https://api.github.com/users/kids-first/orgs","repos_url":"https://api.github.com/users/kids-first/repos","events_url":"https://api.github.com/users/kids-first/events{/privacy}","received_events_url":"https://api.github.com/users/kids-first/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kids-first/kf-api-dataservice","description":":file_cabinet: Primary API for interacting with the Kids First data","fork":false,"url":"https://api.github.com/repos/kids-first/kf-api-dataservice","forks_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/forks","keys_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/teams","hooks_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/hooks","issue_events_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/events{/number}","events_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/events","assignees_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/assignees{/user}","branches_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/branches{/branch}","tags_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/tags","blobs_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/statuses/{sha}","languages_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/languages","stargazers_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/stargazers","contributors_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/contributors","subscribers_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/subscribers","subscription_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/subscription","commits_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/contents/{+path}","compare_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/merges","archive_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/downloads","issues_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues{/number}","pulls_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls{/number}","milestones_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/milestones{/number}","notifications_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/labels{/name}","releases_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/releases{/id}","deployments_url":"https://api.github.com/repos/kids-first/kf-api-dataservice/deployments","created_at":"2018-01-09T21:06:39Z","updated_at":"2018-03-15T22:00:07Z","pushed_at":"2018-03-16T13:39:38Z","git_url":"git://github.com/kids-first/kf-api-dataservice.git","ssh_url":"git@github.com:kids-first/kf-api-dataservice.git","clone_url":"https://github.com/kids-first/kf-api-dataservice.git","svn_url":"https://github.com/kids-first/kf-api-dataservice","homepage":"http://kf-api-dataservice-qa.kids-first.io","size":3647,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":32,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175"},"html":{"href":"https://github.com/kids-first/kf-api-dataservice/pull/175"},"issue":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/175"},"comments":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/issues/175/comments"},"review_comments":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175/comments"},"review_comment":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/pulls/175/commits"},"statuses":{"href":"https://api.github.com/repos/kids-first/kf-api-dataservice/statuses/c70cd06127c44df0a88344b231fe9e54468c7c85"}},"author_association":"OWNER"}}
{"actor":{"display_login":"znatty22"}}