Internal: move index templates api back to indices category and make put template and create index implement IndicesRequest

Closes #7378
This commit is contained in:
javanna 2014-08-21 16:13:32 +02:00 committed by Luca Cavanna
parent 9a14b3ce6f
commit f4168a6382
5 changed files with 29 additions and 5 deletions

View File

@ -27,8 +27,10 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.bytes.BytesArray;
@ -59,7 +61,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_
* @see org.elasticsearch.client.Requests#createIndexRequest(String)
* @see CreateIndexResponse
*/
public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> {
public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> implements IndicesRequest {
private String cause = "";
@ -108,6 +110,16 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
return validationException;
}
@Override
public String[] indices() {
return new String[]{index};
}
@Override
public IndicesOptions indicesOptions() {
return IndicesOptions.strictSingleIndexNoExpandForbidClosed();
}
/**
* The index name to create.
*/

View File

@ -27,7 +27,7 @@ import org.elasticsearch.client.IndicesAdminClient;
public class DeleteIndexTemplateAction extends IndicesAction<DeleteIndexTemplateRequest, DeleteIndexTemplateResponse, DeleteIndexTemplateRequestBuilder> {
public static final DeleteIndexTemplateAction INSTANCE = new DeleteIndexTemplateAction();
public static final String NAME = "cluster:admin/template/delete";
public static final String NAME = "indices:admin/template/delete";
private DeleteIndexTemplateAction() {
super(NAME);

View File

@ -27,7 +27,7 @@ import org.elasticsearch.client.IndicesAdminClient;
public class GetIndexTemplatesAction extends IndicesAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse, GetIndexTemplatesRequestBuilder> {
public static final GetIndexTemplatesAction INSTANCE = new GetIndexTemplatesAction();
public static final String NAME = "cluster:admin/template/get";
public static final String NAME = "indices:admin/template/get";
protected GetIndexTemplatesAction() {
super(NAME);

View File

@ -27,7 +27,7 @@ import org.elasticsearch.client.IndicesAdminClient;
public class PutIndexTemplateAction extends IndicesAction<PutIndexTemplateRequest, PutIndexTemplateResponse, PutIndexTemplateRequestBuilder> {
public static final PutIndexTemplateAction INSTANCE = new PutIndexTemplateAction();
public static final String NAME = "cluster:admin/template/put";
public static final String NAME = "indices:admin/template/put";
private PutIndexTemplateAction() {
super(NAME);

View File

@ -23,7 +23,9 @@ import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.bytes.BytesArray;
@ -50,7 +52,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.writeSettingsT
/**
* A request to create an index template.
*/
public class PutIndexTemplateRequest extends MasterNodeOperationRequest<PutIndexTemplateRequest> {
public class PutIndexTemplateRequest extends MasterNodeOperationRequest<PutIndexTemplateRequest> implements IndicesRequest {
private String name;
@ -404,6 +406,16 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest<PutIndex
return this;
}
@Override
public String[] indices() {
return new String[]{template};
}
@Override
public IndicesOptions indicesOptions() {
return IndicesOptions.strictExpand();
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);