{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/samson/pulls/comments/78665297","id":78665297,"diff_hunk":"@@ -0,0 +1,50 @@\n+# basic ledger event client\n+#\n+require 'faraday'\n+require 'openssl'\n+\n+LEDGER_HOST = ENV[\"LEDGER_HOST\"].freeze\n+LEDGER_URI = \"/api/v1/events\".freeze\n+LEDGER_TOKEN = ENV.fetch(\"LEDGER_TOKEN\", false)\n+\n+class LedgerClient\n+  def connection\n+    @client ||= Faraday.new(url: \"http://\" + LEDGER_HOST + LEDGER_URI)\n+  end\n+\n+  def deployment(deploy)\n+    event = {\n+      id:           deploy.id,\n+      name:         deploy.project.name,\n+      actor:        deploy.user.name,\n+      status:       deploy.status,\n+      started_at:   deploy.created_at.iso8601,\n+      summary:      deploy.summary,\n+      environment:  deploy.stage.deploy_groups.map(&:environment).uniq.map(&:name).join(\"'\"),\n+      url:          deploy.url,\n+      pods:         deploy.stage.deploy_groups.map(&:permalink)\n+    }\n+    create_event(event)\n+  end\n+\n+  def create_event(event)\n+    events = { \"events\": [ event ]}\n+    results = post(events)\n+    # TODO: raise or display errors if results.status != 200\n+    results\n+  end\n+\n+  def self.post_deployment(deploy)\n+    lc = LedgerClient.new","path":"config/initializers/ledger.rb","position":38,"original_position":38,"commit_id":"4a1b7e86e0b4abd4dc1fe1028058d596fbe39e50","original_commit_id":"4a1b7e86e0b4abd4dc1fe1028058d596fbe39e50","user":{"login":"grosser","id":11367,"avatar_url":"https://avatars.githubusercontent.com/u/11367?v=3","gravatar_id":"","url":"https://api.github.com/users/grosser","html_url":"https://github.com/grosser","followers_url":"https://api.github.com/users/grosser/followers","following_url":"https://api.github.com/users/grosser/following{/other_user}","gists_url":"https://api.github.com/users/grosser/gists{/gist_id}","starred_url":"https://api.github.com/users/grosser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grosser/subscriptions","organizations_url":"https://api.github.com/users/grosser/orgs","repos_url":"https://api.github.com/users/grosser/repos","events_url":"https://api.github.com/users/grosser/events{/privacy}","received_events_url":"https://api.github.com/users/grosser/received_events","type":"User","site_admin":false},"body":"maybe just static methods ... don't really need an instance ...","created_at":"2016-09-13T23:43:45Z","updated_at":"2016-09-13T23:43:45Z","html_url":"https://github.com/zendesk/samson/pull/1274#discussion_r78665297","pull_request_url":"https://api.github.com/repos/zendesk/samson/pulls/1274","_links":{"self":{"href":"https://api.github.com/repos/zendesk/samson/pulls/comments/78665297"},"html":{"href":"https://github.com/zendesk/samson/pull/1274#discussion_r78665297"},"pull_request":{"href":"https://api.github.com/repos/zendesk/samson/pulls/1274"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/samson/pulls/1274","id":85144877,"html_url":"https://github.com/zendesk/samson/pull/1274","diff_url":"https://github.com/zendesk/samson/pull/1274.diff","patch_url":"https://github.com/zendesk/samson/pull/1274.patch","issue_url":"https://api.github.com/repos/zendesk/samson/issues/1274","number":1274,"state":"open","locked":false,"title":"[WIP] simple client to post deployment events to leger","user":{"login":"irwaters","id":155554,"avatar_url":"https://avatars.githubusercontent.com/u/155554?v=3","gravatar_id":"","url":"https://api.github.com/users/irwaters","html_url":"https://github.com/irwaters","followers_url":"https://api.github.com/users/irwaters/followers","following_url":"https://api.github.com/users/irwaters/following{/other_user}","gists_url":"https://api.github.com/users/irwaters/gists{/gist_id}","starred_url":"https://api.github.com/users/irwaters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irwaters/subscriptions","organizations_url":"https://api.github.com/users/irwaters/orgs","repos_url":"https://api.github.com/users/irwaters/repos","events_url":"https://api.github.com/users/irwaters/events{/privacy}","received_events_url":"https://api.github.com/users/irwaters/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-09-13T23:41:08Z","updated_at":"2016-09-13T23:43:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c42c9606d729e202857439d85abc35e22eebd1c5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/samson/pulls/1274/commits","review_comments_url":"https://api.github.com/repos/zendesk/samson/pulls/1274/comments","review_comment_url":"https://api.github.com/repos/zendesk/samson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/samson/issues/1274/comments","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/4a1b7e86e0b4abd4dc1fe1028058d596fbe39e50","head":{"label":"zendesk:irwaters/ledger","ref":"irwaters/ledger","sha":"4a1b7e86e0b4abd4dc1fe1028058d596fbe39e50","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":20208662,"name":"samson","full_name":"zendesk/samson","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/samson","description":"Web interface for deployments","fork":false,"url":"https://api.github.com/repos/zendesk/samson","forks_url":"https://api.github.com/repos/zendesk/samson/forks","keys_url":"https://api.github.com/repos/zendesk/samson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/samson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/samson/teams","hooks_url":"https://api.github.com/repos/zendesk/samson/hooks","issue_events_url":"https://api.github.com/repos/zendesk/samson/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/samson/events","assignees_url":"https://api.github.com/repos/zendesk/samson/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/samson/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/samson/tags","blobs_url":"https://api.github.com/repos/zendesk/samson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/samson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/samson/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/samson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/samson/languages","stargazers_url":"https://api.github.com/repos/zendesk/samson/stargazers","contributors_url":"https://api.github.com/repos/zendesk/samson/contributors","subscribers_url":"https://api.github.com/repos/zendesk/samson/subscribers","subscription_url":"https://api.github.com/repos/zendesk/samson/subscription","commits_url":"https://api.github.com/repos/zendesk/samson/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/samson/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/samson/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/samson/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/samson/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/samson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/samson/merges","archive_url":"https://api.github.com/repos/zendesk/samson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/samson/downloads","issues_url":"https://api.github.com/repos/zendesk/samson/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/samson/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/samson/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/samson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/samson/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/samson/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/samson/deployments","created_at":"2014-05-27T05:55:57Z","updated_at":"2016-09-13T00:39:23Z","pushed_at":"2016-09-13T23:41:08Z","git_url":"git://github.com/zendesk/samson.git","ssh_url":"git@github.com:zendesk/samson.git","clone_url":"https://github.com/zendesk/samson.git","svn_url":"https://github.com/zendesk/samson","homepage":null,"size":208721,"stargazers_count":741,"watchers_count":741,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":144,"mirror_url":null,"open_issues_count":63,"forks":144,"open_issues":63,"watchers":741,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"a8cd38be274bb0cb06278262b739fd810b050caa","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":20208662,"name":"samson","full_name":"zendesk/samson","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/samson","description":"Web interface for deployments","fork":false,"url":"https://api.github.com/repos/zendesk/samson","forks_url":"https://api.github.com/repos/zendesk/samson/forks","keys_url":"https://api.github.com/repos/zendesk/samson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/samson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/samson/teams","hooks_url":"https://api.github.com/repos/zendesk/samson/hooks","issue_events_url":"https://api.github.com/repos/zendesk/samson/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/samson/events","assignees_url":"https://api.github.com/repos/zendesk/samson/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/samson/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/samson/tags","blobs_url":"https://api.github.com/repos/zendesk/samson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/samson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/samson/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/samson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/samson/languages","stargazers_url":"https://api.github.com/repos/zendesk/samson/stargazers","contributors_url":"https://api.github.com/repos/zendesk/samson/contributors","subscribers_url":"https://api.github.com/repos/zendesk/samson/subscribers","subscription_url":"https://api.github.com/repos/zendesk/samson/subscription","commits_url":"https://api.github.com/repos/zendesk/samson/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/samson/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/samson/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/samson/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/samson/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/samson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/samson/merges","archive_url":"https://api.github.com/repos/zendesk/samson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/samson/downloads","issues_url":"https://api.github.com/repos/zendesk/samson/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/samson/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/samson/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/samson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/samson/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/samson/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/samson/deployments","created_at":"2014-05-27T05:55:57Z","updated_at":"2016-09-13T00:39:23Z","pushed_at":"2016-09-13T23:41:08Z","git_url":"git://github.com/zendesk/samson.git","ssh_url":"git@github.com:zendesk/samson.git","clone_url":"https://github.com/zendesk/samson.git","svn_url":"https://github.com/zendesk/samson","homepage":null,"size":208721,"stargazers_count":741,"watchers_count":741,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":144,"mirror_url":null,"open_issues_count":63,"forks":144,"open_issues":63,"watchers":741,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/samson/pulls/1274"},"html":{"href":"https://github.com/zendesk/samson/pull/1274"},"issue":{"href":"https://api.github.com/repos/zendesk/samson/issues/1274"},"comments":{"href":"https://api.github.com/repos/zendesk/samson/issues/1274/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/samson/pulls/1274/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/samson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/samson/pulls/1274/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/samson/statuses/4a1b7e86e0b4abd4dc1fe1028058d596fbe39e50"}}}}
{"actor":{"display_login":"grosser"}}