Skip to content

Commit

Permalink
Get snapshot rest client cleanups (#31740)
Browse files Browse the repository at this point in the history
This is a followup to #31537. It makes a number of changes requested by
a review that came after the PR was merged. These are mostly cleanups
and doc improvements.
  • Loading branch information
Tim-Brooks authored Jul 5, 2018
1 parent c0b2ef5 commit a5f5ea8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2122,13 +2122,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(); // <1>
SnapshotId snapshotId = snapshotInfo.snapshotId(); // <2>
SnapshotState snapshotState = snapshotInfo.state(); // <3>
List<SnapshotShardFailure> snapshotShardFailures = snapshotInfo.shardFailures(); // <4>
long startTime = snapshotInfo.startTime(); // <5>
long endTime = snapshotInfo.endTime(); // <6>
// end::get-snapshots-response
assertEquals(1, snapshotsInfos.size());
}
Expand Down
11 changes: 8 additions & 3 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,16 @@ 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.
<1> The REST status of a snapshot
<2> The snapshot id
<3> The current state of the snapshot
<4> Information about failures that occurred during the shard snapshot process.
<5> The snapshot start time
<6> The snapshot end time
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

0 comments on commit a5f5ea8

Please sign in to comment.