Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat | Add input_channel_id on sentry_metric_alert #282

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/data-sources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ resource "sentry_metric_alert" "copy" {
type = action.value.type
target_type = action.value.target_type
target_identifier = action.value.target_identifier
input_channel_id = action.value.input_channel_id
integration_id = action.value.integration_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 @@ -27,6 +27,7 @@ resource "sentry_metric_alert" "copy" {
type = action.value.type
target_type = action.value.target_type
target_identifier = action.value.target_identifier
input_channel_id = action.value.input_channel_id
integration_id = action.value.integration_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 @@ -105,6 +105,10 @@ func dataSourceSentryMetricAlert() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"input_channel_id": {
Type: schema.TypeString,
Computed: true,
},
"integration_id": {
Type: schema.TypeInt,
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 @@ -115,6 +115,11 @@ func resourceSentryMetricAlert() *schema.Resource {
Type: schema.TypeString,
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)",
},
"integration_id": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -351,6 +356,11 @@ func expandMetricAlertTriggerActions(actionList []interface{}) []*sentry.MetricA
action.TargetIdentifier = sentry.String(v)
}
}
if v, ok := actionMap["input_channel_id"].(string); ok {
if v != "" {
action.InputChannelID = sentry.String(v)
}
}
if v, ok := actionMap["integration_id"].(int); ok {
if v != 0 {
action.IntegrationID = sentry.Int(v)
Expand Down Expand Up @@ -392,6 +402,7 @@ func flattenMetricAlertTriggerActions(actions []*sentry.MetricAlertTriggerAction
actionMap["type"] = action.Type
actionMap["target_type"] = action.TargetType
actionMap["target_identifier"] = action.TargetIdentifier
actionMap["input_channel_id"] = action.InputChannelID
actionMap["integration_id"] = action.IntegrationID

actionList = append(actionList, actionMap)
Expand Down
Loading