Snapshot Get Repository API

The Snapshot Get Repository API allows to retrieve information about a registered repository.

Snapshot Get Repository Request

A GetRepositoriesRequest:

GetRepositoriesRequest request = new GetRepositoriesRequest();

Optional Arguments

The following arguments can optionally be provided:

String [] repositories = new String[] {repositoryName};
request.repositories(repositories); 

Sets the repositories to retrieve

request.local(true); 

The local flag (defaults to false) controls whether the repositories need to be looked up in the local cluster state or in the cluster state held by the elected master node

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

GetRepositoriesResponse response = client.snapshot().getRepository(request, RequestOptions.DEFAULT);

Asynchronous Execution

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

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

The GetRepositoriesRequest 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 GetRepositoriesResponse looks like:

ActionListener<GetRepositoriesResponse> listener =
        new ActionListener<GetRepositoriesResponse>() {
    @Override
    public void onResponse(GetRepositoriesResponse getRepositoriesResponse) {
        
    }

    @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 Get Repository Response

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

List<RepositoryMetaData> repositoryMetaDataResponse = response.repositories();