Snapshot Get Repository APIedit

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

Snapshot Get Repository Requestedit

A GetRepositoriesRequest:

GetRepositoriesRequest request = new GetRepositoriesRequest();

Optional Argumentsedit

The following arguments can optionally be provided:

String [] repositories = new String[] {repositoryName};

Sets the repositories to retrieve


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


Timeout to connect to the master node as a TimeValue

Timeout to connect to the master node as a String

Synchronous Executionedit

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

Asynchronous Executionedit

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>() {
    public void onResponse(GetRepositoriesResponse getRepositoriesResponse) {

    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 Responseedit

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

List<RepositoryMetadata> repositoryMetadataResponse = response.repositories();