use of org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotRequestConverters method deleteRepository.
static Request deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(deleteRepositoryRequest.name()).build();
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(deleteRepositoryRequest.masterNodeTimeout());
parameters.withTimeout(deleteRepositoryRequest.timeout());
request.addParameters(parameters.asMap());
return request;
}
use of org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotClientDocumentationIT method testSnapshotDeleteRepository.
public void testSnapshotDeleteRepository() throws IOException {
RestHighLevelClient client = highLevelClient();
createTestRepositories();
// tag::delete-repository-request
DeleteRepositoryRequest request = new DeleteRepositoryRequest(repositoryName);
// end::delete-repository-request
// tag::delete-repository-request-masterTimeout
// <1>
request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
// <2>
request.masterNodeTimeout("1m");
// end::delete-repository-request-masterTimeout
// tag::delete-repository-request-timeout
// <1>
request.timeout(TimeValue.timeValueMinutes(1));
// <2>
request.timeout("1m");
// end::delete-repository-request-timeout
// tag::delete-repository-execute
AcknowledgedResponse response = client.snapshot().deleteRepository(request, RequestOptions.DEFAULT);
// end::delete-repository-execute
// tag::delete-repository-response
// <1>
boolean acknowledged = response.isAcknowledged();
// end::delete-repository-response
assertTrue(acknowledged);
}
use of org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest in project OpenSearch by opensearch-project.
the class RestDeleteRepositoryAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteRepositoryRequest deleteRepositoryRequest = deleteRepositoryRequest(request.param("repository"));
deleteRepositoryRequest.timeout(request.paramAsTime("timeout", deleteRepositoryRequest.timeout()));
deleteRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteRepositoryRequest.masterNodeTimeout()));
return channel -> client.admin().cluster().deleteRepository(deleteRepositoryRequest, new RestToXContentListener<>(channel));
}
use of org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest 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.delete.DeleteRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotRequestConvertersTests method testDeleteRepository.
public void testDeleteRepository() {
Map<String, String> expectedParams = new HashMap<>();
String repository = RequestConvertersTests.randomIndicesNames(1, 1)[0];
StringBuilder endpoint = new StringBuilder("/_snapshot/" + repository);
DeleteRepositoryRequest deleteRepositoryRequest = new DeleteRepositoryRequest();
deleteRepositoryRequest.name(repository);
RequestConvertersTests.setRandomMasterTimeout(deleteRepositoryRequest, expectedParams);
RequestConvertersTests.setRandomTimeout(deleteRepositoryRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
Request request = SnapshotRequestConverters.deleteRepository(deleteRepositoryRequest);
assertThat(request.getEndpoint(), equalTo(endpoint.toString()));
assertThat(request.getMethod(), equalTo(HttpDelete.METHOD_NAME));
assertThat(request.getParameters(), equalTo(expectedParams));
assertNull(request.getEntity());
}
Aggregations