{"action":"created","comment":{"url":"https://api.github.com/repos/rapid7/le/pulls/comments/105765815","pull_request_review_id":26660991,"id":105765815,"diff_hunk":"@@ -1752,11 +1870,178 @@ def cmd_ls(args):\n                  hostnames=addr.startswith('hostnames'))\n \n \n+def cmd_add_structure(args):\n+    \"\"\"\n+    Add a new structure command.\n+    Args:\n+        args: structure name followed by (optionally) pattern and priority\n+    \"\"\"\n+    if not args:\n+        utils.error('No structure name specified')\n+    structure_name = args[0].strip()\n+    if not structure_name:\n+        utils.error('Empty structure name')\n+\n+    pattern = ''\n+    priority = -1\n+\n+    # Get and check the pattern\n+    if len(args) > 1:\n+        pattern = args[1]\n+        if not pattern:\n+            utils.error('Pattern in empty')\n+\n+    if len(args) > 2:\n+        try:\n+            priority = int(args[2])\n+            if priority < 0:\n+                utils.error('Priority must be positive')\n+            if priority > MAX_PATTERN_PRIORITY:\n+                utils.error('Priority `%s\\'is above the limit (%s)', args[2], MAX_PATTERN_PRIORITY)\n+        except ValueError:\n+            utils.error('Invalid priority `%s\\', must be a positive integer', args[2])\n+\n+    if len(args) > 3:\n+        utils.error('Too many arguments')\n+\n+    CONFIG.load()\n+    CONFIG.user_key_required(True)\n+\n+    # Get all structures\n+    response = api_v2_request('GET', 'structures', {}, True)\n+    structures = response['structures']\n+\n+    # Find the structure\n+    matches = [s['id'] for s in structures if structure_name.lower() == s['id'].lower() or structure_name == s['name']]\n+    if len(matches) == 0:\n+        # Add the structure\n+        response = api_v2_request('POST', 'structures', {\n+            'name': structure_name,\n+            'shortcut': structure_name,\n+            'description': '',\n+            'aux': {},\n+            }, True)\n+        print >> sys.stderr, 'Added structure `%s\\'' % structure_name","path":"src/le.py","position":258,"original_position":258,"commit_id":"c00514f5f394e51e0852a77a1790df1ea8638438","original_commit_id":"c00514f5f394e51e0852a77a1790df1ea8638438","user":{"login":"jsouthern-r7","id":22777916,"avatar_url":"https://avatars2.githubusercontent.com/u/22777916?v=3","gravatar_id":"","url":"https://api.github.com/users/jsouthern-r7","html_url":"https://github.com/jsouthern-r7","followers_url":"https://api.github.com/users/jsouthern-r7/followers","following_url":"https://api.github.com/users/jsouthern-r7/following{/other_user}","gists_url":"https://api.github.com/users/jsouthern-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/jsouthern-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsouthern-r7/subscriptions","organizations_url":"https://api.github.com/users/jsouthern-r7/orgs","repos_url":"https://api.github.com/users/jsouthern-r7/repos","events_url":"https://api.github.com/users/jsouthern-r7/events{/privacy}","received_events_url":"https://api.github.com/users/jsouthern-r7/received_events","type":"User","site_admin":false},"body":"Consider replacing with...\r\n\r\nprint('Added structure `%s\\'' % structure_name,  file=sys.stderr)","created_at":"2017-03-13T20:40:14Z","updated_at":"2017-03-13T20:40:14Z","html_url":"https://github.com/rapid7/le/pull/208#discussion_r105765815","pull_request_url":"https://api.github.com/repos/rapid7/le/pulls/208","_links":{"self":{"href":"https://api.github.com/repos/rapid7/le/pulls/comments/105765815"},"html":{"href":"https://github.com/rapid7/le/pull/208#discussion_r105765815"},"pull_request":{"href":"https://api.github.com/repos/rapid7/le/pulls/208"}}},"pull_request":{"url":"https://api.github.com/repos/rapid7/le/pulls/208","id":110426233,"html_url":"https://github.com/rapid7/le/pull/208","diff_url":"https://github.com/rapid7/le/pull/208.diff","patch_url":"https://github.com/rapid7/le/pull/208.patch","issue_url":"https://api.github.com/repos/rapid7/le/issues/208","number":208,"state":"open","locked":false,"title":"Merge master into LOG-8778","user":{"login":"jyeung-r7","id":7153785,"avatar_url":"https://avatars2.githubusercontent.com/u/7153785?v=3","gravatar_id":"","url":"https://api.github.com/users/jyeung-r7","html_url":"https://github.com/jyeung-r7","followers_url":"https://api.github.com/users/jyeung-r7/followers","following_url":"https://api.github.com/users/jyeung-r7/following{/other_user}","gists_url":"https://api.github.com/users/jyeung-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/jyeung-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyeung-r7/subscriptions","organizations_url":"https://api.github.com/users/jyeung-r7/orgs","repos_url":"https://api.github.com/users/jyeung-r7/repos","events_url":"https://api.github.com/users/jyeung-r7/events{/privacy}","received_events_url":"https://api.github.com/users/jyeung-r7/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-13T15:13:46Z","updated_at":"2017-03-13T20:40:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4387afc327be945378d8b08a82334c929d3fdb0f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rapid7/le/pulls/208/commits","review_comments_url":"https://api.github.com/repos/rapid7/le/pulls/208/comments","review_comment_url":"https://api.github.com/repos/rapid7/le/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rapid7/le/issues/208/comments","statuses_url":"https://api.github.com/repos/rapid7/le/statuses/c00514f5f394e51e0852a77a1790df1ea8638438","head":{"label":"jyeung-r7:LOG-8778-master","ref":"LOG-8778-master","sha":"c00514f5f394e51e0852a77a1790df1ea8638438","user":{"login":"jyeung-r7","id":7153785,"avatar_url":"https://avatars2.githubusercontent.com/u/7153785?v=3","gravatar_id":"","url":"https://api.github.com/users/jyeung-r7","html_url":"https://github.com/jyeung-r7","followers_url":"https://api.github.com/users/jyeung-r7/followers","following_url":"https://api.github.com/users/jyeung-r7/following{/other_user}","gists_url":"https://api.github.com/users/jyeung-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/jyeung-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyeung-r7/subscriptions","organizations_url":"https://api.github.com/users/jyeung-r7/orgs","repos_url":"https://api.github.com/users/jyeung-r7/repos","events_url":"https://api.github.com/users/jyeung-r7/events{/privacy}","received_events_url":"https://api.github.com/users/jyeung-r7/received_events","type":"User","site_admin":false},"repo":{"id":81867572,"name":"le","full_name":"jyeung-r7/le","owner":{"login":"jyeung-r7","id":7153785,"avatar_url":"https://avatars2.githubusercontent.com/u/7153785?v=3","gravatar_id":"","url":"https://api.github.com/users/jyeung-r7","html_url":"https://github.com/jyeung-r7","followers_url":"https://api.github.com/users/jyeung-r7/followers","following_url":"https://api.github.com/users/jyeung-r7/following{/other_user}","gists_url":"https://api.github.com/users/jyeung-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/jyeung-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyeung-r7/subscriptions","organizations_url":"https://api.github.com/users/jyeung-r7/orgs","repos_url":"https://api.github.com/users/jyeung-r7/repos","events_url":"https://api.github.com/users/jyeung-r7/events{/privacy}","received_events_url":"https://api.github.com/users/jyeung-r7/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jyeung-r7/le","description":"Logentries agent","fork":true,"url":"https://api.github.com/repos/jyeung-r7/le","forks_url":"https://api.github.com/repos/jyeung-r7/le/forks","keys_url":"https://api.github.com/repos/jyeung-r7/le/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jyeung-r7/le/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jyeung-r7/le/teams","hooks_url":"https://api.github.com/repos/jyeung-r7/le/hooks","issue_events_url":"https://api.github.com/repos/jyeung-r7/le/issues/events{/number}","events_url":"https://api.github.com/repos/jyeung-r7/le/events","assignees_url":"https://api.github.com/repos/jyeung-r7/le/assignees{/user}","branches_url":"https://api.github.com/repos/jyeung-r7/le/branches{/branch}","tags_url":"https://api.github.com/repos/jyeung-r7/le/tags","blobs_url":"https://api.github.com/repos/jyeung-r7/le/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jyeung-r7/le/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jyeung-r7/le/git/refs{/sha}","trees_url":"https://api.github.com/repos/jyeung-r7/le/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jyeung-r7/le/statuses/{sha}","languages_url":"https://api.github.com/repos/jyeung-r7/le/languages","stargazers_url":"https://api.github.com/repos/jyeung-r7/le/stargazers","contributors_url":"https://api.github.com/repos/jyeung-r7/le/contributors","subscribers_url":"https://api.github.com/repos/jyeung-r7/le/subscribers","subscription_url":"https://api.github.com/repos/jyeung-r7/le/subscription","commits_url":"https://api.github.com/repos/jyeung-r7/le/commits{/sha}","git_commits_url":"https://api.github.com/repos/jyeung-r7/le/git/commits{/sha}","comments_url":"https://api.github.com/repos/jyeung-r7/le/comments{/number}","issue_comment_url":"https://api.github.com/repos/jyeung-r7/le/issues/comments{/number}","contents_url":"https://api.github.com/repos/jyeung-r7/le/contents/{+path}","compare_url":"https://api.github.com/repos/jyeung-r7/le/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jyeung-r7/le/merges","archive_url":"https://api.github.com/repos/jyeung-r7/le/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jyeung-r7/le/downloads","issues_url":"https://api.github.com/repos/jyeung-r7/le/issues{/number}","pulls_url":"https://api.github.com/repos/jyeung-r7/le/pulls{/number}","milestones_url":"https://api.github.com/repos/jyeung-r7/le/milestones{/number}","notifications_url":"https://api.github.com/repos/jyeung-r7/le/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jyeung-r7/le/labels{/name}","releases_url":"https://api.github.com/repos/jyeung-r7/le/releases{/id}","deployments_url":"https://api.github.com/repos/jyeung-r7/le/deployments","created_at":"2017-02-13T20:20:01Z","updated_at":"2017-02-13T20:20:03Z","pushed_at":"2017-03-13T15:51:10Z","git_url":"git://github.com/jyeung-r7/le.git","ssh_url":"git@github.com:jyeung-r7/le.git","clone_url":"https://github.com/jyeung-r7/le.git","svn_url":"https://github.com/jyeung-r7/le","homepage":"https://logentries.com/","size":5458,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"LOG-8778"}},"base":{"label":"rapid7:LOG-8778","ref":"LOG-8778","sha":"f1a68eb7f064b29cf4b7cfcc9f6bffd43cf98f8f","user":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars2.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"repo":{"id":1468496,"name":"le","full_name":"rapid7/le","owner":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars2.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rapid7/le","description":"Logentries agent","fork":false,"url":"https://api.github.com/repos/rapid7/le","forks_url":"https://api.github.com/repos/rapid7/le/forks","keys_url":"https://api.github.com/repos/rapid7/le/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rapid7/le/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rapid7/le/teams","hooks_url":"https://api.github.com/repos/rapid7/le/hooks","issue_events_url":"https://api.github.com/repos/rapid7/le/issues/events{/number}","events_url":"https://api.github.com/repos/rapid7/le/events","assignees_url":"https://api.github.com/repos/rapid7/le/assignees{/user}","branches_url":"https://api.github.com/repos/rapid7/le/branches{/branch}","tags_url":"https://api.github.com/repos/rapid7/le/tags","blobs_url":"https://api.github.com/repos/rapid7/le/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rapid7/le/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rapid7/le/git/refs{/sha}","trees_url":"https://api.github.com/repos/rapid7/le/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rapid7/le/statuses/{sha}","languages_url":"https://api.github.com/repos/rapid7/le/languages","stargazers_url":"https://api.github.com/repos/rapid7/le/stargazers","contributors_url":"https://api.github.com/repos/rapid7/le/contributors","subscribers_url":"https://api.github.com/repos/rapid7/le/subscribers","subscription_url":"https://api.github.com/repos/rapid7/le/subscription","commits_url":"https://api.github.com/repos/rapid7/le/commits{/sha}","git_commits_url":"https://api.github.com/repos/rapid7/le/git/commits{/sha}","comments_url":"https://api.github.com/repos/rapid7/le/comments{/number}","issue_comment_url":"https://api.github.com/repos/rapid7/le/issues/comments{/number}","contents_url":"https://api.github.com/repos/rapid7/le/contents/{+path}","compare_url":"https://api.github.com/repos/rapid7/le/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rapid7/le/merges","archive_url":"https://api.github.com/repos/rapid7/le/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rapid7/le/downloads","issues_url":"https://api.github.com/repos/rapid7/le/issues{/number}","pulls_url":"https://api.github.com/repos/rapid7/le/pulls{/number}","milestones_url":"https://api.github.com/repos/rapid7/le/milestones{/number}","notifications_url":"https://api.github.com/repos/rapid7/le/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rapid7/le/labels{/name}","releases_url":"https://api.github.com/repos/rapid7/le/releases{/id}","deployments_url":"https://api.github.com/repos/rapid7/le/deployments","created_at":"2011-03-11T16:00:41Z","updated_at":"2017-02-28T23:31:59Z","pushed_at":"2017-03-13T15:29:09Z","git_url":"git://github.com/rapid7/le.git","ssh_url":"git@github.com:rapid7/le.git","clone_url":"https://github.com/rapid7/le.git","svn_url":"https://github.com/rapid7/le","homepage":"https://logentries.com/","size":5304,"stargazers_count":84,"watchers_count":84,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":29,"forks":50,"open_issues":29,"watchers":84,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rapid7/le/pulls/208"},"html":{"href":"https://github.com/rapid7/le/pull/208"},"issue":{"href":"https://api.github.com/repos/rapid7/le/issues/208"},"comments":{"href":"https://api.github.com/repos/rapid7/le/issues/208/comments"},"review_comments":{"href":"https://api.github.com/repos/rapid7/le/pulls/208/comments"},"review_comment":{"href":"https://api.github.com/repos/rapid7/le/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rapid7/le/pulls/208/commits"},"statuses":{"href":"https://api.github.com/repos/rapid7/le/statuses/c00514f5f394e51e0852a77a1790df1ea8638438"}}}}
{"actor":{"display_login":"jsouthern-r7"}}