Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -37,14 +37,15 @@ public class GetSnapshotsRequest extends MasterNodeRequest<GetSnapshotsRequest>

public static final String ALL_SNAPSHOTS = "_all";
public static final String CURRENT_SNAPSHOT = "_current";
public static final boolean DEFAULT_VERBOSE_MODE = true;

private String repository;

private String[] snapshots = Strings.EMPTY_ARRAY;

private boolean ignoreUnavailable;

private boolean verbose = true;
private boolean verbose = DEFAULT_VERBOSE_MODE;

public GetSnapshotsRequest() {
}
Expand Down
12 changes: 7 additions & 5 deletions core/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -346,6 +347,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
return toXContentSnapshot(builder, params);
}

final boolean verbose = params.paramAsBoolean("verbose", GetSnapshotsRequest.DEFAULT_VERBOSE_MODE);
// write snapshot info for the API and any other situations
builder.startObject();
builder.field(SNAPSHOT, snapshotId.getName());
Expand All @@ -359,22 +361,22 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
builder.value(index);
}
builder.endArray();
if (state != null) {
if (verbose || state != null) {
builder.field(STATE, state);
}
if (reason != null) {
builder.field(REASON, reason);
}
if (startTime != 0) {
if (verbose || startTime != 0) {
builder.field(START_TIME, DATE_TIME_FORMATTER.printer().print(startTime));
builder.field(START_TIME_IN_MILLIS, startTime);
}
if (endTime != 0) {
if (verbose || endTime != 0) {
builder.field(END_TIME, DATE_TIME_FORMATTER.printer().print(endTime));
builder.field(END_TIME_IN_MILLIS, endTime);
builder.timeValueField(DURATION_IN_MILLIS, DURATION, endTime - startTime);
}
if (!shardFailures.isEmpty()) {
if (verbose || !shardFailures.isEmpty()) {
builder.startArray(FAILURES);
for (SnapshotShardFailure shardFailure : shardFailures) {
builder.startObject();
Expand All @@ -383,7 +385,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
}
builder.endArray();
}
if (totalShards != 0) {
if (verbose || totalShards != 0) {
builder.startObject(SHARDS);
builder.field(TOTAL, totalShards);
builder.field(FAILED, failedShards());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ setup:
snapshot: test_snapshot

- is_true: snapshots
- is_true: snapshots.0.failures

- do:
snapshot.delete:
Expand Down Expand Up @@ -87,6 +88,8 @@ setup:
- is_true: snapshots
- match: { snapshots.0.snapshot: test_snapshot }
- match: { snapshots.0.state: SUCCESS }
- is_false: snapshots.0.failures
- is_false: snapshots.0.shards
- is_false: snapshots.0.version

- do:
Expand Down