{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/65777101","id":65777101,"diff_hunk":"@@ -0,0 +1,72 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.elasticsearch.rest.action.admin.indices;\n+\n+import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;\n+import org.elasticsearch.action.admin.indices.rollover.RolloverResponse;\n+import org.elasticsearch.client.Client;\n+import org.elasticsearch.common.inject.Inject;\n+import org.elasticsearch.common.settings.Settings;\n+import org.elasticsearch.common.xcontent.XContentBuilder;\n+import org.elasticsearch.rest.BaseRestHandler;\n+import org.elasticsearch.rest.BytesRestResponse;\n+import org.elasticsearch.rest.RestChannel;\n+import org.elasticsearch.rest.RestController;\n+import org.elasticsearch.rest.RestRequest;\n+import org.elasticsearch.rest.RestResponse;\n+import org.elasticsearch.rest.action.support.RestBuilderListener;\n+\n+import static org.elasticsearch.rest.RestStatus.OK;\n+\n+/**\n+ *\n+ */\n+public class RestRolloverIndexAction extends BaseRestHandler {\n+\n+    @Inject\n+    public RestRolloverIndexAction(Settings settings, RestController controller, Client client) {\n+        super(settings, client);\n+        controller.registerHandler(RestRequest.Method.PUT, \"/{alias}/_rollover/{optional_alias}\", this);\n+        controller.registerHandler(RestRequest.Method.POST, \"/{alias}/_rollover/{optional_alias}\", this);\n+    }\n+\n+    @Override\n+    public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {\n+        if (request.param(\"alias\") == null) {\n+            throw new IllegalArgumentException(\"no source alias\");\n+        }\n+        RolloverRequest rolloverIndexRequest = new RolloverRequest(request.param(\"alias\"), request.param(\"optional_alias\"));\n+        if (request.hasContent()) {\n+            rolloverIndexRequest.source(request.content());\n+        }\n+        rolloverIndexRequest.timeout(request.paramAsTime(\"timeout\", rolloverIndexRequest.timeout()));\n+        rolloverIndexRequest.masterNodeTimeout(request.paramAsTime(\"master_timeout\", rolloverIndexRequest.masterNodeTimeout()));\n+        client.admin().indices().rolloverIndex(rolloverIndexRequest, new RestBuilderListener<RolloverResponse>(channel) {","path":"core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java","position":61,"original_position":61,"commit_id":"a30437f2505a1599bffd14be7a36c67489687dad","original_commit_id":"a30437f2505a1599bffd14be7a36c67489687dad","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"++","created_at":"2016-06-03T21:18:44Z","updated_at":"2016-06-03T21:18:44Z","html_url":"https://github.com/elastic/elasticsearch/pull/18732#discussion_r65777101","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/65777101"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/18732#discussion_r65777101"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732","id":72563149,"html_url":"https://github.com/elastic/elasticsearch/pull/18732","diff_url":"https://github.com/elastic/elasticsearch/pull/18732.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/18732.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18732","number":18732,"state":"open","locked":false,"title":"Add rollover API to switch index aliases given some predicates","user":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"body":"This adds a `_rollover` API (https://github.com/elastic/elasticsearch/issues/18647) to swap the index pointed through an alias, \r\ngiven some predicates are satisfied. \r\nThe API expects an alias which points to a single index. Upon satisfying \r\nall the provide conditions (`max_age`, `max_docs` and `max_size` of the index), \r\nthe alias is changed to point to a new index. \r\nThe new index name is generated using the following:\r\n - if the old index name is not in `{index_name_prefix}_{num}`, \r\n   appending a numerical value to the old index name (`{old_index}_{num}`) \r\n - if the old index name has the `{index_name_prefix}_{num}` format, \r\n   the new index is named as `{index_name_prefix}_{num+1}`\r\n\r\nIf the new index does not exist, then the API automatically creates the index \r\n(index settings can be configured only through matching index templates for now). \r\nWhen the given conditions are not met, the response returns with the same index\r\nname for both `old_index` and `new_index`.\r\n\r\nWould love to get some feedback on the implementation.\r\nWIP: documentation\r\n\r\ncloses #18647\r\n","created_at":"2016-06-03T20:11:26Z","updated_at":"2016-06-03T21:18:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9c67612fe9571356aa2a478462cfe62bb8e2c80","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18732/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/a30437f2505a1599bffd14be7a36c67489687dad","head":{"label":"areek:enhancement/rollover_api","ref":"enhancement/rollover_api","sha":"a30437f2505a1599bffd14be7a36c67489687dad","user":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"repo":{"id":16661385,"name":"elasticsearch","full_name":"areek/elasticsearch","owner":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/areek/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/areek/elasticsearch","forks_url":"https://api.github.com/repos/areek/elasticsearch/forks","keys_url":"https://api.github.com/repos/areek/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/areek/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/areek/elasticsearch/teams","hooks_url":"https://api.github.com/repos/areek/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/areek/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/areek/elasticsearch/events","assignees_url":"https://api.github.com/repos/areek/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/areek/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/areek/elasticsearch/tags","blobs_url":"https://api.github.com/repos/areek/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/areek/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/areek/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/areek/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/areek/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/areek/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/areek/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/areek/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/areek/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/areek/elasticsearch/subscription","commits_url":"https://api.github.com/repos/areek/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/areek/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/areek/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/areek/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/areek/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/areek/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/areek/elasticsearch/merges","archive_url":"https://api.github.com/repos/areek/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/areek/elasticsearch/downloads","issues_url":"https://api.github.com/repos/areek/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/areek/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/areek/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/areek/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/areek/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/areek/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/areek/elasticsearch/deployments","created_at":"2014-02-09T06:24:53Z","updated_at":"2015-12-09T01:17:39Z","pushed_at":"2016-06-03T20:09:34Z","git_url":"git://github.com/areek/elasticsearch.git","ssh_url":"git@github.com:areek/elasticsearch.git","clone_url":"https://github.com/areek/elasticsearch.git","svn_url":"https://github.com/areek/elasticsearch","homepage":"http://elasticsearch.org","size":210050,"stargazers_count":1,"watchers_count":1,"language":"Java","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":"elastic:master","ref":"master","sha":"92c6d78d4a17213ebed306f7f7646041bb0fcfe4","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-06-03T19:57:25Z","pushed_at":"2016-06-03T20:34:42Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":321987,"stargazers_count":16790,"watchers_count":16790,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5676,"mirror_url":null,"open_issues_count":1070,"forks":5676,"open_issues":1070,"watchers":16790,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/18732"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/18732"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/18732/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18732/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/a30437f2505a1599bffd14be7a36c67489687dad"}}}}
{"actor":{"display_login":"s1monw"}}