1111
1212import org .elasticsearch .action .ActionType ;
1313import org .elasticsearch .action .IndicesRequest ;
14- import org .elasticsearch .action .downsample .DownsampleConfig ;
1514import org .elasticsearch .action .support .IndicesOptions ;
1615import org .elasticsearch .action .support .master .AcknowledgedRequest ;
1716import org .elasticsearch .action .support .master .AcknowledgedResponse ;
2019import org .elasticsearch .common .io .stream .StreamOutput ;
2120import org .elasticsearch .core .Nullable ;
2221import org .elasticsearch .core .TimeValue ;
23- import org .elasticsearch .xcontent .AbstractObjectParser ;
24- import org .elasticsearch .xcontent .ConstructingObjectParser ;
25- import org .elasticsearch .xcontent .ObjectParser ;
2622import org .elasticsearch .xcontent .ToXContentObject ;
2723import org .elasticsearch .xcontent .XContentBuilder ;
28- import org .elasticsearch .xcontent .XContentParser ;
2924
3025import java .io .IOException ;
3126import java .util .Arrays ;
32- import java .util .List ;
3327import java .util .Objects ;
3428
35- import static org .elasticsearch .cluster .metadata .DataStreamLifecycle .DATA_RETENTION_FIELD ;
36- import static org .elasticsearch .cluster .metadata .DataStreamLifecycle .DOWNSAMPLING_FIELD ;
37- import static org .elasticsearch .cluster .metadata .DataStreamLifecycle .DOWNSAMPLING_METHOD_FIELD ;
38- import static org .elasticsearch .cluster .metadata .DataStreamLifecycle .ENABLED_FIELD ;
39-
4029/**
4130 * Sets the data stream lifecycle that was provided in the request to the requested data streams.
4231 */
@@ -48,53 +37,6 @@ private PutDataStreamLifecycleAction() {/* no instances */}
4837
4938 public static final class Request extends AcknowledgedRequest <Request > implements IndicesRequest .Replaceable , ToXContentObject {
5039
51- public interface Factory {
52- Request create (
53- @ Nullable TimeValue dataRetention ,
54- @ Nullable Boolean enabled ,
55- @ Nullable List <DataStreamLifecycle .DownsamplingRound > downsampling ,
56- @ Nullable DownsampleConfig .SamplingMethod downsamplingMethod
57- );
58- }
59-
60- @ SuppressWarnings ("unchecked" )
61- public static final ConstructingObjectParser <Request , Factory > PARSER = new ConstructingObjectParser <>(
62- "put_data_stream_lifecycle_request" ,
63- false ,
64- (args , factory ) -> factory .create (
65- (TimeValue ) args [0 ],
66- (Boolean ) args [1 ],
67- (List <DataStreamLifecycle .DownsamplingRound >) args [2 ],
68- (DownsampleConfig .SamplingMethod ) args [3 ]
69- )
70- );
71-
72- static {
73- PARSER .declareField (
74- ConstructingObjectParser .optionalConstructorArg (),
75- (p , c ) -> TimeValue .parseTimeValue (p .text (), DATA_RETENTION_FIELD .getPreferredName ()),
76- DATA_RETENTION_FIELD ,
77- ObjectParser .ValueType .STRING
78- );
79- PARSER .declareBoolean (ConstructingObjectParser .optionalConstructorArg (), ENABLED_FIELD );
80- PARSER .declareField (
81- ConstructingObjectParser .optionalConstructorArg (),
82- (p , c ) -> AbstractObjectParser .parseArray (p , null , DataStreamLifecycle .DownsamplingRound ::fromXContent ),
83- DOWNSAMPLING_FIELD ,
84- ObjectParser .ValueType .OBJECT_ARRAY
85- );
86- PARSER .declareField (
87- ConstructingObjectParser .optionalConstructorArg (),
88- (p , c ) -> DownsampleConfig .SamplingMethod .fromString (p .text ()),
89- DOWNSAMPLING_METHOD_FIELD ,
90- ObjectParser .ValueType .STRING
91- );
92- }
93-
94- public static Request parseRequest (XContentParser parser , Factory factory ) {
95- return PARSER .apply (parser , factory );
96- }
97-
9840 private String [] names ;
9941 private IndicesOptions indicesOptions = IndicesOptions .builder ()
10042 .concreteTargetOptions (IndicesOptions .ConcreteTargetOptions .ERROR_WHEN_UNAVAILABLE_TARGETS )
@@ -150,26 +92,12 @@ public Request(
15092 @ Nullable TimeValue dataRetention ,
15193 @ Nullable Boolean enabled
15294 ) {
153- this (masterNodeTimeout , ackTimeout , names , dataRetention , enabled , null , null );
154- }
155-
156- public Request (
157- TimeValue masterNodeTimeout ,
158- TimeValue ackTimeout ,
159- String [] names ,
160- @ Nullable TimeValue dataRetention ,
161- @ Nullable Boolean enabled ,
162- @ Nullable List <DataStreamLifecycle .DownsamplingRound > downsamplingRounds ,
163- @ Nullable DownsampleConfig .SamplingMethod downsamplingMethod
164- ) {
165- super (masterNodeTimeout , ackTimeout );
166- this .names = names ;
167- this .lifecycle = DataStreamLifecycle .dataLifecycleBuilder ()
168- .dataRetention (dataRetention )
169- .enabled (enabled == null || enabled )
170- .downsamplingRounds (downsamplingRounds )
171- .downsamplingMethod (downsamplingMethod )
172- .build ();
95+ this (
96+ masterNodeTimeout ,
97+ ackTimeout ,
98+ names ,
99+ DataStreamLifecycle .dataLifecycleBuilder ().enabled (enabled == null || enabled ).dataRetention (dataRetention ).build ()
100+ );
173101 }
174102
175103 public String [] getNames () {
0 commit comments