Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2072,13 +2072,21 @@ public void testGetSnapshots() {
getSnapshotsRequest.snapshots(Arrays.asList(snapshot1, snapshot2).toArray(new String[0]));
setRandomMasterTimeout(getSnapshotsRequest, expectedParams);

boolean ignoreUnavailable = randomBoolean();
getSnapshotsRequest.ignoreUnavailable(ignoreUnavailable);
expectedParams.put("ignore_unavailable", Boolean.toString(ignoreUnavailable));
if (randomBoolean()) {
boolean ignoreUnavailable = randomBoolean();
getSnapshotsRequest.ignoreUnavailable(ignoreUnavailable);
expectedParams.put("ignore_unavailable", Boolean.toString(ignoreUnavailable));
} else {
expectedParams.put("ignore_unavailable", Boolean.FALSE.toString());
}

boolean verbose = randomBoolean();
getSnapshotsRequest.verbose(verbose);
expectedParams.put("verbose", Boolean.toString(verbose));
if (randomBoolean()) {
boolean verbose = randomBoolean();
getSnapshotsRequest.verbose(verbose);
expectedParams.put("verbose", Boolean.toString(verbose));
} else {
expectedParams.put("verbose", Boolean.TRUE.toString());
}

Request request = RequestConverters.getSnapshots(getSnapshotsRequest);
assertThat(endpoint, equalTo(request.getEndpoint()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.repositories.fs.FsRepository;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.snapshots.SnapshotInfo;
import org.elasticsearch.snapshots.SnapshotShardFailure;
import org.elasticsearch.snapshots.SnapshotState;

import java.io.IOException;
import java.util.HashMap;
Expand Down Expand Up @@ -496,7 +499,14 @@ public void testSnapshotGetSnapshots() throws IOException {
// end::get-snapshots-execute

// tag::get-snapshots-response
List<SnapshotInfo> snapshotsInfos = response.getSnapshots(); // <1>
List<SnapshotInfo> snapshotsInfos = response.getSnapshots();
SnapshotInfo snapshotInfo = snapshotsInfos.get(0);
RestStatus restStatus = snapshotInfo.status();
SnapshotId snapshotId = snapshotInfo.snapshotId();
SnapshotState snapshotState = snapshotInfo.state();
List<SnapshotShardFailure> snapshotShardFailures = snapshotInfo.shardFailures();
long startTime = snapshotInfo.startTime();
long endTime = snapshotInfo.endTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice here to also add some corresponding instructions in the docs page.

// end::get-snapshots-response
assertEquals(1, snapshotsInfos.size());
}
Expand Down
7 changes: 3 additions & 4 deletions docs/java-rest/high-level/snapshot/get_snapshots.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ argument.
[[java-rest-high-snapshot-get-snapshots-response]]
==== Get Snapshots Response

Use the `GetSnapshotsResponse` to retrieve information about the evaluated
request:
The returned `GetSnapshotsResponse` allows the retrieval of information about the requested
snapshots:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[get-snapshots-response]
--------------------------------------------------
<1> Indicates the node has started the request.
--------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public String reason() {
}

/**
* Returns REST status corresponding to this failure
* Returns {@link RestStatus} corresponding to this failure
*
* @return REST STATUS
* @return REST status
*/
@Override
public RestStatus status() {
Expand Down