Search in sources :

Example 1 with UpgradeRequest

use of org.opensearch.action.admin.indices.upgrade.post.UpgradeRequest in project OpenSearch by opensearch-project.

the class RestUpgradeAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    UpgradeRequest upgradeReq = new UpgradeRequest(Strings.splitStringByCommaToArray(request.param("index")));
    upgradeReq.indicesOptions(IndicesOptions.fromRequest(request, upgradeReq.indicesOptions()));
    upgradeReq.upgradeOnlyAncientSegments(request.paramAsBoolean("only_ancient_segments", false));
    return channel -> client.admin().indices().upgrade(upgradeReq, new RestToXContentListener<>(channel));
}
Also used : POST(org.opensearch.rest.RestRequest.Method.POST) List(java.util.List) NodeClient(org.opensearch.client.node.NodeClient) RestToXContentListener(org.opensearch.rest.action.RestToXContentListener) Collections.unmodifiableList(java.util.Collections.unmodifiableList) RestRequest(org.opensearch.rest.RestRequest) Arrays.asList(java.util.Arrays.asList) IOException(java.io.IOException) IndicesOptions(org.opensearch.action.support.IndicesOptions) BaseRestHandler(org.opensearch.rest.BaseRestHandler) UpgradeRequest(org.opensearch.action.admin.indices.upgrade.post.UpgradeRequest) Strings(org.opensearch.common.Strings) UpgradeRequest(org.opensearch.action.admin.indices.upgrade.post.UpgradeRequest)

Aggregations

IOException (java.io.IOException)1 Arrays.asList (java.util.Arrays.asList)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 List (java.util.List)1 UpgradeRequest (org.opensearch.action.admin.indices.upgrade.post.UpgradeRequest)1 IndicesOptions (org.opensearch.action.support.IndicesOptions)1 NodeClient (org.opensearch.client.node.NodeClient)1 Strings (org.opensearch.common.Strings)1 BaseRestHandler (org.opensearch.rest.BaseRestHandler)1 RestRequest (org.opensearch.rest.RestRequest)1 POST (org.opensearch.rest.RestRequest.Method.POST)1 RestToXContentListener (org.opensearch.rest.action.RestToXContentListener)1