{"action":"created","comment":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/53077361","id":53077361,"diff_hunk":"@@ -0,0 +1,93 @@\n+#!/usr/bin/env python\n+import json\n+import requests\n+from requests.auth import HTTPBasicAuth\n+import ast\n+# from git@github.com:mward29/python-k8sclient.git\n+\n+from st2reactor.sensor.base import Sensor\n+\n+\n+class ThirdPartyResource(Sensor):\n+    def __init__(self, sensor_service, config=None):\n+        super(ThirdPartyResource, self).__init__(sensor_service=sensor_service,\n+                                                 config=config)\n+#        self._labels = self._config['labels'].get('thirdpartyresource', [])\\\n+\n+    def setup(self):\n+        self._logger = self._sensor_service.get_logger(name=self.__class__.__name__)\n+        self._logger.debug('Connecting to Kubernetes via api_client')\n+        extension = self._config['extension_url']\n+        KUBERNETES_API_URL = self._config['kubernetes_api_url'] + extension\n+        user = self._config['user']\n+        password = self._config['password']\n+        verify = self._config['verify']\n+        self.client = requests.get(KUBERNETES_API_URL, auth=HTTPBasicAuth(user, password),\n+                                   verify=verify, stream=True)\n+        pass\n+\n+    def run(self):\n+        self._logger = self._sensor_service.get_logger(name=self.__class__.__name__)\n+        self._logger.debug('Watch Kubernetes for thirdpartyresource information')\n+        r = self.client\n+        lines = r.iter_lines()\n+        # Save the first line for later or just skip it\n+#        first_line = next(lines)\n+        for line in lines:\n+            io = json.dumps(line)","path":"packs/kubernetes/sensors/thirdpartyresource.py","position":32,"original_position":37,"commit_id":"7e1ec1be77dab98db6b199de28a89d418bfe05a7","original_commit_id":"e5a66ad3b0aaf7e952e2742817765d2fb5d785a6","user":{"login":"mward29","id":1389176,"avatar_url":"https://avatars.githubusercontent.com/u/1389176?v=3","gravatar_id":"","url":"https://api.github.com/users/mward29","html_url":"https://github.com/mward29","followers_url":"https://api.github.com/users/mward29/followers","following_url":"https://api.github.com/users/mward29/following{/other_user}","gists_url":"https://api.github.com/users/mward29/gists{/gist_id}","starred_url":"https://api.github.com/users/mward29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mward29/subscriptions","organizations_url":"https://api.github.com/users/mward29/orgs","repos_url":"https://api.github.com/users/mward29/repos","events_url":"https://api.github.com/users/mward29/events{/privacy}","received_events_url":"https://api.github.com/users/mward29/received_events","type":"User","site_admin":false},"body":"The string coming from Kubernetes can not be decoded (json.load) to a json object in its raw form. The json.dump encodes the string to a proper format so json.jump can decode it. I know it looks ackward but it works. It will not work without encoding it first.","created_at":"2016-02-16T20:59:26Z","updated_at":"2016-02-16T20:59:26Z","html_url":"https://github.com/StackStorm/st2contrib/pull/395#discussion_r53077361","pull_request_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395","_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/53077361"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/395#discussion_r53077361"},"pull_request":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395"}}},"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395","id":59242358,"html_url":"https://github.com/StackStorm/st2contrib/pull/395","diff_url":"https://github.com/StackStorm/st2contrib/pull/395.diff","patch_url":"https://github.com/StackStorm/st2contrib/pull/395.patch","issue_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/395","number":395,"state":"open","locked":false,"title":"initial kubernetes pack with thirdpartyresource integration","user":{"login":"mward29","id":1389176,"avatar_url":"https://avatars.githubusercontent.com/u/1389176?v=3","gravatar_id":"","url":"https://api.github.com/users/mward29","html_url":"https://github.com/mward29","followers_url":"https://api.github.com/users/mward29/followers","following_url":"https://api.github.com/users/mward29/following{/other_user}","gists_url":"https://api.github.com/users/mward29/gists{/gist_id}","starred_url":"https://api.github.com/users/mward29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mward29/subscriptions","organizations_url":"https://api.github.com/users/mward29/orgs","repos_url":"https://api.github.com/users/mward29/repos","events_url":"https://api.github.com/users/mward29/events{/privacy}","received_events_url":"https://api.github.com/users/mward29/received_events","type":"User","site_admin":false},"body":"This is an initial Kubernetes integration for ThirdPartyResource. It can watch the Kubernetes API and and trigger and AWS RDS database creation or deletion based.","created_at":"2016-02-12T22:47:00Z","updated_at":"2016-02-16T20:59:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d6caf133476f3468537a6cbdd7a6e08235a181c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395/commits","review_comments_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395/comments","review_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/395/comments","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/7e1ec1be77dab98db6b199de28a89d418bfe05a7","head":{"label":"mward29:master","ref":"master","sha":"7e1ec1be77dab98db6b199de28a89d418bfe05a7","user":{"login":"mward29","id":1389176,"avatar_url":"https://avatars.githubusercontent.com/u/1389176?v=3","gravatar_id":"","url":"https://api.github.com/users/mward29","html_url":"https://github.com/mward29","followers_url":"https://api.github.com/users/mward29/followers","following_url":"https://api.github.com/users/mward29/following{/other_user}","gists_url":"https://api.github.com/users/mward29/gists{/gist_id}","starred_url":"https://api.github.com/users/mward29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mward29/subscriptions","organizations_url":"https://api.github.com/users/mward29/orgs","repos_url":"https://api.github.com/users/mward29/repos","events_url":"https://api.github.com/users/mward29/events{/privacy}","received_events_url":"https://api.github.com/users/mward29/received_events","type":"User","site_admin":false},"repo":{"id":51621292,"name":"st2contrib","full_name":"mward29/st2contrib","owner":{"login":"mward29","id":1389176,"avatar_url":"https://avatars.githubusercontent.com/u/1389176?v=3","gravatar_id":"","url":"https://api.github.com/users/mward29","html_url":"https://github.com/mward29","followers_url":"https://api.github.com/users/mward29/followers","following_url":"https://api.github.com/users/mward29/following{/other_user}","gists_url":"https://api.github.com/users/mward29/gists{/gist_id}","starred_url":"https://api.github.com/users/mward29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mward29/subscriptions","organizations_url":"https://api.github.com/users/mward29/orgs","repos_url":"https://api.github.com/users/mward29/repos","events_url":"https://api.github.com/users/mward29/events{/privacy}","received_events_url":"https://api.github.com/users/mward29/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mward29/st2contrib","description":"StackStorm integration packs for many common tools and also helpful tools to build integrations and automations with StackStorm.","fork":true,"url":"https://api.github.com/repos/mward29/st2contrib","forks_url":"https://api.github.com/repos/mward29/st2contrib/forks","keys_url":"https://api.github.com/repos/mward29/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mward29/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mward29/st2contrib/teams","hooks_url":"https://api.github.com/repos/mward29/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/mward29/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/mward29/st2contrib/events","assignees_url":"https://api.github.com/repos/mward29/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/mward29/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/mward29/st2contrib/tags","blobs_url":"https://api.github.com/repos/mward29/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mward29/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mward29/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/mward29/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mward29/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/mward29/st2contrib/languages","stargazers_url":"https://api.github.com/repos/mward29/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/mward29/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/mward29/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/mward29/st2contrib/subscription","commits_url":"https://api.github.com/repos/mward29/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/mward29/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/mward29/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/mward29/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/mward29/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/mward29/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mward29/st2contrib/merges","archive_url":"https://api.github.com/repos/mward29/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mward29/st2contrib/downloads","issues_url":"https://api.github.com/repos/mward29/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/mward29/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/mward29/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/mward29/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mward29/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/mward29/st2contrib/releases{/id}","deployments_url":"https://api.github.com/repos/mward29/st2contrib/deployments","created_at":"2016-02-12T22:39:58Z","updated_at":"2016-02-15T12:57:01Z","pushed_at":"2016-02-16T19:59:23Z","git_url":"git://github.com/mward29/st2contrib.git","ssh_url":"git@github.com:mward29/st2contrib.git","clone_url":"https://github.com/mward29/st2contrib.git","svn_url":"https://github.com/mward29/st2contrib","homepage":"http://www.stackstorm.com/community","size":4315,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"StackStorm:master","ref":"master","sha":"ba3b1ad9284b1b4678ee0b3d156415aa1d62090e","user":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"repo":{"id":24968227,"name":"st2contrib","full_name":"StackStorm/st2contrib","owner":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StackStorm/st2contrib","description":"StackStorm integration packs for many common tools and also helpful tools to build integrations and automations with StackStorm.","fork":false,"url":"https://api.github.com/repos/StackStorm/st2contrib","forks_url":"https://api.github.com/repos/StackStorm/st2contrib/forks","keys_url":"https://api.github.com/repos/StackStorm/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StackStorm/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StackStorm/st2contrib/teams","hooks_url":"https://api.github.com/repos/StackStorm/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/StackStorm/st2contrib/events","assignees_url":"https://api.github.com/repos/StackStorm/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/StackStorm/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/StackStorm/st2contrib/tags","blobs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StackStorm/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/StackStorm/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/StackStorm/st2contrib/languages","stargazers_url":"https://api.github.com/repos/StackStorm/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/StackStorm/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/StackStorm/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/StackStorm/st2contrib/subscription","commits_url":"https://api.github.com/repos/StackStorm/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/StackStorm/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/StackStorm/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/StackStorm/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StackStorm/st2contrib/merges","archive_url":"https://api.github.com/repos/StackStorm/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StackStorm/st2contrib/downloads","issues_url":"https://api.github.com/repos/StackStorm/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/StackStorm/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/StackStorm/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StackStorm/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/StackStorm/st2contrib/releases{/id}","deployments_url":"https://api.github.com/repos/StackStorm/st2contrib/deployments","created_at":"2014-10-09T01:19:56Z","updated_at":"2016-02-16T08:12:43Z","pushed_at":"2016-02-16T19:59:24Z","git_url":"git://github.com/StackStorm/st2contrib.git","ssh_url":"git@github.com:StackStorm/st2contrib.git","clone_url":"https://github.com/StackStorm/st2contrib.git","svn_url":"https://github.com/StackStorm/st2contrib","homepage":"http://www.stackstorm.com/community","size":4504,"stargazers_count":69,"watchers_count":69,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":70,"mirror_url":null,"open_issues_count":25,"forks":70,"open_issues":25,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/395"},"issue":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/395"},"comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/395/comments"},"review_comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395/comments"},"review_comment":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/395/commits"},"statuses":{"href":"https://api.github.com/repos/StackStorm/st2contrib/statuses/7e1ec1be77dab98db6b199de28a89d418bfe05a7"}}}}