diff --git a/docs/reference/indices/aliases.asciidoc b/docs/reference/indices/aliases.asciidoc index 4d07343461b..5451ac530b3 100644 --- a/docs/reference/indices/aliases.asciidoc +++ b/docs/reference/indices/aliases.asciidoc @@ -227,7 +227,7 @@ Possible options: `alias`:: The name of alias to return in the response. Like the index option, this option supports wildcards and the option the specify - multiple alias names separated by a comma. This is a required option. + multiple alias names separated by a comma. `ignore_unavailable`:: What to do is an specified index name doesn't diff --git a/rest-api-spec/api/indices.exists_alias.json b/rest-api-spec/api/indices.exists_alias.json index 3ee49326616..2c286e25517 100644 --- a/rest-api-spec/api/indices.exists_alias.json +++ b/rest-api-spec/api/indices.exists_alias.json @@ -4,7 +4,7 @@ "methods": ["HEAD"], "url": { "path": "/_alias/{name}", - "paths": ["/_alias/{name}", "/{index}/_alias/{name}"], + "paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"], "parts": { "index": { "type" : "list", @@ -12,7 +12,6 @@ }, "name": { "type" : "list", - "required" : true, "description" : "A comma-separated list of alias names to return" } }, diff --git a/rest-api-spec/api/indices.get_alias.json b/rest-api-spec/api/indices.get_alias.json index 4fd1b5223e2..d1d8e7edec3 100644 --- a/rest-api-spec/api/indices.get_alias.json +++ b/rest-api-spec/api/indices.get_alias.json @@ -4,7 +4,7 @@ "methods": ["GET"], "url": { "path": "/_alias/{name}", - "paths": ["/_alias/{name}", "/{index}/_alias/{name}"], + "paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"], "parts": { "index": { "type" : "list", @@ -12,7 +12,6 @@ }, "name": { "type" : "list", - "required" : true, "description" : "A comma-separated list of alias names to return" } }, diff --git a/rest-api-spec/api/indices.get_aliases.json b/rest-api-spec/api/indices.get_aliases.json deleted file mode 100644 index e61dffe421b..00000000000 --- a/rest-api-spec/api/indices.get_aliases.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "indices.get_aliases": { - "documentation": "http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/", - "methods": ["GET"], - "url": { - "path": "/_aliases", - "paths": ["/_aliases", "/{index}/_aliases"], - "parts": { - "index": { - "type" : "list", - "description" : "A comma-separated list of index names to filter aliases" - } - }, - "params": { - "timeout": { - "type" : "time", - "description" : "Explicit operation timeout" - } - } - }, - "body": null - } -} diff --git a/rest-api-spec/test/indices.update_aliases/10_basic.yaml b/rest-api-spec/test/indices.update_aliases/10_basic.yaml index 84012175ada..cc0909d2a28 100644 --- a/rest-api-spec/test/indices.update_aliases/10_basic.yaml +++ b/rest-api-spec/test/indices.update_aliases/10_basic.yaml @@ -31,7 +31,7 @@ - is_true: '' - do: - indices.get_aliases: + indices.get_alias: index: test_index - match: {test_index.aliases.test_alias: {'index_routing': 'routing_value', 'search_routing': 'routing_value'}} diff --git a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 612628a911c..9506030a7b4 100644 --- a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -43,7 +43,6 @@ import org.elasticsearch.rest.action.admin.cluster.snapshots.restore.RestRestore import org.elasticsearch.rest.action.admin.cluster.state.RestClusterStateAction; import org.elasticsearch.rest.action.admin.cluster.stats.RestClusterStatsAction; import org.elasticsearch.rest.action.admin.cluster.tasks.RestPendingClusterTasksAction; -import org.elasticsearch.rest.action.admin.indices.alias.RestGetIndicesAliasesAction; import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction; import org.elasticsearch.rest.action.admin.indices.alias.delete.RestIndexDeleteAliasesAction; import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetAliasesAction; @@ -147,7 +146,6 @@ public class RestActionModule extends AbstractModule { bind(RestIndicesStatsAction.class).asEagerSingleton(); bind(RestIndicesStatusAction.class).asEagerSingleton(); bind(RestIndicesSegmentsAction.class).asEagerSingleton(); - bind(RestGetIndicesAliasesAction.class).asEagerSingleton(); bind(RestGetAliasesAction.class).asEagerSingleton(); bind(RestAliasesExistAction.class).asEagerSingleton(); bind(RestIndexDeleteAliasesAction.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java deleted file mode 100644 index 7a94446cf73..00000000000 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to ElasticSearch and Shay Banon under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. ElasticSearch licenses this - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.admin.indices.alias; - -import com.carrotsearch.hppc.cursors.ObjectCursor; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.Requests; -import org.elasticsearch.cluster.metadata.AliasMetaData; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.*; -import org.elasticsearch.rest.action.support.RestXContentBuilder; - -import java.io.IOException; - -import static org.elasticsearch.rest.RestRequest.Method.GET; -import static org.elasticsearch.rest.RestStatus.OK; - -/** - * - */ -public class RestGetIndicesAliasesAction extends BaseRestHandler { - - @Inject - public RestGetIndicesAliasesAction(Settings settings, Client client, RestController controller) { - super(settings, client); - controller.registerHandler(GET, "/_aliases", this); - controller.registerHandler(GET, "/{index}/_aliases", this); - } - - @Override - public void handleRequest(final RestRequest request, final RestChannel channel) { - final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); - - ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() - .filterRoutingTable(true) - .filterNodes(true) - .filteredIndices(indices); - - clusterStateRequest.listenerThreaded(false); - - client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override - public void onResponse(ClusterStateResponse response) { - try { - MetaData metaData = response.getState().metaData(); - XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); - builder.startObject(); - - for (IndexMetaData indexMetaData : metaData) { - builder.startObject(indexMetaData.index(), XContentBuilder.FieldCaseConversion.NONE); - - builder.startObject("aliases"); - for (ObjectCursor cursor : indexMetaData.aliases().values()) { - AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS); - } - builder.endObject(); - - builder.endObject(); - } - - builder.endObject(); - - channel.sendResponse(new XContentRestResponse(request, OK, builder)); - } catch (Throwable e) { - onFailure(e); - } - } - - @Override - public void onFailure(Throwable e) { - try { - channel.sendResponse(new XContentThrowableRestResponse(request, e)); - } catch (IOException e1) { - logger.error("Failed to send failure response", e1); - } - } - }); - } -} - diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java index de42ea16fa3..78d1177bdc5 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java @@ -51,6 +51,7 @@ public class RestGetAliasesAction extends BaseRestHandler { super(settings, client); controller.registerHandler(GET, "/_alias/{name}", this); controller.registerHandler(GET, "/{index}/_alias/{name}", this); + controller.registerHandler(GET, "/{index}/_alias", this); } @Override diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java index 15285964224..f3e3990c41d 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java @@ -43,6 +43,7 @@ public class RestAliasesExistAction extends BaseRestHandler { super(settings, client); controller.registerHandler(HEAD, "/_alias/{name}", this); controller.registerHandler(HEAD, "/{index}/_alias/{name}", this); + controller.registerHandler(HEAD, "/{index}/_alias", this); } @Override