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

add grafana_oncall_user_notification_rule resource #1653

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
111 changes: 111 additions & 0 deletions docs/resources/oncall_user_notification_rule.md
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_sms, notify_by_phone_call, notify_by_telegram, notify_by_email, notify_by_mobile_app, notify_by_mobile_app_critical
- `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. Position=-1 will put the escalation policy to the end of the list. 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 }}"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import grafana_oncall_user_notification_rule.name "{{ id }}"
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"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/fatih/color v1.17.0
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/strfmt v0.23.0
github.com/grafana/amixr-api-go-client v0.0.12-0.20240410110211-c9f68db085c4 // main branch
github.com/grafana/amixr-api-go-client v0.0.12 // main branch
github.com/grafana/grafana-com-public-clients/go/gcom v0.0.0-20240322153219-42c6a1d2bcab
github.com/grafana/grafana-openapi-client-go v0.0.0-20240523010106-657d101fcbd9
github.com/grafana/machine-learning-go-client v0.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grafana/amixr-api-go-client v0.0.12-0.20240410110211-c9f68db085c4 h1:e7cZfDiNodjQn63be9m8zfnvMEQAMqHVFswjcbdlspk=
github.com/grafana/amixr-api-go-client v0.0.12-0.20240410110211-c9f68db085c4/go.mod h1:N6x26XUrM5zGtK5zL5vNJnAn2JFMxLFPPLTw/6pDkFE=
github.com/grafana/amixr-api-go-client v0.0.12 h1:oEHZTBhxoZ35EsfeccZBJGPKhZUVOmdSir3WWnSJMLc=
github.com/grafana/amixr-api-go-client v0.0.12/go.mod h1:N6x26XUrM5zGtK5zL5vNJnAn2JFMxLFPPLTw/6pDkFE=
github.com/grafana/grafana-com-public-clients/go/gcom v0.0.0-20240322153219-42c6a1d2bcab h1:/5R8NO996/keDkZqKXEkU3/QgFs1wzChKYkakjsBpRk=
github.com/grafana/grafana-com-public-clients/go/gcom v0.0.0-20240322153219-42c6a1d2bcab/go.mod h1:6sYY1qgwYfSDNQhKQA0tar8Oc38cIGfyqwejhxoOsPs=
github.com/grafana/grafana-openapi-client-go v0.0.0-20240523010106-657d101fcbd9 h1:lOumw0RmkvKsTRMm6e5x2x6EbtyTeIKhy8ZJaK1KW9w=
Expand Down
Loading
Loading