@@ -23,114 +23,20 @@ async function createPolicy(client: ElasticsearchClient, name: string, phases: a
2323 return client . ilm . putLifecycle ( { policy : name , body } , options ) ;
2424}
2525
26- const minAgeSchema = schema . maybe ( schema . string ( ) ) ;
27-
28- const setPrioritySchema = schema . maybe (
29- schema . object ( {
30- priority : schema . nullable ( schema . number ( ) ) ,
31- } )
32- ) ;
33-
34- const unfollowSchema = schema . maybe ( schema . object ( { } ) ) ; // Unfollow has no options
35-
36- const migrateSchema = schema . maybe ( schema . object ( { enabled : schema . literal ( false ) } ) ) ;
37-
38- const allocateNodeSchema = schema . maybe ( schema . recordOf ( schema . string ( ) , schema . string ( ) ) ) ;
39- const allocateSchema = schema . maybe (
40- schema . object ( {
41- number_of_replicas : schema . maybe ( schema . number ( ) ) ,
42- include : allocateNodeSchema ,
43- exclude : allocateNodeSchema ,
44- require : allocateNodeSchema ,
45- } )
46- ) ;
47-
48- const forcemergeSchema = schema . maybe (
49- schema . object ( {
50- max_num_segments : schema . number ( ) ,
51- index_codec : schema . maybe ( schema . literal ( 'best_compression' ) ) ,
52- } )
53- ) ;
54-
55- const hotPhaseSchema = schema . object ( {
56- min_age : minAgeSchema ,
57- actions : schema . object ( {
58- set_priority : setPrioritySchema ,
59- unfollow : unfollowSchema ,
60- rollover : schema . maybe (
61- schema . object ( {
62- max_age : schema . maybe ( schema . string ( ) ) ,
63- max_size : schema . maybe ( schema . string ( ) ) ,
64- max_docs : schema . maybe ( schema . number ( ) ) ,
65- } )
66- ) ,
67- forcemerge : forcemergeSchema ,
68- } ) ,
69- } ) ;
70-
71- const warmPhaseSchema = schema . maybe (
72- schema . object ( {
73- min_age : minAgeSchema ,
74- actions : schema . object ( {
75- migrate : migrateSchema ,
76- set_priority : setPrioritySchema ,
77- unfollow : unfollowSchema ,
78- readonly : schema . maybe ( schema . object ( { } ) ) , // Readonly has no options
79- allocate : allocateSchema ,
80- shrink : schema . maybe (
81- schema . object ( {
82- number_of_shards : schema . number ( ) ,
83- } )
84- ) ,
85- forcemerge : forcemergeSchema ,
86- } ) ,
87- } )
88- ) ;
89-
90- const coldPhaseSchema = schema . maybe (
91- schema . object ( {
92- min_age : minAgeSchema ,
93- actions : schema . object ( {
94- migrate : migrateSchema ,
95- set_priority : setPrioritySchema ,
96- unfollow : unfollowSchema ,
97- allocate : allocateSchema ,
98- freeze : schema . maybe ( schema . object ( { } ) ) , // Freeze has no options
99- searchable_snapshot : schema . maybe (
100- schema . object ( {
101- snapshot_repository : schema . string ( ) ,
102- } )
103- ) ,
104- } ) ,
105- } )
106- ) ;
107-
108- const deletePhaseSchema = schema . maybe (
109- schema . object ( {
110- min_age : minAgeSchema ,
111- actions : schema . object ( {
112- wait_for_snapshot : schema . maybe (
113- schema . object ( {
114- policy : schema . string ( ) ,
115- } )
116- ) ,
117- delete : schema . maybe (
118- schema . object ( {
119- delete_searchable_snapshot : schema . maybe ( schema . boolean ( ) ) ,
120- } )
121- ) ,
122- } ) ,
123- } )
124- ) ;
125-
126- // Per https://www.elastic.co/guide/en/elasticsearch/reference/current/_actions.html
26+ /**
27+ * We intentionally do not deeply validate the posted policy object to avoid erroring on valid ES
28+ * policy configuration Kibana UI does not know or should not know about. For instance, the
29+ * `force_merge_index` setting of the `searchable_snapshot` action.
30+ *
31+ * We only specify a rough structure based on https://www.elastic.co/guide/en/elasticsearch/reference/current/_actions.html.
32+ */
12733const bodySchema = schema . object ( {
12834 name : schema . string ( ) ,
12935 phases : schema . object ( {
130- hot : hotPhaseSchema ,
131- warm : warmPhaseSchema ,
132- cold : coldPhaseSchema ,
133- delete : deletePhaseSchema ,
36+ hot : schema . any ( ) ,
37+ warm : schema . maybe ( schema . any ( ) ) ,
38+ cold : schema . maybe ( schema . any ( ) ) ,
39+ delete : schema . maybe ( schema . any ( ) ) ,
13440 } ) ,
13541} ) ;
13642
0 commit comments