{"action":"created","comment":{"url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/comments/167905908","pull_request_review_id":96189697,"id":167905908,"diff_hunk":"@@ -0,0 +1,154 @@\n+from .util import get_nested\n+\n+\n+class EventType(object):\n+    def __init__(self, event):\n+        self.event = event\n+\n+    def has_required_keys(self):\n+        return all(get_nested(self.event, *key.split('.')) is not None for key in self.required_keys)\n+\n+    def collect(self):\n+        event_info = {}\n+        for key in self.keys:\n+            value = get_nested(self.event, *key.split('.'))\n+            if value is not None:\n+                event_info['event-info.%s.%s' % (self.type, key)] = value\n+        event_info['event-info.eventType'] = self.type\n+        return event_info\n+\n+\n+class ApiGateway(EventType):\n+    type = 'apiGateway'\n+    keys = [\n+        'httpMethod',\n+        'path',\n+        'requestContext.accountId',\n+        'requestContext.httpMethod',\n+        'requestContext.identity.userAgent',\n+        'requestContext.requestId',\n+        'requestContext.resourcePath',\n+        'requestContext.stage',\n+        'resource',\n+    ]\n+    required_keys = [\n+        'headers',\n+        'httpMethod',\n+        'path',\n+        'requestContext',\n+        'resource',\n+    ]\n+\n+\n+class CloudFront(EventType):\n+    type = 'cloudFront'\n+    keys = [\n+        'Records[0].cf.config.distributionId',\n+        'Records[0].cf.request.clientIp',\n+        'Records[0].cf.request.headers.host[0].value',\n+        'Records[0].cf.request.headers.user-agent[0].value',\n+        'Records[0].cf.request.method',\n+        'Records[0].cf.request.uri',\n+    ]\n+    required_keys = ['Records.cf']","path":"iopipe/contrib/eventinfo/event_types.py","position":53,"original_position":53,"commit_id":"b2eace7659e76fbbd7e1064859fa4e5cedb6964f","original_commit_id":"b2eace7659e76fbbd7e1064859fa4e5cedb6964f","user":{"login":"coreylight","id":1470090,"avatar_url":"https://avatars0.githubusercontent.com/u/1470090?v=4","gravatar_id":"","url":"https://api.github.com/users/coreylight","html_url":"https://github.com/coreylight","followers_url":"https://api.github.com/users/coreylight/followers","following_url":"https://api.github.com/users/coreylight/following{/other_user}","gists_url":"https://api.github.com/users/coreylight/gists{/gist_id}","starred_url":"https://api.github.com/users/coreylight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreylight/subscriptions","organizations_url":"https://api.github.com/users/coreylight/orgs","repos_url":"https://api.github.com/users/coreylight/repos","events_url":"https://api.github.com/users/coreylight/events{/privacy}","received_events_url":"https://api.github.com/users/coreylight/received_events","type":"User","site_admin":false},"body":"I just was poking around at this and saw that this maybe should be `required_keys = ['Records[0].cf']` ? Not sure just a heads up :)","created_at":"2018-02-13T15:46:13Z","updated_at":"2018-02-13T15:46:13Z","html_url":"https://github.com/iopipe/iopipe-python/pull/150#discussion_r167905908","pull_request_url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/comments/167905908"},"html":{"href":"https://github.com/iopipe/iopipe-python/pull/150#discussion_r167905908"},"pull_request":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150"}}},"pull_request":{"url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150","id":167561971,"html_url":"https://github.com/iopipe/iopipe-python/pull/150","diff_url":"https://github.com/iopipe/iopipe-python/pull/150.diff","patch_url":"https://github.com/iopipe/iopipe-python/pull/150.patch","issue_url":"https://api.github.com/repos/iopipe/iopipe-python/issues/150","number":150,"state":"open","locked":false,"title":"Event Info Plugin","user":{"login":"kolanos","id":17498,"avatar_url":"https://avatars2.githubusercontent.com/u/17498?v=4","gravatar_id":"","url":"https://api.github.com/users/kolanos","html_url":"https://github.com/kolanos","followers_url":"https://api.github.com/users/kolanos/followers","following_url":"https://api.github.com/users/kolanos/following{/other_user}","gists_url":"https://api.github.com/users/kolanos/gists{/gist_id}","starred_url":"https://api.github.com/users/kolanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolanos/subscriptions","organizations_url":"https://api.github.com/users/kolanos/orgs","repos_url":"https://api.github.com/users/kolanos/repos","events_url":"https://api.github.com/users/kolanos/events{/privacy}","received_events_url":"https://api.github.com/users/kolanos/received_events","type":"User","site_admin":false},"body":"A plugin to collect AWS event information.","created_at":"2018-02-06T23:51:04Z","updated_at":"2018-02-13T15:46:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39c75aae7880bd1545d17eec5a50cdc830f656f7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":705949764,"url":"https://api.github.com/repos/iopipe/iopipe-python/labels/Work%20In%20Progress","name":"Work In Progress","color":"0052cc","default":false}],"milestone":{"url":"https://api.github.com/repos/iopipe/iopipe-python/milestones/3","html_url":"https://github.com/iopipe/iopipe-python/milestone/3","labels_url":"https://api.github.com/repos/iopipe/iopipe-python/milestones/3/labels","id":3109555,"number":3,"title":"v1.2","description":"","creator":{"login":"kolanos","id":17498,"avatar_url":"https://avatars2.githubusercontent.com/u/17498?v=4","gravatar_id":"","url":"https://api.github.com/users/kolanos","html_url":"https://github.com/kolanos","followers_url":"https://api.github.com/users/kolanos/followers","following_url":"https://api.github.com/users/kolanos/following{/other_user}","gists_url":"https://api.github.com/users/kolanos/gists{/gist_id}","starred_url":"https://api.github.com/users/kolanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolanos/subscriptions","organizations_url":"https://api.github.com/users/kolanos/orgs","repos_url":"https://api.github.com/users/kolanos/repos","events_url":"https://api.github.com/users/kolanos/events{/privacy}","received_events_url":"https://api.github.com/users/kolanos/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2018-02-12T22:29:51Z","updated_at":"2018-02-12T22:30:42Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150/commits","review_comments_url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150/comments","review_comment_url":"https://api.github.com/repos/iopipe/iopipe-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iopipe/iopipe-python/issues/150/comments","statuses_url":"https://api.github.com/repos/iopipe/iopipe-python/statuses/b2eace7659e76fbbd7e1064859fa4e5cedb6964f","head":{"label":"kolanos:eventinfo","ref":"eventinfo","sha":"b2eace7659e76fbbd7e1064859fa4e5cedb6964f","user":{"login":"kolanos","id":17498,"avatar_url":"https://avatars2.githubusercontent.com/u/17498?v=4","gravatar_id":"","url":"https://api.github.com/users/kolanos","html_url":"https://github.com/kolanos","followers_url":"https://api.github.com/users/kolanos/followers","following_url":"https://api.github.com/users/kolanos/following{/other_user}","gists_url":"https://api.github.com/users/kolanos/gists{/gist_id}","starred_url":"https://api.github.com/users/kolanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolanos/subscriptions","organizations_url":"https://api.github.com/users/kolanos/orgs","repos_url":"https://api.github.com/users/kolanos/repos","events_url":"https://api.github.com/users/kolanos/events{/privacy}","received_events_url":"https://api.github.com/users/kolanos/received_events","type":"User","site_admin":false},"repo":{"id":99169334,"name":"iopipe-python","full_name":"kolanos/iopipe-python","owner":{"login":"kolanos","id":17498,"avatar_url":"https://avatars2.githubusercontent.com/u/17498?v=4","gravatar_id":"","url":"https://api.github.com/users/kolanos","html_url":"https://github.com/kolanos","followers_url":"https://api.github.com/users/kolanos/followers","following_url":"https://api.github.com/users/kolanos/following{/other_user}","gists_url":"https://api.github.com/users/kolanos/gists{/gist_id}","starred_url":"https://api.github.com/users/kolanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolanos/subscriptions","organizations_url":"https://api.github.com/users/kolanos/orgs","repos_url":"https://api.github.com/users/kolanos/repos","events_url":"https://api.github.com/users/kolanos/events{/privacy}","received_events_url":"https://api.github.com/users/kolanos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kolanos/iopipe-python","description":"Python agent for AWS Lambda tracing & analytics","fork":true,"url":"https://api.github.com/repos/kolanos/iopipe-python","forks_url":"https://api.github.com/repos/kolanos/iopipe-python/forks","keys_url":"https://api.github.com/repos/kolanos/iopipe-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kolanos/iopipe-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kolanos/iopipe-python/teams","hooks_url":"https://api.github.com/repos/kolanos/iopipe-python/hooks","issue_events_url":"https://api.github.com/repos/kolanos/iopipe-python/issues/events{/number}","events_url":"https://api.github.com/repos/kolanos/iopipe-python/events","assignees_url":"https://api.github.com/repos/kolanos/iopipe-python/assignees{/user}","branches_url":"https://api.github.com/repos/kolanos/iopipe-python/branches{/branch}","tags_url":"https://api.github.com/repos/kolanos/iopipe-python/tags","blobs_url":"https://api.github.com/repos/kolanos/iopipe-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kolanos/iopipe-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kolanos/iopipe-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/kolanos/iopipe-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kolanos/iopipe-python/statuses/{sha}","languages_url":"https://api.github.com/repos/kolanos/iopipe-python/languages","stargazers_url":"https://api.github.com/repos/kolanos/iopipe-python/stargazers","contributors_url":"https://api.github.com/repos/kolanos/iopipe-python/contributors","subscribers_url":"https://api.github.com/repos/kolanos/iopipe-python/subscribers","subscription_url":"https://api.github.com/repos/kolanos/iopipe-python/subscription","commits_url":"https://api.github.com/repos/kolanos/iopipe-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/kolanos/iopipe-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/kolanos/iopipe-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/kolanos/iopipe-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/kolanos/iopipe-python/contents/{+path}","compare_url":"https://api.github.com/repos/kolanos/iopipe-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kolanos/iopipe-python/merges","archive_url":"https://api.github.com/repos/kolanos/iopipe-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kolanos/iopipe-python/downloads","issues_url":"https://api.github.com/repos/kolanos/iopipe-python/issues{/number}","pulls_url":"https://api.github.com/repos/kolanos/iopipe-python/pulls{/number}","milestones_url":"https://api.github.com/repos/kolanos/iopipe-python/milestones{/number}","notifications_url":"https://api.github.com/repos/kolanos/iopipe-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kolanos/iopipe-python/labels{/name}","releases_url":"https://api.github.com/repos/kolanos/iopipe-python/releases{/id}","deployments_url":"https://api.github.com/repos/kolanos/iopipe-python/deployments","created_at":"2017-08-02T23:22:21Z","updated_at":"2017-08-02T23:22:22Z","pushed_at":"2018-02-12T22:49:53Z","git_url":"git://github.com/kolanos/iopipe-python.git","ssh_url":"git@github.com:kolanos/iopipe-python.git","clone_url":"https://github.com/kolanos/iopipe-python.git","svn_url":"https://github.com/kolanos/iopipe-python","homepage":null,"size":781,"stargazers_count":0,"watchers_count":0,"language":"Python","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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"iopipe:master","ref":"master","sha":"88dce9d88a1ff5dadfd6996f7518c9bd83658eed","user":{"login":"iopipe","id":15937935,"avatar_url":"https://avatars2.githubusercontent.com/u/15937935?v=4","gravatar_id":"","url":"https://api.github.com/users/iopipe","html_url":"https://github.com/iopipe","followers_url":"https://api.github.com/users/iopipe/followers","following_url":"https://api.github.com/users/iopipe/following{/other_user}","gists_url":"https://api.github.com/users/iopipe/gists{/gist_id}","starred_url":"https://api.github.com/users/iopipe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iopipe/subscriptions","organizations_url":"https://api.github.com/users/iopipe/orgs","repos_url":"https://api.github.com/users/iopipe/repos","events_url":"https://api.github.com/users/iopipe/events{/privacy}","received_events_url":"https://api.github.com/users/iopipe/received_events","type":"Organization","site_admin":false},"repo":{"id":64508423,"name":"iopipe-python","full_name":"iopipe/iopipe-python","owner":{"login":"iopipe","id":15937935,"avatar_url":"https://avatars2.githubusercontent.com/u/15937935?v=4","gravatar_id":"","url":"https://api.github.com/users/iopipe","html_url":"https://github.com/iopipe","followers_url":"https://api.github.com/users/iopipe/followers","following_url":"https://api.github.com/users/iopipe/following{/other_user}","gists_url":"https://api.github.com/users/iopipe/gists{/gist_id}","starred_url":"https://api.github.com/users/iopipe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iopipe/subscriptions","organizations_url":"https://api.github.com/users/iopipe/orgs","repos_url":"https://api.github.com/users/iopipe/repos","events_url":"https://api.github.com/users/iopipe/events{/privacy}","received_events_url":"https://api.github.com/users/iopipe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iopipe/iopipe-python","description":"Python agent for AWS Lambda tracing & analytics","fork":false,"url":"https://api.github.com/repos/iopipe/iopipe-python","forks_url":"https://api.github.com/repos/iopipe/iopipe-python/forks","keys_url":"https://api.github.com/repos/iopipe/iopipe-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iopipe/iopipe-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iopipe/iopipe-python/teams","hooks_url":"https://api.github.com/repos/iopipe/iopipe-python/hooks","issue_events_url":"https://api.github.com/repos/iopipe/iopipe-python/issues/events{/number}","events_url":"https://api.github.com/repos/iopipe/iopipe-python/events","assignees_url":"https://api.github.com/repos/iopipe/iopipe-python/assignees{/user}","branches_url":"https://api.github.com/repos/iopipe/iopipe-python/branches{/branch}","tags_url":"https://api.github.com/repos/iopipe/iopipe-python/tags","blobs_url":"https://api.github.com/repos/iopipe/iopipe-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iopipe/iopipe-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iopipe/iopipe-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/iopipe/iopipe-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iopipe/iopipe-python/statuses/{sha}","languages_url":"https://api.github.com/repos/iopipe/iopipe-python/languages","stargazers_url":"https://api.github.com/repos/iopipe/iopipe-python/stargazers","contributors_url":"https://api.github.com/repos/iopipe/iopipe-python/contributors","subscribers_url":"https://api.github.com/repos/iopipe/iopipe-python/subscribers","subscription_url":"https://api.github.com/repos/iopipe/iopipe-python/subscription","commits_url":"https://api.github.com/repos/iopipe/iopipe-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/iopipe/iopipe-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/iopipe/iopipe-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/iopipe/iopipe-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/iopipe/iopipe-python/contents/{+path}","compare_url":"https://api.github.com/repos/iopipe/iopipe-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iopipe/iopipe-python/merges","archive_url":"https://api.github.com/repos/iopipe/iopipe-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iopipe/iopipe-python/downloads","issues_url":"https://api.github.com/repos/iopipe/iopipe-python/issues{/number}","pulls_url":"https://api.github.com/repos/iopipe/iopipe-python/pulls{/number}","milestones_url":"https://api.github.com/repos/iopipe/iopipe-python/milestones{/number}","notifications_url":"https://api.github.com/repos/iopipe/iopipe-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iopipe/iopipe-python/labels{/name}","releases_url":"https://api.github.com/repos/iopipe/iopipe-python/releases{/id}","deployments_url":"https://api.github.com/repos/iopipe/iopipe-python/deployments","created_at":"2016-07-29T20:25:53Z","updated_at":"2018-01-31T19:10:35Z","pushed_at":"2018-02-12T22:49:44Z","git_url":"git://github.com/iopipe/iopipe-python.git","ssh_url":"git@github.com:iopipe/iopipe-python.git","clone_url":"https://github.com/iopipe/iopipe-python.git","svn_url":"https://github.com/iopipe/iopipe-python","homepage":null,"size":779,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":6,"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":13,"open_issues":6,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150"},"html":{"href":"https://github.com/iopipe/iopipe-python/pull/150"},"issue":{"href":"https://api.github.com/repos/iopipe/iopipe-python/issues/150"},"comments":{"href":"https://api.github.com/repos/iopipe/iopipe-python/issues/150/comments"},"review_comments":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150/comments"},"review_comment":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iopipe/iopipe-python/pulls/150/commits"},"statuses":{"href":"https://api.github.com/repos/iopipe/iopipe-python/statuses/b2eace7659e76fbbd7e1064859fa4e5cedb6964f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"coreylight"}}