// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleAction.java
// public class SimpleAction extends Action<SimpleRequest, SimpleResponse, SimpleRequestBuilder> {
// 
//     public static final SimpleAction INSTANCE = new SimpleAction();
//     public static final String NAME = "custom:indices/simple";
// 
//     private SimpleAction() {
//         super(NAME);
//     }
// 
//     @Override
//     public SimpleResponse newResponse() {
//         return new SimpleResponse();
//     }
// 
//     @Override
//     public SimpleRequestBuilder newRequestBuilder(ElasticsearchClient elasticsearchClient) {
//         return new SimpleRequestBuilder(elasticsearchClient, this);
//     }
// 
// }
// 
// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleRequest.java
// public class SimpleRequest extends BroadcastRequest<SimpleRequest> {
// 
//     private String field;
// 
//     SimpleRequest() {
//     }
// 
//     public SimpleRequest(String... indices) {
//         super(indices);
//     }
// 
//     public void setField(String field) {
//         this.field = field;
//     }
// 
//     public String getField() {
//         return field;
//     }
// 
//     @Override
//     public void readFrom(StreamInput in) throws IOException {
//         super.readFrom(in);
//         field = in.readString();
//     }
// 
//     @Override
//     public void writeTo(StreamOutput out) throws IOException {
//         super.writeTo(out);
//         out.writeString(field);
//     }
// }
// 
// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleResponse.java
// public class SimpleResponse extends BroadcastResponse {
// 
//     private Set<String> simple;
// 
//     SimpleResponse() {
//     }
// 
//     SimpleResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures, Set<String> simple) {
//         super(totalShards, successfulShards, failedShards, shardFailures);
//         this.simple = simple;
//     }
// 
//     public Set<String> getSimple() {
//         return simple;
//     }
// 
//     @Override
//     public void readFrom(StreamInput in) throws IOException {
//         super.readFrom(in);
//         int n = in.readInt();
//         simple = new HashSet<String>();
//         for (int i = 0; i < n; i++) {
//             simple.add(in.readString());
//         }
//     }
// 
//     @Override
//     public void writeTo(StreamOutput out) throws IOException {
//         super.writeTo(out);
//         out.writeInt(simple.size());
//         for (String t : simple) {
//             out.writeString(t);
//         }
//     }
// }


import org.elasticsearch.action.simple.SimpleAction;
import org.elasticsearch.action.simple.SimpleRequest;
import org.elasticsearch.action.simple.SimpleResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.action.RestBuilderListener;
import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestStatus.OK;
package org.elasticsearch.rest;





public class RestSimpleAction extends BaseRestHandler {
    @Inject
    public RestSimpleAction(Settings settings, Client client, RestController controller) {
        super(settings);
        controller.registerHandler(POST, "/_simple", this);
        controller.registerHandler(POST, "/{index}/_simple", this);
        controller.registerHandler(POST, "/_simple/{field}", this);
        controller.registerHandler(GET, "/_simple", this);
        controller.registerHandler(GET, "/{index}/_simple", this);
        controller.registerHandler(GET, "/_simple/{field}", this);
    }

    @Override
    protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleAction.java
// public class SimpleAction extends Action<SimpleRequest, SimpleResponse, SimpleRequestBuilder> {
// 
//     public static final SimpleAction INSTANCE = new SimpleAction();
//     public static final String NAME = "custom:indices/simple";
// 
//     private SimpleAction() {
//         super(NAME);
//     }
// 
//     @Override
//     public SimpleResponse newResponse() {
//         return new SimpleResponse();
//     }
// 
//     @Override
//     public SimpleRequestBuilder newRequestBuilder(ElasticsearchClient elasticsearchClient) {
//         return new SimpleRequestBuilder(elasticsearchClient, this);
//     }
// 
// }
// 
// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleRequest.java
// public class SimpleRequest extends BroadcastRequest<SimpleRequest> {
// 
//     private String field;
// 
//     SimpleRequest() {
//     }
// 
//     public SimpleRequest(String... indices) {
//         super(indices);
//     }
// 
//     public void setField(String field) {
//         this.field = field;
//     }
// 
//     public String getField() {
//         return field;
//     }
// 
//     @Override
//     public void readFrom(StreamInput in) throws IOException {
//         super.readFrom(in);
//         field = in.readString();
//     }
// 
//     @Override
//     public void writeTo(StreamOutput out) throws IOException {
//         super.writeTo(out);
//         out.writeString(field);
//     }
// }
// 
// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/action/simple/SimpleResponse.java
// public class SimpleResponse extends BroadcastResponse {
// 
//     private Set<String> simple;
// 
//     SimpleResponse() {
//     }
// 
//     SimpleResponse(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures, Set<String> simple) {
//         super(totalShards, successfulShards, failedShards, shardFailures);
//         this.simple = simple;
//     }
// 
//     public Set<String> getSimple() {
//         return simple;
//     }
// 
//     @Override
//     public void readFrom(StreamInput in) throws IOException {
//         super.readFrom(in);
//         int n = in.readInt();
//         simple = new HashSet<String>();
//         for (int i = 0; i < n; i++) {
//             simple.add(in.readString());
//         }
//     }
// 
//     @Override
//     public void writeTo(StreamOutput out) throws IOException {
//         super.writeTo(out);
//         out.writeInt(simple.size());
//         for (String t : simple) {
//             out.writeString(t);
//         }
//     }
// }


// Path: chapter_17/rest_plugin/src/main/java/org/elasticsearch/rest/RestSimpleAction.java
import org.elasticsearch.action.simple.SimpleAction;
import org.elasticsearch.action.simple.SimpleRequest;
import org.elasticsearch.action.simple.SimpleResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.action.RestBuilderListener;
import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestStatus.OK;

package org.elasticsearch.rest;





public class RestSimpleAction extends BaseRestHandler {
    @Inject
    public RestSimpleAction(Settings settings, Client client, RestController controller) {
        super(settings);
        controller.registerHandler(POST, "/_simple", this);
        controller.registerHandler(POST, "/{index}/_simple", this);
        controller.registerHandler(POST, "/_simple/{field}", this);
        controller.registerHandler(GET, "/_simple", this);
        controller.registerHandler(GET, "/{index}/_simple", this);
        controller.registerHandler(GET, "/_simple/{field}", this);
    }

    @Override
    protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
        final SimpleRequest simpleRequest = new SimpleRequest(Strings.splitStringByCommaToArray(request.param("index")));