Skip to content

Commit

Permalink
Merge pull request #89 from iLert/add-microsoft-teams-webhook
Browse files Browse the repository at this point in the history
add microsoft_teams_webhook to alert actions
  • Loading branch information
yacut authored Jul 19, 2024
2 parents 62d9395 + 21d6d97 commit 0ae944b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 19.07.2024, Version 2.8.5

- Add microsoft_teams_webhook to alert actions [#89](https://github.com/iLert/terraform-provider-ilert/pull/89)

## 09.07.2024, Version 2.8.4

- Add region to user [#87](https://github.com/iLert/terraform-provider-ilert/pull/88)
- Add region to user [#88](https://github.com/iLert/terraform-provider-ilert/pull/88)

## 03.07.2024, Version 2.8.0

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
github.com/iLert/ilert-go/v3 v3.8.1
github.com/iLert/ilert-go/v3 v3.8.3
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iLert/ilert-go/v3 v3.8.1 h1:tdsrXlEKh43+rAkyufC0pUTYRYVYlIAJiGWw164wCWE=
github.com/iLert/ilert-go/v3 v3.8.1/go.mod h1:xHJ8qdmthK4HExcQOd3V5JARed/EBKTdX86MqrJ1yJ0=
github.com/iLert/ilert-go/v3 v3.8.3 h1:QY3aYHzQ4JDCP/36TMxwDKtsvMU1Rd7cPrVBN8VeVEA=
github.com/iLert/ilert-go/v3 v3.8.3/go.mod h1:xHJ8qdmthK4HExcQOd3V5JARed/EBKTdX86MqrJ1yJ0=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
Expand Down
32 changes: 32 additions & 0 deletions ilert/resource_alert_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,22 @@ func resourceAlertAction() *schema.Resource {
},
},
},
"microsoft_teams_webhook": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
MinItems: 1,
ForceNew: true,
ConflictsWith: removeStringsFromSlice(alertActionTypesAll, ilert.ConnectorTypes.MicrosoftTeamsWebhook),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"url": {
Type: schema.TypeString,
Required: true,
},
},
},
},
"created_at": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -817,6 +833,16 @@ func buildAlertAction(d *schema.ResourceData) (*ilert.AlertAction, error) {
}
}

if val, ok := d.GetOk("microsoft_teams_webhook"); ok {
vL := val.([]interface{})
if len(vL) > 0 {
v := vL[0].(map[string]interface{})
alertAction.Params = &ilert.AlertActionParamsMicrosoftTeamsWebhook{
URL: v["url"].(string),
}
}
}

if val, ok := d.GetOk("alert_filter"); ok {
vL := val.([]interface{})
if len(vL) > 0 {
Expand Down Expand Up @@ -1098,6 +1124,12 @@ func resourceAlertActionRead(ctx context.Context, d *schema.ResourceData, m inte
"type": result.AlertAction.Params.Type,
},
})
case ilert.ConnectorTypes.MicrosoftTeamsWebhook:
d.Set("microsoft_teams_webhook", []interface{}{
map[string]interface{}{
"url": result.AlertAction.Params.URL,
},
})
}

alertFilter, err := flattenAlertActionAlertFilter(result.AlertAction.AlertFilter)
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/alert_action.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The following arguments are supported:
- `automation_rule` - (Optional) An [automation_rule](#automation-rule-arguments) block.
- `telegram` - (Optional) An [telegram](#telegram-arguments) block.
- `microsoft_teams_bot` - (Optional) A [microsoft_teams_bot](#microsoft-teams-bot-arguments) block.
- `microsoft_teams_webhook` - (Optional) A [microsoft_teams_webhook](#microsoft-teams-webhook-arguments) block.
- `alert_filter` - (Optional) An [alert_filter](#alert-filter-arguments) block.
- `team` - (Optional) One or more [team](#team-arguments) blocks.

Expand Down Expand Up @@ -216,6 +217,12 @@ The following arguments are supported:
- `team_name` - (Optional) The name of the team.
- `type` - (Required) The type of the bot setup. Allowed values are `chat` or `meeting`.

#### Microsoft teams webhook Arguments

> See [the Microsoft teams bot integration documentation](https://docs.ilert.com/chatops/microsoft-teams/chat/workflows) for more details.
- `url` - (Required) The workflow URL for the channel.

#### Alert Filter Arguments

- `operator` - (Required) The operator to use for the filter. Allowed values are `AND` or `OR`.
Expand Down

0 comments on commit 0ae944b

Please sign in to comment.