diff --git a/internal/services/sentinel/client/client.go b/internal/services/sentinel/client/client.go index 44400b4ee5dd..4b44512f4575 100644 --- a/internal/services/sentinel/client/client.go +++ b/internal/services/sentinel/client/client.go @@ -12,13 +12,13 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-11-01/sentinelonboardingstates" "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-11-01/watchlistitems" "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-11-01/watchlists" - newalertrules "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2023-12-01-preview/alertrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2023-12-01-preview/alertrules" "github.com/hashicorp/terraform-provider-azurerm/internal/common" securityinsight "github.com/jackofallops/kermit/sdk/securityinsights/2022-10-01-preview/securityinsights" ) type Client struct { - AlertRulesClient *newalertrules.AlertRulesClient + AlertRulesClient *alertrules.AlertRulesClient AlertRuleTemplatesClient *alertruletemplates.AlertRuleTemplatesClient AutomationRulesClient *automationrules.AutomationRulesClient DataConnectorsClient *securityinsight.DataConnectorsClient @@ -28,11 +28,10 @@ type Client struct { AnalyticsSettingsClient *securityinsight.SecurityMLAnalyticsSettingsClient ThreatIntelligenceClient *securityinsight.ThreatIntelligenceIndicatorClient MetadataClient *metadata.MetadataClient - NewAlertRulesClient *newalertrules.AlertRulesClient } func NewClient(o *common.ClientOptions) (*Client, error) { - alertRulesClient, err := newalertrules.NewAlertRulesClientWithBaseURI(o.Environment.ResourceManager) + alertRulesClient, err := alertrules.NewAlertRulesClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building Alert Rules Client: %+v", err) } @@ -80,12 +79,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(metadataClient.Client, o.Authorizers.ResourceManager) - newAlertRulesClient, err := newalertrules.NewAlertRulesClientWithBaseURI(o.Environment.ResourceManager) - if err != nil { - return nil, fmt.Errorf("building New Alert Rules Client: %+v", err) - } - o.Configure(newAlertRulesClient.Client, o.Authorizers.ResourceManager) - return &Client{ AlertRulesClient: alertRulesClient, AlertRuleTemplatesClient: &alertRuleTemplatesClient, @@ -97,6 +90,5 @@ func NewClient(o *common.ClientOptions) (*Client, error) { AnalyticsSettingsClient: &analyticsSettingsClient, ThreatIntelligenceClient: &threatIntelligenceClient, MetadataClient: metadataClient, - NewAlertRulesClient: newAlertRulesClient, }, nil } diff --git a/internal/services/sentinel/sentinel_alert_rule.go b/internal/services/sentinel/sentinel_alert_rule.go index e4d1bf483472..241543de1b88 100644 --- a/internal/services/sentinel/sentinel_alert_rule.go +++ b/internal/services/sentinel/sentinel_alert_rule.go @@ -7,36 +7,13 @@ import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2023-12-01-preview/alertrules" - newalertrules "github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2023-12-01-preview/alertrules" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) -// TODO: after all sentinel alert rules updated to new API version, remove these old functions and rename new funtions. -func importNewSentinelAlertRule(expectKind newalertrules.AlertRuleKind) pluginsdk.ImporterFunc { - return func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) (data []*pluginsdk.ResourceData, err error) { - id, err := newalertrules.ParseAlertRuleID(d.Id()) - if err != nil { - return nil, err - } - - client := meta.(*clients.Client).Sentinel.NewAlertRulesClient - resp, err := client.Get(ctx, *id) - if err != nil { - return nil, fmt.Errorf("retrieving %q: %+v", id, err) - } - - if err = assertNewAlertRuleKind(resp.Model, expectKind); err != nil { - return nil, err - } - return []*pluginsdk.ResourceData{d}, nil - } -} - func importSentinelAlertRule(expectKind alertrules.AlertRuleKind) pluginsdk.ImporterFunc { return func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) (data []*pluginsdk.ResourceData, err error) { id, err := alertrules.ParseAlertRuleID(d.Id()) @@ -103,26 +80,6 @@ func assertAlertRuleKind(rule alertrules.AlertRule, expectKind alertrules.AlertR return nil } -func assertNewAlertRuleKind(rule newalertrules.AlertRule, expectKind newalertrules.AlertRuleKind) error { - if rule == nil { - return fmt.Errorf("model was nil") - } - - var kind newalertrules.AlertRuleKind - switch rule.(type) { - case newalertrules.ScheduledAlertRule: - kind = newalertrules.AlertRuleKindScheduled - case newalertrules.FusionAlertRule: - kind = newalertrules.AlertRuleKindFusion - case newalertrules.MicrosoftSecurityIncidentCreationAlertRule: - kind = newalertrules.AlertRuleKindMicrosoftSecurityIncidentCreation - } - if expectKind != kind { - return fmt.Errorf("Sentinel Alert Rule has mismatched kind, expected: %q, got %q", expectKind, kind) - } - return nil -} - func expandAlertRuleTactics(input []interface{}) *[]alertrules.AttackTactic { result := make([]alertrules.AttackTactic, 0) @@ -133,16 +90,6 @@ func expandAlertRuleTactics(input []interface{}) *[]alertrules.AttackTactic { return &result } -func expandNewAlertRuleTactics(input []interface{}) *[]newalertrules.AttackTactic { - result := make([]newalertrules.AttackTactic, 0) - - for _, e := range input { - result = append(result, newalertrules.AttackTactic(e.(string))) - } - - return &result -} - func flattenAlertRuleTactics(input *[]alertrules.AttackTactic) []interface{} { if input == nil { return []interface{}{} @@ -157,20 +104,6 @@ func flattenAlertRuleTactics(input *[]alertrules.AttackTactic) []interface{} { return output } -func flattenNewAlertRuleTactics(input *[]newalertrules.AttackTactic) []interface{} { - if input == nil { - return []interface{}{} - } - - output := make([]interface{}, 0) - - for _, e := range *input { - output = append(output, string(e)) - } - - return output -} - func expandAlertRuleTechnicals(input []interface{}) *[]string { result := make([]string, 0) @@ -196,21 +129,6 @@ func expandAlertRuleIncidentConfiguration(input []interface{}, createIncidentKey return output } -func expandNewAlertRuleIncidentConfiguration(input []interface{}, createIncidentKey string, withGroupByPrefix bool) *newalertrules.IncidentConfiguration { - if len(input) == 0 || input[0] == nil { - return nil - } - - raw := input[0].(map[string]interface{}) - - output := &newalertrules.IncidentConfiguration{ - CreateIncident: raw[createIncidentKey].(bool), - GroupingConfiguration: expandNewAlertRuleGrouping(raw["grouping"].([]interface{}), withGroupByPrefix), - } - - return output -} - func flattenAlertRuleIncidentConfiguration(input *alertrules.IncidentConfiguration, createIncidentKey string, withGroupByPrefix bool) []interface{} { if input == nil { return []interface{}{} @@ -224,19 +142,6 @@ func flattenAlertRuleIncidentConfiguration(input *alertrules.IncidentConfigurati } } -func flattenNewAlertRuleIncidentConfiguration(input *newalertrules.IncidentConfiguration, createIncidentKey string, withGroupByPrefix bool) []interface{} { - if input == nil { - return []interface{}{} - } - - return []interface{}{ - map[string]interface{}{ - createIncidentKey: input.CreateIncident, - "grouping": flattenNewAlertRuleGrouping(input.GroupingConfiguration, withGroupByPrefix), - }, - } -} - func expandAlertRuleEventGroupingSetting(input []interface{}) *alertrules.EventGroupingSettings { if len(input) == 0 || input[0] == nil { return nil @@ -298,51 +203,6 @@ func expandAlertRuleGrouping(input []interface{}, withGroupPrefix bool) *alertru return output } -func expandNewAlertRuleGrouping(input []interface{}, withGroupPrefix bool) *newalertrules.GroupingConfiguration { - if len(input) == 0 || input[0] == nil { - return nil - } - - raw := input[0].(map[string]interface{}) - - output := &newalertrules.GroupingConfiguration{ - Enabled: raw["enabled"].(bool), - ReopenClosedIncident: raw["reopen_closed_incidents"].(bool), - LookbackDuration: raw["lookback_duration"].(string), - MatchingMethod: newalertrules.MatchingMethod(raw["entity_matching_method"].(string)), - } - - key := "by_entities" - if withGroupPrefix { - key = "group_" + key - } - groupByEntitiesList := raw[key].([]interface{}) - groupByEntities := make([]newalertrules.EntityMappingType, len(groupByEntitiesList)) - for idx, t := range groupByEntitiesList { - groupByEntities[idx] = newalertrules.EntityMappingType(t.(string)) - } - output.GroupByEntities = &groupByEntities - - key = "by_alert_details" - if withGroupPrefix { - key = "group_" + key - } - groupByAlertDetailsList := raw[key].([]interface{}) - groupByAlertDetails := make([]newalertrules.AlertDetail, len(groupByAlertDetailsList)) - for idx, t := range groupByAlertDetailsList { - groupByAlertDetails[idx] = newalertrules.AlertDetail(t.(string)) - } - output.GroupByAlertDetails = &groupByAlertDetails - - key = "by_custom_details" - if withGroupPrefix { - key = "group_" + key - } - output.GroupByCustomDetails = utils.ExpandStringSlice(raw[key].([]interface{})) - - return output -} - func flattenAlertRuleGrouping(input *alertrules.GroupingConfiguration, withGroupPrefix bool) []interface{} { if input == nil { return []interface{}{} @@ -410,56 +270,6 @@ func flattenAlertRuleEventGroupingSetting(input *alertrules.EventGroupingSetting } } -func flattenNewAlertRuleGrouping(input *newalertrules.GroupingConfiguration, withGroupPrefix bool) []interface{} { - if input == nil { - return []interface{}{} - } - - var groupByEntities []interface{} - if input.GroupByEntities != nil { - for _, entity := range *input.GroupByEntities { - groupByEntities = append(groupByEntities, string(entity)) - } - } - - var groupByAlertDetails []interface{} - if input.GroupByAlertDetails != nil { - for _, detail := range *input.GroupByAlertDetails { - groupByAlertDetails = append(groupByAlertDetails, string(detail)) - } - } - - var groupByCustomDetails []interface{} - if input.GroupByCustomDetails != nil { - for _, detail := range *input.GroupByCustomDetails { - groupByCustomDetails = append(groupByCustomDetails, detail) - } - } - - var ( - k1 = "by_entities" - k2 = "by_alert_details" - k3 = "by_custom_details" - ) - - if withGroupPrefix { - k1 = "group_" + k1 - k2 = "group_" + k2 - k3 = "group_" + k3 - } - return []interface{}{ - map[string]interface{}{ - "enabled": input.Enabled, - "lookback_duration": input.LookbackDuration, - "reopen_closed_incidents": input.ReopenClosedIncident, - "entity_matching_method": string(input.MatchingMethod), - k1: groupByEntities, - k2: groupByAlertDetails, - k3: groupByCustomDetails, - }, - } -} - func expandAlertRuleAlertDetailsOverride(input []interface{}) *alertrules.AlertDetailsOverride { if len(input) == 0 || input[0] == nil { return nil @@ -487,33 +297,6 @@ func expandAlertRuleAlertDetailsOverride(input []interface{}) *alertrules.AlertD return output } -func expandNewAlertRuleAlertDetailsOverride(input []interface{}) *newalertrules.AlertDetailsOverride { - if len(input) == 0 || input[0] == nil { - return nil - } - - b := input[0].(map[string]interface{}) - output := &newalertrules.AlertDetailsOverride{} - - if v := b["description_format"]; v != "" { - output.AlertDescriptionFormat = pointer.To(v.(string)) - } - if v := b["display_name_format"]; v != "" { - output.AlertDisplayNameFormat = pointer.To(v.(string)) - } - if v := b["severity_column_name"]; v != "" { - output.AlertSeverityColumnName = pointer.To(v.(string)) - } - if v := b["tactics_column_name"]; v != "" { - output.AlertTacticsColumnName = pointer.To(v.(string)) - } - if v := b["dynamic_property"]; v != nil && len(v.([]interface{})) > 0 { - output.AlertDynamicProperties = expandNewAlertRuleAlertDynamicProperties(v.([]interface{})) - } - - return output -} - func flattenAlertRuleAlertDetailsOverride(input *alertrules.AlertDetailsOverride) []interface{} { if input == nil { return []interface{}{} @@ -555,31 +338,6 @@ func flattenAlertRuleAlertDetailsOverride(input *alertrules.AlertDetailsOverride } } -func flattenNewAlertRuleAlertDetailsOverride(input *newalertrules.AlertDetailsOverride) []interface{} { - if input == nil { - return []interface{}{} - } - - descriptionFormat := pointer.From(input.AlertDescriptionFormat) - displayNameFormat := pointer.From(input.AlertDisplayNameFormat) - severityColumnName := pointer.From(input.AlertSeverityColumnName) - tacticsColumnName := pointer.From(input.AlertTacticsColumnName) - var dynamicProperties []interface{} - if input.AlertDynamicProperties != nil { - dynamicProperties = flattenNewAlertRuleAlertDynamicProperties(input.AlertDynamicProperties) - } - - return []interface{}{ - map[string]interface{}{ - "description_format": descriptionFormat, - "display_name_format": displayNameFormat, - "severity_column_name": severityColumnName, - "tactics_column_name": tacticsColumnName, - "dynamic_property": dynamicProperties, - }, - } -} - func expandAlertRuleAlertDynamicProperties(input []interface{}) *[]alertrules.AlertPropertyMapping { if len(input) == 0 || input[0] == nil { return nil @@ -598,24 +356,6 @@ func expandAlertRuleAlertDynamicProperties(input []interface{}) *[]alertrules.Al return &output } -func expandNewAlertRuleAlertDynamicProperties(input []interface{}) *[]newalertrules.AlertPropertyMapping { - if len(input) == 0 || input[0] == nil { - return nil - } - - output := make([]newalertrules.AlertPropertyMapping, 0, len(input)) - for _, v := range input { - b := v.(map[string]interface{}) - property := newalertrules.AlertProperty(b["name"].(string)) - output = append(output, newalertrules.AlertPropertyMapping{ - AlertProperty: &property, - Value: pointer.To(b["value"].(string)), - }) - } - - return &output -} - func flattenAlertRuleAlertDynamicProperties(input *[]alertrules.AlertPropertyMapping) []interface{} { if input == nil || len(*input) == 0 { return []interface{}{} @@ -636,26 +376,6 @@ func flattenAlertRuleAlertDynamicProperties(input *[]alertrules.AlertPropertyMap return output } -func flattenNewAlertRuleAlertDynamicProperties(input *[]newalertrules.AlertPropertyMapping) []interface{} { - if input == nil || len(*input) == 0 { - return []interface{}{} - } - - output := make([]interface{}, 0, len(*input)) - for _, i := range *input { - name := "" - if i.AlertProperty != nil { - name = string(*i.AlertProperty) - } - output = append(output, map[string]interface{}{ - "name": name, - "value": i.Value, - }) - } - - return output -} - func expandAlertRuleEntityMapping(input []interface{}) *[]alertrules.EntityMapping { if len(input) == 0 { return nil @@ -674,24 +394,6 @@ func expandAlertRuleEntityMapping(input []interface{}) *[]alertrules.EntityMappi return &result } -func expandNewAlertRuleEntityMapping(input []interface{}) *[]newalertrules.EntityMapping { - if len(input) == 0 { - return nil - } - - result := make([]newalertrules.EntityMapping, 0, len(input)) - for _, e := range input { - b := e.(map[string]interface{}) - mappingType := newalertrules.EntityMappingType(b["entity_type"].(string)) - result = append(result, newalertrules.EntityMapping{ - EntityType: &mappingType, - FieldMappings: expandNewAlertRuleFieldMapping(b["field_mapping"].([]interface{})), - }) - } - - return &result -} - func flattenAlertRuleEntityMapping(input *[]alertrules.EntityMapping) []interface{} { if input == nil { return []interface{}{} @@ -712,26 +414,6 @@ func flattenAlertRuleEntityMapping(input *[]alertrules.EntityMapping) []interfac return output } -func flattenNewAlertRuleEntityMapping(input *[]newalertrules.EntityMapping) []interface{} { - if input == nil { - return []interface{}{} - } - - output := make([]interface{}, 0, len(*input)) - for _, e := range *input { - entityType := "" - if e.EntityType != nil { - entityType = string(*e.EntityType) - } - output = append(output, map[string]interface{}{ - "entity_type": entityType, - "field_mapping": flattenNewAlertRuleFieldMapping(e.FieldMappings), - }) - } - - return output -} - func expandAlertRuleFieldMapping(input []interface{}) *[]alertrules.FieldMapping { if len(input) == 0 { return nil @@ -749,23 +431,6 @@ func expandAlertRuleFieldMapping(input []interface{}) *[]alertrules.FieldMapping return &result } -func expandNewAlertRuleFieldMapping(input []interface{}) *[]newalertrules.FieldMapping { - if len(input) == 0 { - return nil - } - - result := make([]newalertrules.FieldMapping, 0, len(input)) - for _, e := range input { - b := e.(map[string]interface{}) - result = append(result, newalertrules.FieldMapping{ - Identifier: pointer.To(b["identifier"].(string)), - ColumnName: pointer.To(b["column_name"].(string)), - }) - } - - return &result -} - func flattenAlertRuleFieldMapping(input *[]alertrules.FieldMapping) []interface{} { if input == nil { return []interface{}{} @@ -792,32 +457,6 @@ func flattenAlertRuleFieldMapping(input *[]alertrules.FieldMapping) []interface{ return output } -func flattenNewAlertRuleFieldMapping(input *[]newalertrules.FieldMapping) []interface{} { - if input == nil { - return []interface{}{} - } - - output := make([]interface{}, 0, len(*input)) - for _, e := range *input { - var identifier string - if e.Identifier != nil { - identifier = *e.Identifier - } - - var columnName string - if e.ColumnName != nil { - columnName = *e.ColumnName - } - - output = append(output, map[string]interface{}{ - "identifier": identifier, - "column_name": columnName, - }) - } - - return output -} - func expandAlertRuleSentinelEntityMapping(input []interface{}) *[]alertrules.SentinelEntityMapping { if len(input) == 0 { return nil @@ -834,22 +473,6 @@ func expandAlertRuleSentinelEntityMapping(input []interface{}) *[]alertrules.Sen return &result } -func expandNewAlertRuleSentinelEntityMapping(input []interface{}) *[]newalertrules.SentinelEntityMapping { - if len(input) == 0 { - return nil - } - - result := make([]newalertrules.SentinelEntityMapping, 0, len(input)) - for _, e := range input { - b := e.(map[string]interface{}) - result = append(result, newalertrules.SentinelEntityMapping{ - ColumnName: utils.String(b["column_name"].(string)), - }) - } - - return &result -} - func flattenAlertRuleSentinelEntityMapping(input *[]alertrules.SentinelEntityMapping) []interface{} { if input == nil { return []interface{}{} @@ -869,23 +492,3 @@ func flattenAlertRuleSentinelEntityMapping(input *[]alertrules.SentinelEntityMap return output } - -func flattenNewAlertRuleSentinelEntityMapping(input *[]newalertrules.SentinelEntityMapping) []interface{} { - if input == nil { - return []interface{}{} - } - - output := make([]interface{}, 0, len(*input)) - for _, e := range *input { - var columnName string - if e.ColumnName != nil { - columnName = *e.ColumnName - } - - output = append(output, map[string]interface{}{ - "column_name": columnName, - }) - } - - return output -} diff --git a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go index f63e8ab1a5a3..abd888e48f91 100644 --- a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go +++ b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource.go @@ -33,7 +33,7 @@ func resourceSentinelAlertRuleScheduled() *pluginsdk.Resource { Importer: pluginsdk.ImporterValidatingResourceIdThen(func(id string) error { _, err := alertrules.ParseAlertRuleID(id) return err - }, importNewSentinelAlertRule(alertrules.AlertRuleKindScheduled)), + }, importSentinelAlertRule(alertrules.AlertRuleKindScheduled)), Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -352,7 +352,7 @@ func resourceSentinelAlertRuleScheduled() *pluginsdk.Resource { } func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Sentinel.NewAlertRulesClient + client := meta.(*clients.Client).Sentinel.AlertRulesClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -398,13 +398,13 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m } } - incident := expandNewAlertRuleIncidentConfiguration(d.Get("incident").([]interface{}), "create_incident_enabled", false) + incident := expandAlertRuleIncidentConfiguration(d.Get("incident").([]interface{}), "create_incident_enabled", false) param := alertrules.ScheduledAlertRule{ Properties: &alertrules.ScheduledAlertRuleProperties{ Description: utils.String(d.Get("description").(string)), DisplayName: d.Get("display_name").(string), - Tactics: expandNewAlertRuleTactics(d.Get("tactics").(*pluginsdk.Set).List()), + Tactics: expandAlertRuleTactics(d.Get("tactics").(*pluginsdk.Set).List()), Techniques: expandAlertRuleTechnicals(d.Get("techniques").(*pluginsdk.Set).List()), IncidentConfiguration: incident, Severity: pointer.To(alertrules.AlertSeverity(d.Get("severity").(string))), @@ -429,7 +429,7 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m param.Properties.EventGroupingSettings = expandAlertRuleScheduledEventGroupingSetting(v.([]interface{})) } if v, ok := d.GetOk("alert_details_override"); ok { - param.Properties.AlertDetailsOverride = expandNewAlertRuleAlertDetailsOverride(v.([]interface{})) + param.Properties.AlertDetailsOverride = expandAlertRuleAlertDetailsOverride(v.([]interface{})) } if v, ok := d.GetOk("custom_details"); ok { param.Properties.CustomDetails = utils.ExpandPtrMapStringString(v.(map[string]interface{})) @@ -438,11 +438,11 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m entityMappingCount := 0 sentinelEntityMappingCount := 0 if v, ok := d.GetOk("entity_mapping"); ok { - param.Properties.EntityMappings = expandNewAlertRuleEntityMapping(v.([]interface{})) + param.Properties.EntityMappings = expandAlertRuleEntityMapping(v.([]interface{})) entityMappingCount = len(*param.Properties.EntityMappings) } if v, ok := d.GetOk("sentinel_entity_mapping"); ok { - param.Properties.SentinelEntitiesMappings = expandNewAlertRuleSentinelEntityMapping(v.([]interface{})) + param.Properties.SentinelEntitiesMappings = expandAlertRuleSentinelEntityMapping(v.([]interface{})) sentinelEntityMappingCount = len(*param.Properties.SentinelEntitiesMappings) } @@ -457,7 +457,7 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q: %+v", id, err) } - if err := assertNewAlertRuleKind(resp.Model, alertrules.AlertRuleKindScheduled); err != nil { + if err := assertAlertRuleKind(resp.Model, alertrules.AlertRuleKindScheduled); err != nil { return fmt.Errorf("asserting alert rule of %q: %+v", id, err) } } @@ -472,7 +472,7 @@ func resourceSentinelAlertRuleScheduledCreateUpdate(d *pluginsdk.ResourceData, m } func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Sentinel.NewAlertRulesClient + client := meta.(*clients.Client).Sentinel.AlertRulesClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -492,7 +492,7 @@ func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta inte return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q: %+v", id, err) } - if err := assertNewAlertRuleKind(resp.Model, alertrules.AlertRuleKindScheduled); err != nil { + if err := assertAlertRuleKind(resp.Model, alertrules.AlertRuleKindScheduled); err != nil { return fmt.Errorf("asserting alert rule of %q: %+v", id, err) } @@ -506,14 +506,14 @@ func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta inte if prop := rule.Properties; prop != nil { d.Set("description", prop.Description) d.Set("display_name", prop.DisplayName) - if err := d.Set("tactics", flattenNewAlertRuleTactics(prop.Tactics)); err != nil { + if err := d.Set("tactics", flattenAlertRuleTactics(prop.Tactics)); err != nil { return fmt.Errorf("setting `tactics`: %+v", err) } if err := d.Set("techniques", prop.Techniques); err != nil { return fmt.Errorf("setting `techniques`: %+v", err) } - if err := d.Set("incident", flattenNewAlertRuleIncidentConfiguration(prop.IncidentConfiguration, "create_incident_enabled", false)); err != nil { + if err := d.Set("incident", flattenAlertRuleIncidentConfiguration(prop.IncidentConfiguration, "create_incident_enabled", false)); err != nil { return fmt.Errorf("setting `incident`: %+v", err) } @@ -532,16 +532,16 @@ func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta inte if err := d.Set("event_grouping", flattenAlertRuleScheduledEventGroupingSetting(prop.EventGroupingSettings)); err != nil { return fmt.Errorf("setting `event_grouping`: %+v", err) } - if err := d.Set("alert_details_override", flattenNewAlertRuleAlertDetailsOverride(prop.AlertDetailsOverride)); err != nil { + if err := d.Set("alert_details_override", flattenAlertRuleAlertDetailsOverride(prop.AlertDetailsOverride)); err != nil { return fmt.Errorf("setting `alert_details_override`: %+v", err) } if err := d.Set("custom_details", utils.FlattenPtrMapStringString(prop.CustomDetails)); err != nil { return fmt.Errorf("setting `custom_details`: %+v", err) } - if err := d.Set("entity_mapping", flattenNewAlertRuleEntityMapping(prop.EntityMappings)); err != nil { + if err := d.Set("entity_mapping", flattenAlertRuleEntityMapping(prop.EntityMappings)); err != nil { return fmt.Errorf("setting `entity_mapping`: %+v", err) } - if err := d.Set("sentinel_entity_mapping", flattenNewAlertRuleSentinelEntityMapping(prop.SentinelEntitiesMappings)); err != nil { + if err := d.Set("sentinel_entity_mapping", flattenAlertRuleSentinelEntityMapping(prop.SentinelEntitiesMappings)); err != nil { return fmt.Errorf("setting `sentinel_entity_mapping`: %+v", err) } } @@ -552,7 +552,7 @@ func resourceSentinelAlertRuleScheduledRead(d *pluginsdk.ResourceData, meta inte } func resourceSentinelAlertRuleScheduledDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Sentinel.NewAlertRulesClient + client := meta.(*clients.Client).Sentinel.AlertRulesClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource_test.go b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource_test.go index d076434cc3de..859ff1a133df 100644 --- a/internal/services/sentinel/sentinel_alert_rule_scheduled_resource_test.go +++ b/internal/services/sentinel/sentinel_alert_rule_scheduled_resource_test.go @@ -179,7 +179,7 @@ func (t SentinelAlertRuleScheduledResource) Exists(ctx context.Context, clients return nil, err } - resp, err := clients.Sentinel.NewAlertRulesClient.Get(ctx, *id) + resp, err := clients.Sentinel.AlertRulesClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading Sentinel Alert Rule Scheduled %q: %v", id, err) }