Skip to content

Commit 34b6381

Browse files
Add message_thread_id for Telegram contact points (#1234)
* Add message_thread_id for Telegram contact points * Update resource_alerting_contact_point_notifiers.go * Fix casing and tests The attribute is `message_thread_id`, according to grafana/grafana#79546 * Try with an integer --------- Co-authored-by: Julien Duchesne <[email protected]>
1 parent 2766bd3 commit 34b6381

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

docs/resources/contact_point.md

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Optional:
437437
- `disable_resolve_message` (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
438438
- `disable_web_page_preview` (Boolean) When set it disables link previews for links in the message.
439439
- `message` (String) The templated content of the message.
440+
- `message_thread_id` (String) The ID of the message thread to send the message to.
440441
- `parse_mode` (String) Mode for parsing entities in the message text. Supported: None, Markdown, MarkdownV2, and HTML. HTML is the default.
441442
- `protect_content` (Boolean) When set it protects the contents of the message from forwarding and saving.
442443
- `settings` (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.

examples/resources/grafana_contact_point/_acc_receiver_types.tf

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ resource "grafana_contact_point" "receiver_types" {
130130
telegram {
131131
token = "token"
132132
chat_id = "chat-id"
133+
message_thread_id = "5"
133134
message = "message"
134135
parse_mode = "Markdown"
135136
disable_web_page_preview = true

internal/resources/grafana/resource_alerting_contact_point_notifiers.go

+7
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,11 @@ func (t telegramNotifier) schema() *schema.Resource {
17821782
Optional: true,
17831783
Description: "The templated content of the message.",
17841784
}
1785+
r.Schema["message_thread_id"] = &schema.Schema{
1786+
Type: schema.TypeString,
1787+
Optional: true,
1788+
Description: "The ID of the message thread to send the message to.",
1789+
}
17851790
r.Schema["parse_mode"] = &schema.Schema{
17861791
Type: schema.TypeString,
17871792
Optional: true,
@@ -1812,6 +1817,7 @@ func (t telegramNotifier) pack(p *models.EmbeddedContactPoint, data *schema.Reso
18121817

18131818
packNotifierStringField(&settings, &notifier, "bottoken", "token")
18141819
packNotifierStringField(&settings, &notifier, "chatid", "chat_id")
1820+
packNotifierStringField(&settings, &notifier, "message_thread_id", "message_thread_id")
18151821
packNotifierStringField(&settings, &notifier, "message", "message")
18161822
packNotifierStringField(&settings, &notifier, "parse_mode", "parse_mode")
18171823

@@ -1840,6 +1846,7 @@ func (t telegramNotifier) unpack(raw interface{}, name string) *models.EmbeddedC
18401846

18411847
unpackNotifierStringField(&json, &settings, "token", "bottoken")
18421848
unpackNotifierStringField(&json, &settings, "chat_id", "chatid")
1849+
unpackNotifierStringField(&json, &settings, "message_thread_id", "message_thread_id")
18431850
unpackNotifierStringField(&json, &settings, "message", "message")
18441851
unpackNotifierStringField(&json, &settings, "parse_mode", "parse_mode")
18451852

internal/resources/grafana/resource_alerting_contact_point_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ func TestAccContactPoint_notifiers(t *testing.T) {
271271
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.#", "1"),
272272
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.token", "token"),
273273
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.chat_id", "chat-id"),
274+
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.message_thread_id", "5"),
274275
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.message", "message"),
275276
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.parse_mode", "Markdown"),
276277
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "telegram.0.disable_web_page_preview", "true"),

0 commit comments

Comments
 (0)