Search in sources :

Example 11 with AcknowledgedRestListener

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

the class RestDeleteSnapshotAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteSnapshotRequest deleteSnapshotRequest = deleteSnapshotRequest(request.param("repository"), request.param("snapshot"));
    deleteSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteSnapshotRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().deleteSnapshot(deleteSnapshotRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Requests.deleteSnapshotRequest(org.elasticsearch.client.Requests.deleteSnapshotRequest) 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) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) RestController(org.elasticsearch.rest.RestController) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)

Example 12 with AcknowledgedRestListener

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

the class RestDeleteStoredScriptAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    String id = request.param("id");
    String lang = request.param("lang");
    // name ordering issues in the handlers' paths.
    if (id == null) {
        id = lang;
        lang = null;
    }
    if (lang != null) {
        deprecationLogger.deprecated("specifying lang [" + lang + "] as part of the url path is deprecated");
    }
    DeleteStoredScriptRequest deleteStoredScriptRequest = new DeleteStoredScriptRequest(id, lang);
    return channel -> client.admin().cluster().deleteStoredScript(deleteStoredScriptRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Settings(org.elasticsearch.common.settings.Settings) DELETE(org.elasticsearch.rest.RestRequest.Method.DELETE) RestRequest(org.elasticsearch.rest.RestRequest) DeleteStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) DeleteStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest)

Example 13 with AcknowledgedRestListener

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

the class RestPutRepositoryAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    PutRepositoryRequest putRepositoryRequest = putRepositoryRequest(request.param("repository"));
    try (XContentParser parser = request.contentParser()) {
        putRepositoryRequest.source(parser.mapOrdered());
    }
    putRepositoryRequest.verify(request.paramAsBoolean("verify", true));
    putRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRepositoryRequest.masterNodeTimeout()));
    putRepositoryRequest.timeout(request.paramAsTime("timeout", putRepositoryRequest.timeout()));
    return channel -> client.admin().cluster().putRepository(putRepositoryRequest, new AcknowledgedRestListener<>(channel));
}
Also used : XContentParser(org.elasticsearch.common.xcontent.XContentParser) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) PutRepositoryRequest(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest) POST(org.elasticsearch.rest.RestRequest.Method.POST) Settings(org.elasticsearch.common.settings.Settings) Requests.putRepositoryRequest(org.elasticsearch.client.Requests.putRepositoryRequest) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) PUT(org.elasticsearch.rest.RestRequest.Method.PUT) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) PutRepositoryRequest(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest) XContentParser(org.elasticsearch.common.xcontent.XContentParser)

Example 14 with AcknowledgedRestListener

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

the class RestPutStoredScriptAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    String id = request.param("id");
    String lang = request.param("lang");
    // name ordering issues in the handlers' paths.
    if (id == null) {
        id = lang;
        lang = null;
    }
    BytesReference content = request.content();
    if (lang != null) {
        deprecationLogger.deprecated("specifying lang [" + lang + "] as part of the url path is deprecated, use request content instead");
    }
    PutStoredScriptRequest putRequest = new PutStoredScriptRequest(id, lang, content, request.getXContentType());
    return channel -> client.admin().cluster().putStoredScript(putRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BytesReference(org.elasticsearch.common.bytes.BytesReference) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) POST(org.elasticsearch.rest.RestRequest.Method.POST) PutStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest) Settings(org.elasticsearch.common.settings.Settings) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) BytesReference(org.elasticsearch.common.bytes.BytesReference) PUT(org.elasticsearch.rest.RestRequest.Method.PUT) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) PutStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest)

Example 15 with AcknowledgedRestListener

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

the class RestDeleteIndexTemplateAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name"));
    deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout()));
    return channel -> client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new AcknowledgedRestListener<>(channel));
}
Also used : DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) 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) RestController(org.elasticsearch.rest.RestController) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)

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