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);
}
});
}
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());
}
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]"));
}
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));
}
Aggregations