Search in sources :

Example 21 with OK

use of org.elasticsearch.rest.RestStatus.OK in project elasticsearch by elastic.

the class RestRecoveryAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final RecoveryRequest recoveryRequest = new RecoveryRequest(Strings.splitStringByCommaToArray(request.param("index")));
    recoveryRequest.detailed(request.paramAsBoolean("detailed", false));
    recoveryRequest.activeOnly(request.paramAsBoolean("active_only", false));
    recoveryRequest.indicesOptions(IndicesOptions.fromRequest(request, recoveryRequest.indicesOptions()));
    return channel -> client.admin().indices().recoveries(recoveryRequest, new RestBuilderListener<RecoveryResponse>(channel) {

        @Override
        public RestResponse buildResponse(RecoveryResponse response, XContentBuilder builder) throws Exception {
            response.detailed(recoveryRequest.detailed());
            builder.startObject();
            response.toXContent(builder, request);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) RecoveryResponse(org.elasticsearch.action.admin.indices.recovery.RecoveryResponse) GET(org.elasticsearch.rest.RestRequest.Method.GET) RestResponse(org.elasticsearch.rest.RestResponse) RecoveryRequest(org.elasticsearch.action.admin.indices.recovery.RecoveryRequest) RestBuilderListener(org.elasticsearch.rest.action.RestBuilderListener) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) Settings(org.elasticsearch.common.settings.Settings) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RestRequest(org.elasticsearch.rest.RestRequest) OK(org.elasticsearch.rest.RestStatus.OK) NodeClient(org.elasticsearch.client.node.NodeClient) RecoveryRequest(org.elasticsearch.action.admin.indices.recovery.RecoveryRequest) RestResponse(org.elasticsearch.rest.RestResponse) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) IOException(java.io.IOException) RecoveryResponse(org.elasticsearch.action.admin.indices.recovery.RecoveryResponse)

Aggregations

IOException (java.io.IOException)21 NodeClient (org.elasticsearch.client.node.NodeClient)21 Settings (org.elasticsearch.common.settings.Settings)21 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)21 RestController (org.elasticsearch.rest.RestController)21 RestRequest (org.elasticsearch.rest.RestRequest)21 OK (org.elasticsearch.rest.RestStatus.OK)21 Strings (org.elasticsearch.common.Strings)20 BytesRestResponse (org.elasticsearch.rest.BytesRestResponse)19 GET (org.elasticsearch.rest.RestRequest.Method.GET)19 RestResponse (org.elasticsearch.rest.RestResponse)19 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)18 RestBuilderListener (org.elasticsearch.rest.action.RestBuilderListener)17 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)16 RestActions.buildBroadcastShardsHeader (org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader)8 POST (org.elasticsearch.rest.RestRequest.Method.POST)7 HEAD (org.elasticsearch.rest.RestRequest.Method.HEAD)6 Map (java.util.Map)5 NOT_FOUND (org.elasticsearch.rest.RestStatus.NOT_FOUND)5 ObjectObjectCursor (com.carrotsearch.hppc.cursors.ObjectObjectCursor)4