Search in sources :

Example 6 with GetRepositoriesRequest

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

the class RestRepositoriesAction method doCatRequest.

@Override
protected RestChannelConsumer doCatRequest(RestRequest request, NodeClient client) {
    GetRepositoriesRequest getRepositoriesRequest = new GetRepositoriesRequest();
    getRepositoriesRequest.local(request.paramAsBoolean("local", getRepositoriesRequest.local()));
    getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().getRepositories(getRepositoriesRequest, new RestResponseListener<GetRepositoriesResponse>(channel) {

        @Override
        public RestResponse buildResponse(GetRepositoriesResponse getRepositoriesResponse) throws Exception {
            return RestTable.buildResponse(buildTable(request, getRepositoriesResponse), channel);
        }
    });
}
Also used : List(java.util.List) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) NodeClient(org.opensearch.client.node.NodeClient) GET(org.opensearch.rest.RestRequest.Method.GET) RestRequest(org.opensearch.rest.RestRequest) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) Table(org.opensearch.common.Table) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse) RestResponse(org.opensearch.rest.RestResponse) RestResponseListener(org.opensearch.rest.action.RestResponseListener) Collections.singletonList(java.util.Collections.singletonList) RestResponse(org.opensearch.rest.RestResponse) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 7 with GetRepositoriesRequest

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

the class SnapshotIT method testSnapshotDeleteRepository.

public void testSnapshotDeleteRepository() throws IOException {
    String repository = "test";
    assertTrue(createTestRepository(repository, FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    GetRepositoriesRequest request = new GetRepositoriesRequest();
    GetRepositoriesResponse response = execute(request, highLevelClient().snapshot()::getRepository, highLevelClient().snapshot()::getRepositoryAsync);
    assertThat(1, equalTo(response.repositories().size()));
    DeleteRepositoryRequest deleteRequest = new DeleteRepositoryRequest(repository);
    AcknowledgedResponse deleteResponse = execute(deleteRequest, highLevelClient().snapshot()::deleteRepository, highLevelClient().snapshot()::deleteRepositoryAsync);
    assertTrue(deleteResponse.isAcknowledged());
}
Also used : DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 8 with GetRepositoriesRequest

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

the class SnapshotIT method testSnapshotGetRepositoriesNonExistent.

public void testSnapshotGetRepositoriesNonExistent() {
    String repository = "doesnotexist";
    GetRepositoriesRequest request = new GetRepositoriesRequest(new String[] { repository });
    OpenSearchException exception = expectThrows(OpenSearchException.class, () -> execute(request, highLevelClient().snapshot()::getRepository, highLevelClient().snapshot()::getRepositoryAsync));
    assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
    assertThat(exception.getMessage(), equalTo("OpenSearch exception [type=repository_missing_exception, reason=[" + repository + "] missing]"));
}
Also used : OpenSearchException(org.opensearch.OpenSearchException) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)

Example 9 with GetRepositoriesRequest

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

the class RestGetRepositoriesAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final String[] repositories = request.paramAsStringArray("repository", Strings.EMPTY_ARRAY);
    GetRepositoriesRequest getRepositoriesRequest = getRepositoryRequest(repositories);
    getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout()));
    getRepositoriesRequest.local(request.paramAsBoolean("local", getRepositoriesRequest.local()));
    settingsFilter.addFilterSettingParams(request);
    return channel -> client.admin().cluster().getRepositories(getRepositoriesRequest, new RestToXContentListener<>(channel));
}
Also used : SettingsFilter(org.opensearch.common.settings.SettingsFilter) NodeClient(org.opensearch.client.node.NodeClient) Collections.unmodifiableList(java.util.Collections.unmodifiableList) GET(org.opensearch.rest.RestRequest.Method.GET) RestRequest(org.opensearch.rest.RestRequest) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) IOException(java.io.IOException) Requests.getRepositoryRequest(org.opensearch.client.Requests.getRepositoryRequest) Strings(org.opensearch.common.Strings) List(java.util.List) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) RestToXContentListener(org.opensearch.rest.action.RestToXContentListener) Arrays.asList(java.util.Arrays.asList) BaseRestHandler(org.opensearch.rest.BaseRestHandler) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)

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