Skip to content

Commit

Permalink
Feat | Add input_channel_id on sentry_metric_alert
Browse files Browse the repository at this point in the history
  • Loading branch information
geototti21 committed Feb 18, 2023
1 parent 0d0817a commit d361071
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/data-sources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ resource "sentry_metric_alert" "copy" {
target_type = action.value.target_type
target_identifier = action.value.target_identifier
integration_id = action.value.integration_id
input_channel_id = action.value.input_channel_id
}
}
Expand Down Expand Up @@ -97,6 +98,7 @@ Read-Only:
Read-Only:

- `id` (String)
- `input_channel_id` (String)
- `integration_id` (Number)
- `target_identifier` (String)
- `target_type` (String)
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "sentry_metric_alert" "main" {
type = "slack"
target_type = "specific"
target_identifier = "#slack-channel"
input_channel_id = "C0XXXXXXXXX" #
integration_id = data.sentry_organization_integration.slack.id
}
alert_threshold = 300
Expand Down Expand Up @@ -116,6 +117,7 @@ Required:

Optional:

- `input_channel_id` (String) Slack channel ID to avoid rate-limiting, see [here](https://docs.sentry.io/product/integrations/notification-incidents/slack/#rate-limiting-error)
- `integration_id` (Number)
- `target_identifier` (String)

Expand Down
1 change: 1 addition & 0 deletions examples/data-sources/sentry_metric_alert/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ resource "sentry_metric_alert" "copy" {
target_type = action.value.target_type
target_identifier = action.value.target_identifier
integration_id = action.value.integration_id
input_channel_id = action.value.input_channel_id
}
}

Expand Down
1 change: 1 addition & 0 deletions examples/resources/sentry_metric_alert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "sentry_metric_alert" "main" {
type = "slack"
target_type = "specific"
target_identifier = "#slack-channel"
input_channel_id = "C0XXXXXXXXX" #
integration_id = data.sentry_organization_integration.slack.id
}
alert_threshold = 300
Expand Down
4 changes: 4 additions & 0 deletions sentry/data_source_sentry_metric_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func dataSourceSentryMetricAlert() *schema.Resource {
Type: schema.TypeInt,
Computed: true,
},
"input_channel_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
Expand Down
11 changes: 11 additions & 0 deletions sentry/resource_sentry_metric_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func resourceSentryMetricAlert() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"input_channel_id": {
Type: schema.TypeString,
Optional: true,
Description: "Slack channel ID to avoid rate-limiting, see [here](https://docs.sentry.io/product/integrations/notification-incidents/slack/#rate-limiting-error)",
},
},
},
},
Expand Down Expand Up @@ -356,6 +361,11 @@ func expandMetricAlertTriggerActions(actionList []interface{}) []*sentry.MetricA
action.IntegrationID = sentry.Int(v)
}
}
if v, ok := actionMap["input_channel_id"].(string); ok {
if v != "" {
action.InputChannelID = sentry.String(v)
}
}
actions = append(actions, action)
}
return actions
Expand Down Expand Up @@ -393,6 +403,7 @@ func flattenMetricAlertTriggerActions(actions []*sentry.MetricAlertTriggerAction
actionMap["target_type"] = action.TargetType
actionMap["target_identifier"] = action.TargetIdentifier
actionMap["integration_id"] = action.IntegrationID
actionMap["input_channel_id"] = action.InputChannelID

actionList = append(actionList, actionMap)
}
Expand Down

0 comments on commit d361071

Please sign in to comment.