{"action":"created","comment":{"url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/comments/60130468","id":60130468,"diff_hunk":"@@ -70,14 +78,108 @@ function filter_old_indices(current_indices) {\n // was deleted or an error\n function delete_index(index) {\n   return new Promise((resolve, reject) => {\n-    request_es(\"del\", `/${index}`).then(() => resolve(index)).catch(reject);\n+    request_es_no_body(\"del\", `/${index}`).then(() => resolve(index)).catch(reject);\n   });\n }\n \n function delete_indices(indices) {\n-  return Promise.all(_.map(indices, (index) => delete_index(index)));\n+  return Promise.all(_.map(indices, delete_index));\n }\n \n export function clear_old_indices() {\n   return get_indices().then(filter_old_indices).then(delete_indices);\n }\n+\n+function get_aliases() {\n+  return new Promise((resolve, reject) => {\n+    get_es(\"/_aliases\").then((indices) => {\n+      // The aliases endpoint returns a map from index name to metadata about those indexes.\n+      // e.g.\n+      //   {\n+      //     \".kibana-4\": {\n+      //       \"aliases\": {}\n+      //     },\n+      //     \"logs-2016.04.02\": {\n+      //       \"aliases\": {\n+      //         \"last_2days\": {},\n+      //         \"last_2weeks\": {},\n+      //         \"last_day\": {},\n+      //         \"last_week\": {}\n+      //       }\n+      //     },\n+      //   }\n+      // It's much easier to work with a map from alias name to list of indexes in the alias.\n+      const aliases = {};\n+      for (const index of Object.keys(indices)) {\n+        // Filter out the kibana index\n+        if (index.indexOf(\".kibana\") !== -1) {\n+          continue;\n+        }\n+        for (const alias of Object.keys(indices[index].aliases)) {\n+          if (!aliases[alias]) {\n+            aliases[alias] = [];\n+          }\n+          aliases[alias].push(index);\n+          // Keep the results sorted and unique\n+          aliases[alias] = _.chain(aliases[alias]).sortBy(_.identity).uniq(true).value();\n+        }\n+      }\n+\n+      resolve(aliases);\n+    }).catch((err) => {\n+      reject(err);\n+    });\n+  });\n+}\n+\n+function remove_unmanaged_aliases(aliases) {","path":"lib/elasticsearch.ts","position":null,"original_position":105,"commit_id":"4d9af1f09942daf75a11604da019f4a3fede8e74","original_commit_id":"cdf2053021aa7a9eec1e3bd0de1374bf5c617768","user":{"login":"azylman","id":790102,"avatar_url":"https://avatars.githubusercontent.com/u/790102?v=3","gravatar_id":"","url":"https://api.github.com/users/azylman","html_url":"https://github.com/azylman","followers_url":"https://api.github.com/users/azylman/followers","following_url":"https://api.github.com/users/azylman/following{/other_user}","gists_url":"https://api.github.com/users/azylman/gists{/gist_id}","starred_url":"https://api.github.com/users/azylman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azylman/subscriptions","organizations_url":"https://api.github.com/users/azylman/orgs","repos_url":"https://api.github.com/users/azylman/repos","events_url":"https://api.github.com/users/azylman/events{/privacy}","received_events_url":"https://api.github.com/users/azylman/received_events","type":"User","site_admin":false},"body":"https://github.com/Clever/elasticsearch-toolbox/pull/4/commits/4d9af1f09942daf75a11604da019f4a3fede8e74","created_at":"2016-04-18T20:42:27Z","updated_at":"2016-04-18T20:42:27Z","html_url":"https://github.com/Clever/elasticsearch-toolbox/pull/4#discussion_r60130468","pull_request_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/comments/60130468"},"html":{"href":"https://github.com/Clever/elasticsearch-toolbox/pull/4#discussion_r60130468"},"pull_request":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4","id":66910410,"html_url":"https://github.com/Clever/elasticsearch-toolbox/pull/4","diff_url":"https://github.com/Clever/elasticsearch-toolbox/pull/4.diff","patch_url":"https://github.com/Clever/elasticsearch-toolbox/pull/4.patch","issue_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/4","number":4,"state":"open","locked":false,"title":"support keeping aliases up to date","user":{"login":"azylman","id":790102,"avatar_url":"https://avatars.githubusercontent.com/u/790102?v=3","gravatar_id":"","url":"https://api.github.com/users/azylman","html_url":"https://github.com/azylman","followers_url":"https://api.github.com/users/azylman/followers","following_url":"https://api.github.com/users/azylman/following{/other_user}","gists_url":"https://api.github.com/users/azylman/gists{/gist_id}","starred_url":"https://api.github.com/users/azylman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azylman/subscriptions","organizations_url":"https://api.github.com/users/azylman/orgs","repos_url":"https://api.github.com/users/azylman/repos","events_url":"https://api.github.com/users/azylman/events{/privacy}","received_events_url":"https://api.github.com/users/azylman/received_events","type":"User","site_admin":false},"body":"This adds an `/aliases/update` endpoint that updates all specified time-based aliases based on the config. It also adds an optional cron time to update the aliases at.","created_at":"2016-04-18T19:46:04Z","updated_at":"2016-04-18T20:42:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ab72a08bb1d665d563c4802f6d09e0597a6aa24","assignee":{"login":"azylman","id":790102,"avatar_url":"https://avatars.githubusercontent.com/u/790102?v=3","gravatar_id":"","url":"https://api.github.com/users/azylman","html_url":"https://github.com/azylman","followers_url":"https://api.github.com/users/azylman/followers","following_url":"https://api.github.com/users/azylman/following{/other_user}","gists_url":"https://api.github.com/users/azylman/gists{/gist_id}","starred_url":"https://api.github.com/users/azylman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azylman/subscriptions","organizations_url":"https://api.github.com/users/azylman/orgs","repos_url":"https://api.github.com/users/azylman/repos","events_url":"https://api.github.com/users/azylman/events{/privacy}","received_events_url":"https://api.github.com/users/azylman/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4/commits","review_comments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4/comments","review_comment_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/4/comments","statuses_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/statuses/4d9af1f09942daf75a11604da019f4a3fede8e74","head":{"label":"Clever:alias-updates","ref":"alias-updates","sha":"4d9af1f09942daf75a11604da019f4a3fede8e74","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":55640876,"name":"elasticsearch-toolbox","full_name":"Clever/elasticsearch-toolbox","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/elasticsearch-toolbox","description":"Maintenance tooling for Elasticsearch","fork":false,"url":"https://api.github.com/repos/Clever/elasticsearch-toolbox","forks_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/forks","keys_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/teams","hooks_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/hooks","issue_events_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/events","assignees_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/tags","blobs_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/languages","stargazers_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/stargazers","contributors_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/contributors","subscribers_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/subscribers","subscription_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/subscription","commits_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/merges","archive_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/downloads","issues_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/labels{/name}","releases_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/releases{/id}","deployments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/deployments","created_at":"2016-04-06T21:12:27Z","updated_at":"2016-04-13T16:39:52Z","pushed_at":"2016-04-18T20:42:18Z","git_url":"git://github.com/Clever/elasticsearch-toolbox.git","ssh_url":"git@github.com:Clever/elasticsearch-toolbox.git","clone_url":"https://github.com/Clever/elasticsearch-toolbox.git","svn_url":"https://github.com/Clever/elasticsearch-toolbox","homepage":null,"size":53,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Clever:master","ref":"master","sha":"dc6aa0d1843c12cc8b202edcf3e7cb425cb23fed","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":55640876,"name":"elasticsearch-toolbox","full_name":"Clever/elasticsearch-toolbox","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/elasticsearch-toolbox","description":"Maintenance tooling for Elasticsearch","fork":false,"url":"https://api.github.com/repos/Clever/elasticsearch-toolbox","forks_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/forks","keys_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/teams","hooks_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/hooks","issue_events_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/events","assignees_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/tags","blobs_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/languages","stargazers_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/stargazers","contributors_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/contributors","subscribers_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/subscribers","subscription_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/subscription","commits_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/merges","archive_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/downloads","issues_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/labels{/name}","releases_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/releases{/id}","deployments_url":"https://api.github.com/repos/Clever/elasticsearch-toolbox/deployments","created_at":"2016-04-06T21:12:27Z","updated_at":"2016-04-13T16:39:52Z","pushed_at":"2016-04-18T20:42:18Z","git_url":"git://github.com/Clever/elasticsearch-toolbox.git","ssh_url":"git@github.com:Clever/elasticsearch-toolbox.git","clone_url":"https://github.com/Clever/elasticsearch-toolbox.git","svn_url":"https://github.com/Clever/elasticsearch-toolbox","homepage":null,"size":53,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4"},"html":{"href":"https://github.com/Clever/elasticsearch-toolbox/pull/4"},"issue":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/4"},"comments":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/Clever/elasticsearch-toolbox/statuses/4d9af1f09942daf75a11604da019f4a3fede8e74"}}}}