From 9604067c102c112c115814384ab8f80f85448f78 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 10 Dec 2024 22:07:35 +1100 Subject: [PATCH] remove duplicate function --- .../sentinel_alert_rule_scheduled_resource.go | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go index abd888e48f91..d70235690d65 100644 --- a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go +++ b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go @@ -426,7 +426,7 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m param.Properties.TemplateVersion = utils.String(v.(string)) } if v, ok := d.GetOk("event_grouping"); ok { - param.Properties.EventGroupingSettings = expandAlertRuleScheduledEventGroupingSetting(v.([]interface{})) + param.Properties.EventGroupingSettings = expandAlertRuleEventGroupingSetting(v.([]interface{})) } if v, ok := d.GetOk("alert_details_override"); ok { param.Properties.AlertDetailsOverride = expandAlertRuleAlertDetailsOverride(v.([]interface{})) @@ -529,7 +529,7 @@ func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta inte d.Set("alert_rule_template_guid", prop.AlertRuleTemplateName) d.Set("alert_rule_template_version", prop.TemplateVersion) - if err := d.Set("event_grouping", flattenAlertRuleScheduledEventGroupingSetting(prop.EventGroupingSettings)); err != nil { + if err := d.Set("event_grouping", flattenAlertRuleEventGroupingSetting(prop.EventGroupingSettings)); err != nil { return fmt.Errorf("setting `event_grouping`: %+v", err) } if err := d.Set("alert_details_override", flattenAlertRuleAlertDetailsOverride(prop.AlertDetailsOverride)); err != nil { @@ -567,36 +567,3 @@ func resourceSentinelAlertRuleScheduledDelete(d *pluginsdk.ResourceData, meta in return nil } - -func expandAlertRuleScheduledEventGroupingSetting(input []interface{}) *alertrules.EventGroupingSettings { - if len(input) == 0 || input[0] == nil { - return nil - } - - v := input[0].(map[string]interface{}) - result := alertrules.EventGroupingSettings{} - - if aggregationKind := v["aggregation_method"].(string); aggregationKind != "" { - kind := alertrules.EventGroupingAggregationKind(aggregationKind) - result.AggregationKind = &kind - } - - return &result -} - -func flattenAlertRuleScheduledEventGroupingSetting(input *alertrules.EventGroupingSettings) []interface{} { - if input == nil { - return []interface{}{} - } - - var aggregationKind string - if input.AggregationKind != nil { - aggregationKind = string(*input.AggregationKind) - } - - return []interface{}{ - map[string]interface{}{ - "aggregation_method": aggregationKind, - }, - } -}