Search in sources :

Example 6 with AcknowledgedRestListener

use of org.elasticsearch.rest.action.AcknowledgedRestListener in project elasticsearch by elastic.

the class RestOpenIndexAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    OpenIndexRequest openIndexRequest = new OpenIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
    openIndexRequest.timeout(request.paramAsTime("timeout", openIndexRequest.timeout()));
    openIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", openIndexRequest.masterNodeTimeout()));
    openIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, openIndexRequest.indicesOptions()));
    return channel -> client.admin().indices().open(openIndexRequest, new AcknowledgedRestListener<OpenIndexResponse>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Settings(org.elasticsearch.common.settings.Settings) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) OpenIndexRequest(org.elasticsearch.action.admin.indices.open.OpenIndexRequest) Strings(org.elasticsearch.common.Strings) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) OpenIndexRequest(org.elasticsearch.action.admin.indices.open.OpenIndexRequest) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse)

Example 7 with AcknowledgedRestListener

use of org.elasticsearch.rest.action.AcknowledgedRestListener in project elasticsearch by elastic.

the class RestPutIndexTemplateAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
    if (request.hasParam("template")) {
        DEPRECATION_LOGGER.deprecated("Deprecated parameter[template] used, replaced by [index_patterns]");
        putRequest.patterns(Collections.singletonList(request.param("template")));
    } else {
        putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
    }
    putRequest.order(request.paramAsInt("order", putRequest.order()));
    putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
    putRequest.create(request.paramAsBoolean("create", false));
    putRequest.cause(request.param("cause", ""));
    putRequest.source(request.content(), request.getXContentType());
    return channel -> client.admin().indices().putTemplate(putRequest, new AcknowledgedRestListener<>(channel));
}
Also used : Loggers(org.elasticsearch.common.logging.Loggers) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Arrays(java.util.Arrays) DeprecationLogger(org.elasticsearch.common.logging.DeprecationLogger) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) Settings(org.elasticsearch.common.settings.Settings) PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) Collections(java.util.Collections) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest)

Example 8 with AcknowledgedRestListener

use of org.elasticsearch.rest.action.AcknowledgedRestListener in project elasticsearch by elastic.

the class RestCloseIndexAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    CloseIndexRequest closeIndexRequest = new CloseIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
    closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout()));
    closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
    closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
    return channel -> client.admin().indices().close(closeIndexRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) Settings(org.elasticsearch.common.settings.Settings) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest)

Example 9 with AcknowledgedRestListener

use of org.elasticsearch.rest.action.AcknowledgedRestListener in project elasticsearch by elastic.

the class RestDeletePipelineAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
    DeletePipelineRequest request = new DeletePipelineRequest(restRequest.param("id"));
    request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout()));
    request.timeout(restRequest.paramAsTime("timeout", request.timeout()));
    return channel -> client.admin().cluster().deletePipeline(request, new AcknowledgedRestListener<>(channel));
}
Also used : DeletePipelineRequest(org.elasticsearch.action.ingest.DeletePipelineRequest) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Settings(org.elasticsearch.common.settings.Settings) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) DeletePipelineRequest(org.elasticsearch.action.ingest.DeletePipelineRequest) RestController(org.elasticsearch.rest.RestController) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener)

Example 10 with AcknowledgedRestListener

use of org.elasticsearch.rest.action.AcknowledgedRestListener in project elasticsearch by elastic.

the class RestDeleteRepositoryAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteRepositoryRequest deleteRepositoryRequest = deleteRepositoryRequest(request.param("repository"));
    deleteRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteRepositoryRequest.masterNodeTimeout()));
    deleteRepositoryRequest.timeout(request.paramAsTime("timeout", deleteRepositoryRequest.timeout()));
    deleteRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteRepositoryRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().deleteRepository(deleteRepositoryRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) DeleteRepositoryRequest(org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) Settings(org.elasticsearch.common.settings.Settings) DELETE(org.elasticsearch.rest.RestRequest.Method.DELETE) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) Requests.deleteRepositoryRequest(org.elasticsearch.client.Requests.deleteRepositoryRequest) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) DeleteRepositoryRequest(org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)

Aggregations

IOException (java.io.IOException)23 NodeClient (org.elasticsearch.client.node.NodeClient)23 Settings (org.elasticsearch.common.settings.Settings)23 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)23 RestController (org.elasticsearch.rest.RestController)23 RestRequest (org.elasticsearch.rest.RestRequest)23 AcknowledgedRestListener (org.elasticsearch.rest.action.AcknowledgedRestListener)23 Strings (org.elasticsearch.common.Strings)9 POST (org.elasticsearch.rest.RestRequest.Method.POST)6 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)5 XContentParser (org.elasticsearch.common.xcontent.XContentParser)5 DELETE (org.elasticsearch.rest.RestRequest.Method.DELETE)5 PUT (org.elasticsearch.rest.RestRequest.Method.PUT)5 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)4 Map (java.util.Map)3 Set (java.util.Set)3 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)3 AliasActions (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions)3 BytesReference (org.elasticsearch.common.bytes.BytesReference)3 Collections (java.util.Collections)2