Search in sources :

Example 1 with GetRepositoriesRequest

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest in project OpenSearch by opensearch-project.

the class SnapshotRequestConverters method getRepositories.

static Request getRepositories(GetRepositoriesRequest getRepositoriesRequest) {
    String[] repositories = getRepositoriesRequest.repositories() == null ? Strings.EMPTY_ARRAY : getRepositoriesRequest.repositories();
    String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addCommaSeparatedPathParts(repositories).build();
    Request request = new Request(HttpGet.METHOD_NAME, endpoint);
    RequestConverters.Params parameters = new RequestConverters.Params();
    parameters.withMasterTimeout(getRepositoriesRequest.masterNodeTimeout());
    parameters.withLocal(getRepositoriesRequest.local());
    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 GetRepositoriesRequest

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest in project OpenSearch by opensearch-project.

the class SnapshotRequestConvertersTests method testGetRepositories.

public void testGetRepositories() {
    Map<String, String> expectedParams = new HashMap<>();
    StringBuilder endpoint = new StringBuilder("/_snapshot");
    GetRepositoriesRequest getRepositoriesRequest = new GetRepositoriesRequest();
    RequestConvertersTests.setRandomMasterTimeout(getRepositoriesRequest, expectedParams);
    RequestConvertersTests.setRandomLocal(getRepositoriesRequest::local, expectedParams);
    if (randomBoolean()) {
        String[] entries = new String[] { "a", "b", "c" };
        getRepositoriesRequest.repositories(entries);
        endpoint.append("/" + String.join(",", entries));
    }
    Request request = SnapshotRequestConverters.getRepositories(getRepositoriesRequest);
    assertThat(request.getEndpoint(), equalTo(endpoint.toString()));
    assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME));
    assertThat(expectedParams, equalTo(request.getParameters()));
}
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) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)

Example 3 with GetRepositoriesRequest

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest in project OpenSearch by opensearch-project.

the class SnapshotIT method testSnapshotGetDefaultRepositories.

public void testSnapshotGetDefaultRepositories() throws IOException {
    assertTrue(createTestRepository("other", FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    assertTrue(createTestRepository("test", FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    GetRepositoriesResponse response = execute(new GetRepositoriesRequest(), highLevelClient().snapshot()::getRepository, highLevelClient().snapshot()::getRepositoryAsync);
    assertThat(2, equalTo(response.repositories().size()));
}
Also used : GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 4 with GetRepositoriesRequest

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest in project OpenSearch by opensearch-project.

the class SnapshotIT method testSnapshotGetRepositoriesUsingParams.

public void testSnapshotGetRepositoriesUsingParams() throws IOException {
    String testRepository = "test";
    assertTrue(createTestRepository(testRepository, FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    assertTrue(createTestRepository("other", FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    GetRepositoriesRequest request = new GetRepositoriesRequest();
    request.repositories(new String[] { testRepository });
    GetRepositoriesResponse response = execute(request, highLevelClient().snapshot()::getRepository, highLevelClient().snapshot()::getRepositoryAsync);
    assertThat(1, equalTo(response.repositories().size()));
}
Also used : GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 5 with GetRepositoriesRequest

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest in project OpenSearch by opensearch-project.

the class SnapshotClientDocumentationIT method testSnapshotGetRepository.

public void testSnapshotGetRepository() throws IOException {
    RestHighLevelClient client = highLevelClient();
    createTestRepositories();
    // tag::get-repository-request
    GetRepositoriesRequest request = new GetRepositoriesRequest();
    // end::get-repository-request
    // tag::get-repository-request-repositories
    String[] repositories = new String[] { repositoryName };
    // <1>
    request.repositories(repositories);
    // end::get-repository-request-repositories
    // tag::get-repository-request-local
    // <1>
    request.local(true);
    // end::get-repository-request-local
    // tag::get-repository-request-masterTimeout
    // <1>
    request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
    // <2>
    request.masterNodeTimeout("1m");
    // end::get-repository-request-masterTimeout
    // tag::get-repository-execute
    GetRepositoriesResponse response = client.snapshot().getRepository(request, RequestOptions.DEFAULT);
    // end::get-repository-execute
    // tag::get-repository-response
    List<RepositoryMetadata> repositoryMetadataResponse = response.repositories();
    // end::get-repository-response
    assertThat(1, equalTo(repositoryMetadataResponse.size()));
    assertThat(repositoryName, equalTo(repositoryMetadataResponse.get(0).name()));
}
Also used : RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Aggregations

GetRepositoriesRequest (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)9 GetRepositoriesResponse (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)5 DeleteRepositoryRequest (org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)3 List (java.util.List)2 PutRepositoryRequest (org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest)2 VerifyRepositoryRequest (org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest)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 NodeClient (org.opensearch.client.node.NodeClient)2 RepositoryMetadata (org.opensearch.cluster.metadata.RepositoryMetadata)2 RestRequest (org.opensearch.rest.RestRequest)2 GET (org.opensearch.rest.RestRequest.Method.GET)2 IOException (java.io.IOException)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 HashMap (java.util.HashMap)1