{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/comments/193155314","pull_request_review_id":126071726,"id":193155314,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzE1NTMxNA==","diff_hunk":"@@ -0,0 +1,34 @@\n+package com.gu.zuora.reports\n+\n+import com.amazonaws.services.s3.model.{ObjectMetadata, PutObjectRequest, PutObjectResult}\n+import com.gu.util.Logging\n+import com.gu.util.config.Stage\n+import com.gu.util.zuora.RestRequestMaker.{ClientFailableOp, DownloadStream, GenericError}\n+\n+import scala.util.Try\n+import scalaz.syntax.std.either._\n+\n+object S3ReportUploader extends Logging {\n+\n+  val buckets = Map(\n+    Stage(\"CODE\") -> \"zuora-reports-code\",\n+    Stage(\"PROD\") -> \"zuora-reports-prod\",\n+    Stage(\"DEV\") -> \"zuora-reports-dev\"\n+  )\n+\n+  def apply(stage: Stage, s3Write: PutObjectRequest => Try[PutObjectResult])(downloadStream: DownloadStream, queryName: String): ClientFailableOp[String] = {\n+\n+    val metadata = new ObjectMetadata()\n+    metadata.setContentLength(downloadStream.lengthBytes)\n+\n+    val destBucket = buckets(stage)\n+    val destKey = s\"${queryName}.csv\" //todo do we want any type of directory structure to save the files ?","path":"handlers/zuora-reports/src/main/scala/com/gu/zuora/reports/S3ReportUploader.scala","position":25,"original_position":25,"commit_id":"d799c72fc608bf4277302c082523449b9cb03837","original_commit_id":"d799c72fc608bf4277302c082523449b9cb03837","user":{"login":"pvighi","id":15324270,"node_id":"MDQ6VXNlcjE1MzI0Mjcw","avatar_url":"https://avatars3.githubusercontent.com/u/15324270?v=4","gravatar_id":"","url":"https://api.github.com/users/pvighi","html_url":"https://github.com/pvighi","followers_url":"https://api.github.com/users/pvighi/followers","following_url":"https://api.github.com/users/pvighi/following{/other_user}","gists_url":"https://api.github.com/users/pvighi/gists{/gist_id}","starred_url":"https://api.github.com/users/pvighi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvighi/subscriptions","organizations_url":"https://api.github.com/users/pvighi/orgs","repos_url":"https://api.github.com/users/pvighi/repos","events_url":"https://api.github.com/users/pvighi/events{/privacy}","received_events_url":"https://api.github.com/users/pvighi/received_events","type":"User","site_admin":false},"body":"Should we have some sort of folder structure in the results bucket or should everything be thrown together in the same place. I'm now thinking that with the code as it is reports with the same name will overwrite each other so we might need to do something if we want to avoid that","created_at":"2018-06-05T17:23:50Z","updated_at":"2018-06-05T17:23:50Z","html_url":"https://github.com/guardian/zuora-auto-cancel/pull/107#discussion_r193155314","pull_request_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/comments/193155314"},"html":{"href":"https://github.com/guardian/zuora-auto-cancel/pull/107#discussion_r193155314"},"pull_request":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107","id":192780048,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNzgwMDQ4","html_url":"https://github.com/guardian/zuora-auto-cancel/pull/107","diff_url":"https://github.com/guardian/zuora-auto-cancel/pull/107.diff","patch_url":"https://github.com/guardian/zuora-auto-cancel/pull/107.patch","issue_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/107","number":107,"state":"open","locked":false,"title":"Zuora reports fetch files and some extra stuff","user":{"login":"pvighi","id":15324270,"node_id":"MDQ6VXNlcjE1MzI0Mjcw","avatar_url":"https://avatars3.githubusercontent.com/u/15324270?v=4","gravatar_id":"","url":"https://api.github.com/users/pvighi","html_url":"https://github.com/pvighi","followers_url":"https://api.github.com/users/pvighi/followers","following_url":"https://api.github.com/users/pvighi/following{/other_user}","gists_url":"https://api.github.com/users/pvighi/gists{/gist_id}","starred_url":"https://api.github.com/users/pvighi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvighi/subscriptions","organizations_url":"https://api.github.com/users/pvighi/orgs","repos_url":"https://api.github.com/users/pvighi/repos","events_url":"https://api.github.com/users/pvighi/events{/privacy}","received_events_url":"https://api.github.com/users/pvighi/received_events","type":"User","site_admin":false},"body":"* added file fetcher lambda : downloads query results from Zuora and stores them in S3\r\n* improved getJobStatus response to be easier to parse: it now contains a status that could be pending or completed\r\n* added manual testing to run the lambda code in dev without having to deploy it\r\n* added some documentation\r\n* added export statements to cloudformation template","created_at":"2018-06-05T17:21:28Z","updated_at":"2018-06-05T17:23:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d079beacc628cd0f4929d82a2f1c212f18ace828","assignee":null,"assignees":[],"requested_reviewers":[{"login":"johnduffell","id":7304387,"node_id":"MDQ6VXNlcjczMDQzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/7304387?v=4","gravatar_id":"","url":"https://api.github.com/users/johnduffell","html_url":"https://github.com/johnduffell","followers_url":"https://api.github.com/users/johnduffell/followers","following_url":"https://api.github.com/users/johnduffell/following{/other_user}","gists_url":"https://api.github.com/users/johnduffell/gists{/gist_id}","starred_url":"https://api.github.com/users/johnduffell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnduffell/subscriptions","organizations_url":"https://api.github.com/users/johnduffell/orgs","repos_url":"https://api.github.com/users/johnduffell/repos","events_url":"https://api.github.com/users/johnduffell/events{/privacy}","received_events_url":"https://api.github.com/users/johnduffell/received_events","type":"User","site_admin":false},{"login":"jacobwinch","id":19384074,"node_id":"MDQ6VXNlcjE5Mzg0MDc0","avatar_url":"https://avatars3.githubusercontent.com/u/19384074?v=4","gravatar_id":"","url":"https://api.github.com/users/jacobwinch","html_url":"https://github.com/jacobwinch","followers_url":"https://api.github.com/users/jacobwinch/followers","following_url":"https://api.github.com/users/jacobwinch/following{/other_user}","gists_url":"https://api.github.com/users/jacobwinch/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobwinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobwinch/subscriptions","organizations_url":"https://api.github.com/users/jacobwinch/orgs","repos_url":"https://api.github.com/users/jacobwinch/repos","events_url":"https://api.github.com/users/jacobwinch/events{/privacy}","received_events_url":"https://api.github.com/users/jacobwinch/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107/commits","review_comments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107/comments","review_comment_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/107/comments","statuses_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/statuses/d799c72fc608bf4277302c082523449b9cb03837","head":{"label":"guardian:zuora-reports-fetchFile","ref":"zuora-reports-fetchFile","sha":"d799c72fc608bf4277302c082523449b9cb03837","user":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":80627505,"node_id":"MDEwOlJlcG9zaXRvcnk4MDYyNzUwNQ==","name":"zuora-auto-cancel","full_name":"guardian/zuora-auto-cancel","owner":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/zuora-auto-cancel","description":"Lambdas covering supporter operations, mostly in life operations","fork":false,"url":"https://api.github.com/repos/guardian/zuora-auto-cancel","forks_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/forks","keys_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/teams","hooks_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/hooks","issue_events_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/events","assignees_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/tags","blobs_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/languages","stargazers_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/stargazers","contributors_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/contributors","subscribers_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/subscribers","subscription_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/subscription","commits_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/merges","archive_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/downloads","issues_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/labels{/name}","releases_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/deployments","created_at":"2017-02-01T14:25:47Z","updated_at":"2018-06-05T08:09:07Z","pushed_at":"2018-06-05T17:21:29Z","git_url":"git://github.com/guardian/zuora-auto-cancel.git","ssh_url":"git@github.com:guardian/zuora-auto-cancel.git","clone_url":"https://github.com/guardian/zuora-auto-cancel.git","svn_url":"https://github.com/guardian/zuora-auto-cancel","homepage":"","size":1002,"stargazers_count":3,"watchers_count":3,"language":"Scala","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":1,"license":null,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"b96dc3ec80fec1f0a5c970b682b0f2a0fedd3ff8","user":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":80627505,"node_id":"MDEwOlJlcG9zaXRvcnk4MDYyNzUwNQ==","name":"zuora-auto-cancel","full_name":"guardian/zuora-auto-cancel","owner":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/zuora-auto-cancel","description":"Lambdas covering supporter operations, mostly in life operations","fork":false,"url":"https://api.github.com/repos/guardian/zuora-auto-cancel","forks_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/forks","keys_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/teams","hooks_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/hooks","issue_events_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/events","assignees_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/tags","blobs_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/languages","stargazers_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/stargazers","contributors_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/contributors","subscribers_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/subscribers","subscription_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/subscription","commits_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/merges","archive_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/downloads","issues_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/labels{/name}","releases_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/zuora-auto-cancel/deployments","created_at":"2017-02-01T14:25:47Z","updated_at":"2018-06-05T08:09:07Z","pushed_at":"2018-06-05T17:21:29Z","git_url":"git://github.com/guardian/zuora-auto-cancel.git","ssh_url":"git@github.com:guardian/zuora-auto-cancel.git","clone_url":"https://github.com/guardian/zuora-auto-cancel.git","svn_url":"https://github.com/guardian/zuora-auto-cancel","homepage":"","size":1002,"stargazers_count":3,"watchers_count":3,"language":"Scala","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":1,"license":null,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107"},"html":{"href":"https://github.com/guardian/zuora-auto-cancel/pull/107"},"issue":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/107"},"comments":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/zuora-auto-cancel/statuses/d799c72fc608bf4277302c082523449b9cb03837"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pvighi"}}