Snapshot Delete Repository API

edit

The Snapshot Delete Repository API allows to delete a registered repository.

Snapshot Delete Repository Request

edit

A DeleteRepositoryRequest:

DeleteRepositoryRequest request = new DeleteRepositoryRequest(repositoryName);

Optional Arguments

edit

The following arguments can optionally be provided:

request.timeout(TimeValue.timeValueMinutes(1)); 
request.timeout("1m"); 

Timeout to wait for the all the nodes to acknowledge the settings were applied as a TimeValue

Timeout to wait for the all the nodes to acknowledge the settings were applied as a String

request.masterNodeTimeout(TimeValue.timeValueMinutes(1)); 
request.masterNodeTimeout("1m"); 

Timeout to connect to the master node as a TimeValue

Timeout to connect to the master node as a String

Synchronous Execution

edit
DeleteRepositoryResponse response = client.snapshot().deleteRepository(request, RequestOptions.DEFAULT);

Asynchronous Execution

edit

The asynchronous execution of a snapshot delete repository requires both the DeleteRepositoryRequest instance and an ActionListener instance to be passed to the asynchronous method:

client.snapshot().deleteRepositoryAsync(request, RequestOptions.DEFAULT, listener); 

The DeleteRepositoryRequest to execute and the ActionListener to use when the execution completes

The asynchronous method does not block and returns immediately. Once it is completed the ActionListener is called back using the onResponse method if the execution successfully completed or using the onFailure method if it failed.

A typical listener for DeleteRepositoryResponse looks like:

ActionListener<DeleteRepositoryResponse> listener =
    new ActionListener<DeleteRepositoryResponse>() {
        @Override
        public void onResponse(DeleteRepositoryResponse deleteRepositoryResponse) {
            
        }

        @Override
        public void onFailure(Exception e) {
            
        }
    };

Called when the execution is successfully completed. The response is provided as an argument

Called in case of a failure. The raised exception is provided as an argument

Snapshot Delete Repository Response

edit

The returned DeleteRepositoryResponse allows to retrieve information about the executed operation as follows:

boolean acknowledged = response.isAcknowledged(); 

Indicates the node has acknowledged the request