|
@@ -12,10 +12,12 @@ import org.elasticsearch.action.ActionRequestValidationException;
|
|
|
import org.elasticsearch.action.ActionResponse;
|
|
|
import org.elasticsearch.action.ActionType;
|
|
|
import org.elasticsearch.action.IndicesRequest;
|
|
|
+import org.elasticsearch.action.admin.indices.rollover.RolloverConditions;
|
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
|
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
|
|
import org.elasticsearch.cluster.SimpleDiffable;
|
|
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
|
|
+import org.elasticsearch.cluster.metadata.DataLifecycle;
|
|
|
import org.elasticsearch.cluster.metadata.DataStream;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
@@ -46,11 +48,17 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
|
|
|
private String[] names;
|
|
|
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true, false, false, true, false);
|
|
|
+ private boolean includeDefaults = false;
|
|
|
|
|
|
public Request(String[] names) {
|
|
|
this.names = names;
|
|
|
}
|
|
|
|
|
|
+ public Request(String[] names, boolean includeDefaults) {
|
|
|
+ this.names = names;
|
|
|
+ this.includeDefaults = includeDefaults;
|
|
|
+ }
|
|
|
+
|
|
|
public String[] getNames() {
|
|
|
return names;
|
|
|
}
|
|
@@ -64,6 +72,11 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
super(in);
|
|
|
this.names = in.readOptionalStringArray();
|
|
|
this.indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
|
+ if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0) && DataLifecycle.isEnabled()) {
|
|
|
+ this.includeDefaults = in.readBoolean();
|
|
|
+ } else {
|
|
|
+ this.includeDefaults = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -71,6 +84,9 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
super.writeTo(out);
|
|
|
out.writeOptionalStringArray(names);
|
|
|
indicesOptions.writeIndicesOptions(out);
|
|
|
+ if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0) && DataLifecycle.isEnabled()) {
|
|
|
+ out.writeBoolean(includeDefaults);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -78,12 +94,14 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
if (this == o) return true;
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
Request request = (Request) o;
|
|
|
- return Arrays.equals(names, request.names) && indicesOptions.equals(request.indicesOptions);
|
|
|
+ return Arrays.equals(names, request.names)
|
|
|
+ && indicesOptions.equals(request.indicesOptions)
|
|
|
+ && includeDefaults == request.includeDefaults;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- int result = Objects.hash(indicesOptions);
|
|
|
+ int result = Objects.hash(indicesOptions, includeDefaults);
|
|
|
result = 31 * result + Arrays.hashCode(names);
|
|
|
return result;
|
|
|
}
|
|
@@ -98,6 +116,10 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
return indicesOptions;
|
|
|
}
|
|
|
|
|
|
+ public boolean includeDefaults() {
|
|
|
+ return includeDefaults;
|
|
|
+ }
|
|
|
+
|
|
|
public Request indicesOptions(IndicesOptions indicesOptions) {
|
|
|
this.indicesOptions = indicesOptions;
|
|
|
return this;
|
|
@@ -113,6 +135,11 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
this.names = indices;
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
+ public Request includeDefaults(boolean includeDefaults) {
|
|
|
+ this.includeDefaults = includeDefaults;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static class Response extends ActionResponse implements ToXContentObject {
|
|
@@ -202,6 +229,14 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
|
|
|
@Override
|
|
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
+ return toXContent(builder, params, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Converts the response to XContent and passes the RolloverConditions, when provided, to the data stream.
|
|
|
+ */
|
|
|
+ public XContentBuilder toXContent(XContentBuilder builder, Params params, @Nullable RolloverConditions rolloverConditions)
|
|
|
+ throws IOException {
|
|
|
builder.startObject();
|
|
|
builder.field(DataStream.NAME_FIELD.getPreferredName(), dataStream.getName());
|
|
|
builder.field(DataStream.TIMESTAMP_FIELD_FIELD.getPreferredName(), dataStream.getTimeStampField());
|
|
@@ -215,7 +250,8 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
builder.field(INDEX_TEMPLATE_FIELD.getPreferredName(), indexTemplate);
|
|
|
}
|
|
|
if (dataStream.getLifecycle() != null) {
|
|
|
- builder.field(LIFECYCLE_FIELD.getPreferredName(), dataStream.getLifecycle());
|
|
|
+ builder.field(LIFECYCLE_FIELD.getPreferredName());
|
|
|
+ dataStream.getLifecycle().toXContent(builder, params, rolloverConditions);
|
|
|
}
|
|
|
if (ilmPolicyName != null) {
|
|
|
builder.field(ILM_POLICY_FIELD.getPreferredName(), ilmPolicyName);
|
|
@@ -289,22 +325,42 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
}
|
|
|
|
|
|
private final List<DataStreamInfo> dataStreams;
|
|
|
+ @Nullable
|
|
|
+ private final RolloverConditions rolloverConditions;
|
|
|
|
|
|
public Response(List<DataStreamInfo> dataStreams) {
|
|
|
+ this(dataStreams, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Response(List<DataStreamInfo> dataStreams, @Nullable RolloverConditions rolloverConditions) {
|
|
|
this.dataStreams = dataStreams;
|
|
|
+ this.rolloverConditions = rolloverConditions;
|
|
|
}
|
|
|
|
|
|
public Response(StreamInput in) throws IOException {
|
|
|
- this(in.readList(DataStreamInfo::new));
|
|
|
+ this(
|
|
|
+ in.readList(DataStreamInfo::new),
|
|
|
+ in.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0) && DataLifecycle.isEnabled()
|
|
|
+ ? in.readOptionalWriteable(RolloverConditions::new)
|
|
|
+ : null
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public List<DataStreamInfo> getDataStreams() {
|
|
|
return dataStreams;
|
|
|
}
|
|
|
|
|
|
+ @Nullable
|
|
|
+ public RolloverConditions getRolloverConditions() {
|
|
|
+ return rolloverConditions;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
out.writeList(dataStreams);
|
|
|
+ if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0) && DataLifecycle.isEnabled()) {
|
|
|
+ out.writeOptionalWriteable(rolloverConditions);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -312,7 +368,7 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
builder.startObject();
|
|
|
builder.startArray(DATA_STREAMS_FIELD.getPreferredName());
|
|
|
for (DataStreamInfo dataStream : dataStreams) {
|
|
|
- dataStream.toXContent(builder, params);
|
|
|
+ dataStream.toXContent(builder, params, rolloverConditions);
|
|
|
}
|
|
|
builder.endArray();
|
|
|
builder.endObject();
|
|
@@ -324,12 +380,12 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|
|
if (this == o) return true;
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
Response response = (Response) o;
|
|
|
- return dataStreams.equals(response.dataStreams);
|
|
|
+ return dataStreams.equals(response.dataStreams) && Objects.equals(rolloverConditions, response.rolloverConditions);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(dataStreams);
|
|
|
+ return Objects.hash(dataStreams, rolloverConditions);
|
|
|
}
|
|
|
}
|
|
|
|