Skip to content

Commit 64b10ee

Browse files
committed
add constructor
1 parent 2189670 commit 64b10ee

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SnapshotLifecyclePolicy.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ public class SnapshotLifecyclePolicy implements SimpleDiffable<SnapshotLifecycle
8989
TIME_ALLOWED_SINCE_LAST_SNAPSHOT.getPreferredName()), TIME_ALLOWED_SINCE_LAST_SNAPSHOT, ObjectParser.ValueType.STRING);
9090
}
9191

92+
public SnapshotLifecyclePolicy(
93+
final String id,
94+
final String name,
95+
final String schedule,
96+
final String repository,
97+
@Nullable final Map<String, Object> configuration,
98+
@Nullable final SnapshotRetentionConfiguration retentionPolicy
99+
) {
100+
this(id, name, schedule, repository, configuration, retentionPolicy, null);
101+
}
102+
92103
public SnapshotLifecyclePolicy(
93104
final String id,
94105
final String name,
@@ -115,9 +126,8 @@ public SnapshotLifecyclePolicy(StreamInput in) throws IOException {
115126
this.repository = in.readString();
116127
this.configuration = in.readGenericMap();
117128
this.retentionPolicy = in.readOptionalWriteable(SnapshotRetentionConfiguration::new);
118-
if (in.getTransportVersion().onOrAfter(TransportVersions.SLM_TIME_ALLOWED_SINCE_LAST_SNAPSHOT)) {
119-
this.timeAllowedSinceLastSnapshot = in.readOptionalTimeValue();
120-
}
129+
this.timeAllowedSinceLastSnapshot = in.getTransportVersion().onOrAfter(TransportVersions.SLM_TIME_ALLOWED_SINCE_LAST_SNAPSHOT) ?
130+
in.readOptionalTimeValue() : null;
121131
this.isCronSchedule = isCronSchedule(schedule);
122132
}
123133

0 commit comments

Comments
 (0)