Search in sources :

Example 1 with DeleteRepositoryRequest

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;
}
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 DeleteRepositoryRequest

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);
}
Also used : DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) RestHighLevelClient(org.opensearch.client.RestHighLevelClient)

Example 3 with DeleteRepositoryRequest

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));
}
Also used : DELETE(org.opensearch.rest.RestRequest.Method.DELETE) List(java.util.List) Requests.deleteRepositoryRequest(org.opensearch.client.Requests.deleteRepositoryRequest) DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) 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) DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)

Example 4 with DeleteRepositoryRequest

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());
}
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 5 with DeleteRepositoryRequest

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());
}
Also used : HashMap(java.util.HashMap) DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) 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)

Aggregations

DeleteRepositoryRequest (org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)5 GetRepositoriesRequest (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)3 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 AcknowledgedResponse (org.opensearch.action.support.master.AcknowledgedResponse)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 GetRepositoriesResponse (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)1 CloneSnapshotRequest (org.opensearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest)1 AcknowledgedRequest (org.opensearch.action.support.master.AcknowledgedRequest)1 Requests.deleteRepositoryRequest (org.opensearch.client.Requests.deleteRepositoryRequest)1 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)1