11package sumologic
22
33import (
4+ "log"
5+ "strings"
6+
47 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
58 "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
6- "log"
79)
810
911func resourceSumologicCSEAggregationRule () * schema.Resource {
@@ -99,6 +101,10 @@ func resourceSumologicCSEAggregationRule() *schema.Resource {
99101 Type : schema .TypeString ,
100102 Required : true ,
101103 },
104+ "window_size_millis" : {
105+ Type : schema .TypeString ,
106+ Optional : true ,
107+ },
102108 },
103109 }
104110}
@@ -136,7 +142,9 @@ func resourceSumologicCSEAggregationRuleRead(d *schema.ResourceData, meta interf
136142 d .Set ("tags" , CSEAggregationRuleGet .Tags )
137143 d .Set ("trigger_expression" , CSEAggregationRuleGet .TriggerExpression )
138144 d .Set ("window_size" , CSEAggregationRuleGet .WindowSizeName )
139-
145+ if strings .EqualFold (CSEAggregationRuleGet .WindowSizeName , "CUSTOM" ) {
146+ d .Set ("window_size_millis" , CSEAggregationRuleGet .WindowSize )
147+ }
140148 return nil
141149}
142150
@@ -152,22 +160,23 @@ func resourceSumologicCSEAggregationRuleCreate(d *schema.ResourceData, meta inte
152160
153161 if d .Id () == "" {
154162 id , err := c .CreateCSEAggregationRule (CSEAggregationRule {
155- AggregationFunctions : resourceToAggregationFunctionsArray (d .Get ("aggregation_functions" ).([]interface {})),
156- DescriptionExpression : d .Get ("description_expression" ).(string ),
157- Enabled : d .Get ("enabled" ).(bool ),
158- EntitySelectors : resourceToEntitySelectorArray (d .Get ("entity_selectors" ).([]interface {})),
159- GroupByEntity : d .Get ("group_by_entity" ).(bool ),
160- GroupByFields : resourceToStringArray (d .Get ("group_by_fields" ).([]interface {})),
161- IsPrototype : d .Get ("is_prototype" ).(bool ),
162- MatchExpression : d .Get ("match_expression" ).(string ),
163- Name : d .Get ("name" ).(string ),
164- NameExpression : d .Get ("name_expression" ).(string ),
165- SeverityMapping : resourceToSeverityMapping (d .Get ("severity_mapping" ).([]interface {})[0 ]),
166- Stream : "record" ,
167- SummaryExpression : d .Get ("summary_expression" ).(string ),
168- Tags : resourceToStringArray (d .Get ("tags" ).([]interface {})),
169- TriggerExpression : d .Get ("trigger_expression" ).(string ),
170- WindowSize : windowSizeField (d .Get ("window_size" ).(string )),
163+ AggregationFunctions : resourceToAggregationFunctionsArray (d .Get ("aggregation_functions" ).([]interface {})),
164+ DescriptionExpression : d .Get ("description_expression" ).(string ),
165+ Enabled : d .Get ("enabled" ).(bool ),
166+ EntitySelectors : resourceToEntitySelectorArray (d .Get ("entity_selectors" ).([]interface {})),
167+ GroupByEntity : d .Get ("group_by_entity" ).(bool ),
168+ GroupByFields : resourceToStringArray (d .Get ("group_by_fields" ).([]interface {})),
169+ IsPrototype : d .Get ("is_prototype" ).(bool ),
170+ MatchExpression : d .Get ("match_expression" ).(string ),
171+ Name : d .Get ("name" ).(string ),
172+ NameExpression : d .Get ("name_expression" ).(string ),
173+ SeverityMapping : resourceToSeverityMapping (d .Get ("severity_mapping" ).([]interface {})[0 ]),
174+ Stream : "record" ,
175+ SummaryExpression : d .Get ("summary_expression" ).(string ),
176+ Tags : resourceToStringArray (d .Get ("tags" ).([]interface {})),
177+ TriggerExpression : d .Get ("trigger_expression" ).(string ),
178+ WindowSize : windowSizeField (d .Get ("window_size" ).(string )),
179+ WindowSizeMilliseconds : d .Get ("window_size_millis" ).(string ),
171180 })
172181
173182 if err != nil {
@@ -229,22 +238,23 @@ func resourceToCSEAggregationRule(d *schema.ResourceData) (CSEAggregationRule, e
229238 }
230239
231240 return CSEAggregationRule {
232- ID : id ,
233- AggregationFunctions : resourceToAggregationFunctionsArray (d .Get ("aggregation_functions" ).([]interface {})),
234- DescriptionExpression : d .Get ("description_expression" ).(string ),
235- Enabled : d .Get ("enabled" ).(bool ),
236- EntitySelectors : resourceToEntitySelectorArray (d .Get ("entity_selectors" ).([]interface {})),
237- GroupByEntity : d .Get ("group_by_entity" ).(bool ),
238- GroupByFields : resourceToStringArray (d .Get ("group_by_fields" ).([]interface {})),
239- IsPrototype : d .Get ("is_prototype" ).(bool ),
240- MatchExpression : d .Get ("match_expression" ).(string ),
241- Name : d .Get ("name" ).(string ),
242- NameExpression : d .Get ("name_expression" ).(string ),
243- SeverityMapping : resourceToSeverityMapping (d .Get ("severity_mapping" ).([]interface {})[0 ]),
244- Stream : "record" ,
245- SummaryExpression : d .Get ("summary_expression" ).(string ),
246- Tags : resourceToStringArray (d .Get ("tags" ).([]interface {})),
247- TriggerExpression : d .Get ("trigger_expression" ).(string ),
248- WindowSize : windowSizeField (d .Get ("window_size" ).(string )),
241+ ID : id ,
242+ AggregationFunctions : resourceToAggregationFunctionsArray (d .Get ("aggregation_functions" ).([]interface {})),
243+ DescriptionExpression : d .Get ("description_expression" ).(string ),
244+ Enabled : d .Get ("enabled" ).(bool ),
245+ EntitySelectors : resourceToEntitySelectorArray (d .Get ("entity_selectors" ).([]interface {})),
246+ GroupByEntity : d .Get ("group_by_entity" ).(bool ),
247+ GroupByFields : resourceToStringArray (d .Get ("group_by_fields" ).([]interface {})),
248+ IsPrototype : d .Get ("is_prototype" ).(bool ),
249+ MatchExpression : d .Get ("match_expression" ).(string ),
250+ Name : d .Get ("name" ).(string ),
251+ NameExpression : d .Get ("name_expression" ).(string ),
252+ SeverityMapping : resourceToSeverityMapping (d .Get ("severity_mapping" ).([]interface {})[0 ]),
253+ Stream : "record" ,
254+ SummaryExpression : d .Get ("summary_expression" ).(string ),
255+ Tags : resourceToStringArray (d .Get ("tags" ).([]interface {})),
256+ TriggerExpression : d .Get ("trigger_expression" ).(string ),
257+ WindowSize : windowSizeField (d .Get ("window_size" ).(string )),
258+ WindowSizeMilliseconds : d .Get ("window_size_millis" ).(string ),
249259 }, nil
250260}
0 commit comments