-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
grafana_oncall_user_notification_rule
resource (#1653)
* add `grafana_oncall_user_notification_rule` resource * WIP * WIP * WIP * WIP * docs + update `github.com/grafana/amixr-api-go-client` package to latest version * linting * remove unused code * update `type` documentation * update tests * `go generate` * `make golangci-lint` * update tests * update tests * update tests * change test user_id * change test user id * update tests * update tests * update tests
- Loading branch information
1 parent
7e0ceeb
commit 3b74b81
Showing
8 changed files
with
681 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "grafana_oncall_user_notification_rule Resource - terraform-provider-grafana" | ||
subcategory: "OnCall" | ||
description: |- | ||
HTTP API https://grafana.com/docs/oncall/latest/oncall-api-reference/personal_notification_rules/ | ||
Note: you must be running Grafana OnCall >= v1.8.0 to use this resource. | ||
--- | ||
|
||
# grafana_oncall_user_notification_rule (Resource) | ||
|
||
* [HTTP API](https://grafana.com/docs/oncall/latest/oncall-api-reference/personal_notification_rules/) | ||
|
||
**Note**: you must be running Grafana OnCall >= v1.8.0 to use this resource. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "grafana_oncall_user" "my_user" { | ||
provider = grafana.oncall | ||
username = "my_username" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_step_1" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 0 | ||
type = "notify_by_mobile_app" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_step_2" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 1 | ||
duration = 600 # 10 minutes | ||
type = "wait" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_step_3" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 2 | ||
type = "notify_by_phone_call" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_step_4" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 3 | ||
duration = 300 # 5 minutes | ||
type = "wait" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_step_5" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 4 | ||
type = "notify_by_slack" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_1" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 0 | ||
type = "notify_by_mobile_app_critical" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_2" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 1 | ||
duration = 300 # 5 minutes | ||
type = "wait" | ||
} | ||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_3" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 2 | ||
type = "notify_by_mobile_app_critical" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `type` (String) The type of notification rule. Can be wait, notify_by_slack, notify_by_msteams, notify_by_sms, notify_by_phone_call, notify_by_telegram, notify_by_email, notify_by_mobile_app, notify_by_mobile_app_critical. NOTE: `notify_by_msteams` is only available for Grafana Cloud customers. | ||
- `user_id` (String) User ID | ||
|
||
### Optional | ||
|
||
- `duration` (Number) A time in seconds to wait (when `type=wait`). Can be 60, 300, 900, 1800, 3600 | ||
- `important` (Boolean) Boolean value which indicates if a rule is “important” | ||
- `position` (Number) Personal notification rules execute one after another starting from position=0. A new escalation policy created with a position of an existing escalation policy will move the old one (and all following) down on the list. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import grafana_oncall_user_notification_rule.name "{{ id }}" | ||
``` |
1 change: 1 addition & 0 deletions
1
examples/resources/grafana_oncall_user_notification_rule/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import grafana_oncall_user_notification_rule.name "{{ id }}" |
66 changes: 66 additions & 0 deletions
66
examples/resources/grafana_oncall_user_notification_rule/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
data "grafana_oncall_user" "my_user" { | ||
provider = grafana.oncall | ||
username = "my_username" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_step_1" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 0 | ||
type = "notify_by_mobile_app" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_step_2" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 1 | ||
duration = 600 # 10 minutes | ||
type = "wait" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_step_3" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 2 | ||
type = "notify_by_phone_call" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_step_4" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 3 | ||
duration = 300 # 5 minutes | ||
type = "wait" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_step_5" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
position = 4 | ||
type = "notify_by_slack" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_1" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 0 | ||
type = "notify_by_mobile_app_critical" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_2" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 1 | ||
duration = 300 # 5 minutes | ||
type = "wait" | ||
} | ||
|
||
resource "grafana_oncall_user_notification_rule" "my_user_important_step_3" { | ||
provider = grafana.oncall | ||
user_id = data.grafana_oncall_user.my_user.id | ||
important = true | ||
position = 2 | ||
type = "notify_by_mobile_app_critical" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.