Search in sources :

Example 6 with SnapshotsStatusRequest

use of org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest in project OpenSearch by opensearch-project.

the class RestSnapshotsStatusAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    String repository = request.param("repository", "_all");
    String[] snapshots = request.paramAsStringArray("snapshot", Strings.EMPTY_ARRAY);
    if (snapshots.length == 1 && "_all".equalsIgnoreCase(snapshots[0])) {
        snapshots = Strings.EMPTY_ARRAY;
    }
    SnapshotsStatusRequest snapshotsStatusRequest = snapshotsStatusRequest(repository).snapshots(snapshots);
    snapshotsStatusRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", snapshotsStatusRequest.ignoreUnavailable()));
    snapshotsStatusRequest.masterNodeTimeout(request.paramAsTime("master_timeout", snapshotsStatusRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().snapshotsStatus(snapshotsStatusRequest, new RestToXContentListener<>(channel));
}
Also used : List(java.util.List) NodeClient(org.opensearch.client.node.NodeClient) RestToXContentListener(org.opensearch.rest.action.RestToXContentListener) Collections.unmodifiableList(java.util.Collections.unmodifiableList) GET(org.opensearch.rest.RestRequest.Method.GET) RestRequest(org.opensearch.rest.RestRequest) Arrays.asList(java.util.Arrays.asList) IOException(java.io.IOException) BaseRestHandler(org.opensearch.rest.BaseRestHandler) SnapshotsStatusRequest(org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest) Requests.snapshotsStatusRequest(org.opensearch.client.Requests.snapshotsStatusRequest) Strings(org.opensearch.common.Strings) SnapshotsStatusRequest(org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest)

Aggregations

SnapshotsStatusRequest (org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest)6 CreateSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest)3 DeleteRepositoryRequest (org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)2 GetRepositoriesRequest (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)2 PutRepositoryRequest (org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest)2 VerifyRepositoryRequest (org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)2 DeleteSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)2 GetSnapshotsRequest (org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest)2 RestoreSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest)2 SnapshotStatus (org.opensearch.action.admin.cluster.snapshots.status.SnapshotStatus)2 SnapshotsStatusResponse (org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse)2 IOException (java.io.IOException)1 Arrays.asList (java.util.Arrays.asList)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CleanupRepositoryRequest (org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest)1 CloneSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest)1 CreateSnapshotResponse (org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse)1 SnapshotStats (org.opensearch.action.admin.cluster.snapshots.status.SnapshotStats)1