Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyeqf committed Feb 9, 2023
1 parent d3334f6 commit e89cd2f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type AlertRuleAnomalyBuiltInModel struct {
Name string `tfschema:"name"`
DisplayName string `tfschema:"display_name"`
WorkspaceId string `tfschema:"log_analytics_workspace_id"`
CustomizableObservations string `tfschema:"customizable_observations"`
Enabled bool `tfschema:"enabled"`
Mode string `tfschema:"mode"`
AnomalyVersion string `tfschema:"anomaly_version"`
Expand Down Expand Up @@ -103,10 +102,6 @@ func (r AlertRuleAnomalyBuiltInResource) Attributes() map[string]*schema.Schema
Type: pluginsdk.TypeInt,
Computed: true,
},
"customizable_observations": {
Type: pluginsdk.TypeString,
Computed: true,
},
"description": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -425,31 +420,22 @@ func (r AlertRuleAnomalyBuiltInResource) Delete() sdk.ResourceFunc {
param := securityinsight.AnomalySecurityMLAnalyticsSettings{
Kind: securityinsight.KindBasicSecurityMLAnalyticsSettingKindAnomaly,
AnomalySecurityMLAnalyticsSettingsProperties: &securityinsight.AnomalySecurityMLAnalyticsSettingsProperties{
Description: existing.Description,
DisplayName: existing.DisplayName,
RequiredDataConnectors: existing.RequiredDataConnectors,
Tactics: existing.Tactics,
Techniques: existing.Techniques,
AnomalyVersion: existing.AnomalyVersion,
Frequency: existing.Frequency,
IsDefaultSettings: existing.IsDefaultSettings,
AnomalySettingsVersion: existing.AnomalySettingsVersion,
SettingsDefinitionID: existing.SettingsDefinitionID,
Enabled: utils.Bool(false),
SettingsStatus: securityinsight.SettingsStatus(metaModel.Mode),
Description: existing.Description,
DisplayName: existing.DisplayName,
RequiredDataConnectors: existing.RequiredDataConnectors,
Tactics: existing.Tactics,
Techniques: existing.Techniques,
AnomalyVersion: existing.AnomalyVersion,
Frequency: existing.Frequency,
IsDefaultSettings: existing.IsDefaultSettings,
AnomalySettingsVersion: existing.AnomalySettingsVersion,
SettingsDefinitionID: existing.SettingsDefinitionID,
Enabled: utils.Bool(false),
SettingsStatus: securityinsight.SettingsStatus(metaModel.Mode),
CustomizableObservations: existing.CustomizableObservations,
},
}

if metaModel.CustomizableObservations != "" {
v, err := pluginsdk.ExpandJsonFromString(metaModel.CustomizableObservations)
if err != nil {
return fmt.Errorf("expanding `customizable_observations`: %+v", err)
}
param.AnomalySecurityMLAnalyticsSettingsProperties.CustomizableObservations = v
} else {
param.AnomalySecurityMLAnalyticsSettingsProperties.CustomizableObservations = existing.CustomizableObservations
}

_, err = client.CreateOrUpdate(ctx, id.ResourceGroup, id.WorkspaceName, id.SecurityMLAnalyticsSettingName, param)
if err != nil {
return fmt.Errorf("updating %s: %+v", id, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ func (a AlertRuleAnomalyDataSource) Attributes() map[string]*schema.Schema {
Type: pluginsdk.TypeInt,
Computed: true,
},
"customizable_observations": {
Type: pluginsdk.TypeString,
Computed: true,
},
"description": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down
2 changes: 0 additions & 2 deletions website/docs/d/sentinel_alert_rule_anomaly.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `anomaly_version` - The anomaly version of the Anomaly Alert Rule.

* `customizable_observations` - The customizable observations of the Anomaly Alert Rule.

* `description` - The description of the Anomaly Alert Rule.

* `enabled` - Is the Anomaly Alert Rule enabled?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `techniques` - A list of techniques of attacks by which to classify the rule.

* `customizable_observations` - The customizable observations of the Built-in Anomaly Alert Rule.

* `multi_select_observation` - A list of `multi_select_observation` blocks as defined below.

* `single_select_observation` - A list of `single_select_observation` blocks as defined below.
Expand Down

0 comments on commit e89cd2f

Please sign in to comment.