Skip to content

Commit

Permalink
Incorporate schema change suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Farrell <[email protected]>
  • Loading branch information
owenfarrell committed Sep 15, 2021
1 parent bbe0756 commit e27235c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func resourceSynapseSqlPoolSecurityAlertPolicyRead(d *pluginsdk.ResourceData, me
d.Set("sql_pool_id", sqlPoolId.ID())

if props := resp.SecurityAlertPolicyProperties; props != nil {
d.Set("state", string(props.State))
d.Set("policy_state", string(props.State))

if props.DisabledAlerts != nil {
disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{})
Expand All @@ -169,7 +169,7 @@ func resourceSynapseSqlPoolSecurityAlertPolicyRead(d *pluginsdk.ResourceData, me
}

if props.EmailAccountAdmins != nil {
d.Set("email_account_admins", props.EmailAccountAdmins)
d.Set("email_account_admins_enabled", props.EmailAccountAdmins)
}

if props.EmailAddresses != nil {
Expand Down Expand Up @@ -224,11 +224,11 @@ func resourceSynapseSqlPoolSecurityAlertPolicyDelete(d *pluginsdk.ResourceData,
}

func expandSQLPoolSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.SQLPoolSecurityAlertPolicy {
state := synapse.SecurityAlertPolicyState(d.Get("state").(string))
policyState := synapse.SecurityAlertPolicyState(d.Get("policy_state").(string))

policy := synapse.SQLPoolSecurityAlertPolicy{
SecurityAlertPolicyProperties: &synapse.SecurityAlertPolicyProperties{
State: state,
State: policyState,
},
}

Expand All @@ -250,7 +250,7 @@ func expandSQLPoolSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.SQLPoo
props.EmailAddresses = &emailAddresses
}

if v, ok := d.GetOk("email_account_admins"); ok {
if v, ok := d.GetOk("email_account_admins_enabled"); ok {
props.EmailAccountAdmins = utils.Bool(v.(bool))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r SynapseSqlPoolSecurityAlertPolicyResource) basic(data acceptance.TestDat
resource "azurerm_synapse_sql_pool_security_alert_policy" "test" {
sql_pool_id = azurerm_synapse_sql_pool.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
retention_days = 20
Expand All @@ -93,10 +93,10 @@ func (r SynapseSqlPoolSecurityAlertPolicyResource) update(data acceptance.TestDa
%[1]s
resource "azurerm_synapse_sql_pool_security_alert_policy" "test" {
sql_pool_id = azurerm_synapse_sql_pool.test.id
state = "Enabled"
email_account_admins = true
retention_days = 30
sql_pool_id = azurerm_synapse_sql_pool.test.id
policy_state = "Enabled"
email_account_admins_enabled = true
retention_days = 30
}
`, r.template(data))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func resourceSynapseWorkspaceSecurityAlertPolicyRead(d *pluginsdk.ResourceData,
d.Set("synapse_workspace_id", workspaceId.ID())

if props := resp.ServerSecurityAlertPolicyProperties; props != nil {
d.Set("state", string(props.State))
d.Set("policy_state", string(props.State))

if props.DisabledAlerts != nil {
disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{})
Expand All @@ -173,7 +173,7 @@ func resourceSynapseWorkspaceSecurityAlertPolicyRead(d *pluginsdk.ResourceData,
}

if props.EmailAccountAdmins != nil {
d.Set("email_account_admins", props.EmailAccountAdmins)
d.Set("email_account_admins_enabled", props.EmailAccountAdmins)
}

if props.EmailAddresses != nil {
Expand Down Expand Up @@ -232,11 +232,11 @@ func resourceSynapseWorkspaceSecurityAlertPolicyDelete(d *pluginsdk.ResourceData
}

func expandServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.ServerSecurityAlertPolicy {
state := synapse.SecurityAlertPolicyState(d.Get("state").(string))
policyState := synapse.SecurityAlertPolicyState(d.Get("policy_state").(string))

policy := synapse.ServerSecurityAlertPolicy{
ServerSecurityAlertPolicyProperties: &synapse.ServerSecurityAlertPolicyProperties{
State: state,
State: policyState,
},
}

Expand All @@ -258,7 +258,7 @@ func expandServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.ServerS
props.EmailAddresses = &emailAddresses
}

if v, ok := d.GetOk("email_account_admins"); ok {
if v, ok := d.GetOk("email_account_admins_enabled"); ok {
props.EmailAccountAdmins = utils.Bool(v.(bool))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r SynapseWorkspaceSecurityAlertPolicyResource) basic(data acceptance.TestD
resource "azurerm_synapse_workspace_security_alert_policy" "test" {
synapse_workspace_id = azurerm_synapse_workspace.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
retention_days = 20
Expand All @@ -93,10 +93,10 @@ func (r SynapseWorkspaceSecurityAlertPolicyResource) update(data acceptance.Test
%[1]s
resource "azurerm_synapse_workspace_security_alert_policy" "test" {
synapse_workspace_id = azurerm_synapse_workspace.test.id
state = "Enabled"
email_account_admins = true
retention_days = 30
synapse_workspace_id = azurerm_synapse_workspace.test.id
policy_state = "Enabled"
email_account_admins_enabled = true
retention_days = 30
}
`, r.template(data))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ The following arguments are supported:

* `sql_pool_id` - (Required) Specifies the ID of the Synapse SQL Pool. Changing this forces a new resource to be created.

* `state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific SQL pool. Allowed values are: `Disabled`, `Enabled`.
* `policy_state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific SQL pool. Allowed values are: `Disabled`, `Enabled`.

* `disabled_alerts` - (Optional) Specifies an array of alerts that are disabled. Allowed values are: `Sql_Injection`, `Sql_Injection_Vulnerability`, `Access_Anomaly`, `Data_Exfiltration`, `Unsafe_Action`.

* `email_account_admins` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.
* `email_account_admins_enabled` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.

* `email_addresses` - (Optional) Specifies an array of e-mail addresses to which the alert is sent.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ The following arguments are supported:

* `synapse_workspace_id` - (Required) Specifies the ID of the Synapse Workspace. Changing this forces a new resource to be created.

* `state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific workspace. Allowed values are: `Disabled`, `Enabled`.
* `policy_state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific workspace. Allowed values are: `Disabled`, `Enabled`.

* `disabled_alerts` - (Optional) Specifies an array of alerts that are disabled. Allowed values are: `Sql_Injection`, `Sql_Injection_Vulnerability`, `Access_Anomaly`, `Data_Exfiltration`, `Unsafe_Action`.

* `email_account_admins` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.
* `email_account_admins_enabled` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.

* `email_addresses` - (Optional) Specifies an array of e-mail addresses to which the alert is sent.

Expand Down

0 comments on commit e27235c

Please sign in to comment.