Search in sources :

Example 1 with VerifyRepositoryRequest

use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.

the class SnapshotRequestConverters method verifyRepository.

static Request verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest) {
    String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(verifyRepositoryRequest.name()).addPathPartAsIs("_verify").build();
    Request request = new Request(HttpPost.METHOD_NAME, endpoint);
    RequestConverters.Params parameters = new RequestConverters.Params();
    parameters.withMasterTimeout(verifyRepositoryRequest.masterNodeTimeout());
    parameters.withTimeout(verifyRepositoryRequest.timeout());
    request.addParameters(parameters.asMap());
    return request;
}
Also used : CleanupRepositoryRequest(org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest) DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest) CloneSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest) DeleteSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) RestoreSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest) PutRepositoryRequest(org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest) CreateSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) GetSnapshotsRequest(org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest) SnapshotsStatusRequest(org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest)

Example 2 with VerifyRepositoryRequest

use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.

the class SnapshotRequestConvertersTests method testVerifyRepository.

public void testVerifyRepository() {
    Map<String, String> expectedParams = new HashMap<>();
    String repository = RequestConvertersTests.randomIndicesNames(1, 1)[0];
    String endpoint = "/_snapshot/" + repository + "/_verify";
    VerifyRepositoryRequest verifyRepositoryRequest = new VerifyRepositoryRequest(repository);
    RequestConvertersTests.setRandomMasterTimeout(verifyRepositoryRequest, expectedParams);
    RequestConvertersTests.setRandomTimeout(verifyRepositoryRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
    Request request = SnapshotRequestConverters.verifyRepository(verifyRepositoryRequest);
    assertThat(request.getEndpoint(), equalTo(endpoint));
    assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
    assertThat(request.getParameters(), equalTo(expectedParams));
}
Also used : HashMap(java.util.HashMap) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest) RestoreSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest) SnapshotsStatusRequest(org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest) DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) AcknowledgedRequest(org.opensearch.action.support.master.AcknowledgedRequest) DeleteSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) PutRepositoryRequest(org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest) CreateSnapshotRequest(org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) GetSnapshotsRequest(org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)

Example 3 with VerifyRepositoryRequest

use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.

the class SnapshotIT method testVerifyRepository.

public void testVerifyRepository() throws IOException {
    AcknowledgedResponse putRepositoryResponse = createTestRepository("test", FsRepository.TYPE, "{\"location\": \".\"}");
    assertTrue(putRepositoryResponse.isAcknowledged());
    VerifyRepositoryRequest request = new VerifyRepositoryRequest("test");
    VerifyRepositoryResponse response = execute(request, highLevelClient().snapshot()::verifyRepository, highLevelClient().snapshot()::verifyRepositoryAsync);
    assertThat(response.getNodes().size(), equalTo(1));
}
Also used : AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) VerifyRepositoryResponse(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)

Example 4 with VerifyRepositoryRequest

use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.

the class SnapshotClientDocumentationIT method testSnapshotVerifyRepository.

public void testSnapshotVerifyRepository() throws IOException {
    RestHighLevelClient client = highLevelClient();
    createTestRepositories();
    // tag::verify-repository-request
    VerifyRepositoryRequest request = new VerifyRepositoryRequest(repositoryName);
    // end::verify-repository-request
    // tag::verify-repository-request-masterTimeout
    // <1>
    request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
    // <2>
    request.masterNodeTimeout("1m");
    // end::verify-repository-request-masterTimeout
    // tag::verify-repository-request-timeout
    // <1>
    request.timeout(TimeValue.timeValueMinutes(1));
    // <2>
    request.timeout("1m");
    // end::verify-repository-request-timeout
    // tag::verify-repository-execute
    VerifyRepositoryResponse response = client.snapshot().verifyRepository(request, RequestOptions.DEFAULT);
    // end::verify-repository-execute
    // tag::verify-repository-response
    List<VerifyRepositoryResponse.NodeView> repositoryMetadataResponse = response.getNodes();
    // end::verify-repository-response
    assertThat(1, equalTo(repositoryMetadataResponse.size()));
    final boolean async = Booleans.parseBoolean(System.getProperty("tests.rest.async", "false"));
    if (async) {
        assertThat("asyncIntegTest-0", equalTo(repositoryMetadataResponse.get(0).getName()));
    } else {
        assertThat("integTest-0", equalTo(repositoryMetadataResponse.get(0).getName()));
    }
}
Also used : VerifyRepositoryResponse(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)

Example 5 with VerifyRepositoryRequest

use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.

the class RestVerifyRepositoryAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    VerifyRepositoryRequest verifyRepositoryRequest = verifyRepositoryRequest(request.param("repository"));
    verifyRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", verifyRepositoryRequest.masterNodeTimeout()));
    verifyRepositoryRequest.timeout(request.paramAsTime("timeout", verifyRepositoryRequest.timeout()));
    return channel -> client.admin().cluster().verifyRepository(verifyRepositoryRequest, new RestToXContentListener<>(channel));
}
Also used : POST(org.opensearch.rest.RestRequest.Method.POST) List(java.util.List) Requests.verifyRepositoryRequest(org.opensearch.client.Requests.verifyRepositoryRequest) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest) NodeClient(org.opensearch.client.node.NodeClient) RestToXContentListener(org.opensearch.rest.action.RestToXContentListener) RestRequest(org.opensearch.rest.RestRequest) IOException(java.io.IOException) BaseRestHandler(org.opensearch.rest.BaseRestHandler) Collections.singletonList(java.util.Collections.singletonList) VerifyRepositoryRequest(org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)

Aggregations

VerifyRepositoryRequest (org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)5 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 VerifyRepositoryResponse (org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse)2 CreateSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest)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 SnapshotsStatusRequest (org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest)2 IOException (java.io.IOException)1 Collections.singletonList (java.util.Collections.singletonList)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 AcknowledgedRequest (org.opensearch.action.support.master.AcknowledgedRequest)1 AcknowledgedResponse (org.opensearch.action.support.master.AcknowledgedResponse)1 Requests.verifyRepositoryRequest (org.opensearch.client.Requests.verifyRepositoryRequest)1 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)1