From 9c82b7a5d0cce27f11119ee45622e680f7200388 Mon Sep 17 00:00:00 2001 From: Neha Dhar Date: Thu, 12 Oct 2023 23:28:43 -0700 Subject: [PATCH] SUMO-199581: timezone in monitor definition --- CHANGELOG.md | 2 ++ .../resource_sumologic_monitors_library_monitor.go | 7 +++++++ ...resource_sumologic_monitors_library_monitor_test.go | 10 ++++++++++ sumologic/sumologic_monitors_library_monitor.go | 1 + 4 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f3c505..682600ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## 2.27.1 (Unreleased) +FEATURES: +* resource/sumologic_monitor: Added support for setting `time_zone` at Monitor level for notifications content (GH-) ## 2.27.0 (September 28, 2023) FEATURES: diff --git a/sumologic/resource_sumologic_monitors_library_monitor.go b/sumologic/resource_sumologic_monitors_library_monitor.go index 5ae9b73a..2da20f49 100644 --- a/sumologic/resource_sumologic_monitors_library_monitor.go +++ b/sumologic/resource_sumologic_monitors_library_monitor.go @@ -65,6 +65,11 @@ func getMonitorBaseSchema() map[string]*schema.Schema { DiffSuppressFunc: SuppressEquivalentTimeDiff(false), }, + "time_zone": { + Type: schema.TypeString, + Optional: true, + }, + "alert_name": { Type: schema.TypeString, Optional: true, @@ -813,6 +818,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in d.Set("slo_id", monitor.SloID) d.Set("notification_group_fields", monitor.NotificationGroupFields) d.Set("tags", monitor.Tags) + d.Set("time_zone", monitor.TimeZone) // set notifications notifications := make([]interface{}, len(monitor.Notifications)) @@ -1564,6 +1570,7 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon ModifiedBy: d.Get("modified_by").(string), IsMutable: d.Get("is_mutable").(bool), Version: d.Get("version").(int), + TimeZone: d.Get("time_zone").(string), Notifications: notifications, Type: d.Get("type").(string), ParentID: d.Get("parent_id").(string), diff --git a/sumologic/resource_sumologic_monitors_library_monitor_test.go b/sumologic/resource_sumologic_monitors_library_monitor_test.go index 2502207c..5fb50f9f 100644 --- a/sumologic/resource_sumologic_monitors_library_monitor_test.go +++ b/sumologic/resource_sumologic_monitors_library_monitor_test.go @@ -203,6 +203,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) { testMonitorType := "Logs" testIsDisabled := false canonicalTestEvaluationDelay := "1h" + testTimeZone := "America/New_York" testQueries := []MonitorQuery{ { RowID: "A", @@ -272,6 +273,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType), @@ -372,6 +374,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { testPlaybook := "This is a test playbook" testIsDisabled := false canonicalTestEvaluationDelay := "1h" + testTimeZone := "America/New_York" testQueries := []MonitorQuery{ { RowID: "A", @@ -434,6 +437,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { testUpdatedPlaybook := "This is an updated test playbook" testUpdatedIsDisabled := true testUpdatedEvaluationDelay := "8m" + testUpdatedTimeZone := "America/Chicago" testUpdatedQueries := []MonitorQuery{ { RowID: "A", @@ -503,6 +507,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType), @@ -527,6 +532,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testUpdatedType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testUpdatedDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testUpdatedEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testUpdatedTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testUpdatedContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testUpdatedQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType), @@ -802,6 +808,7 @@ resource "sumologic_monitor" "test" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "60m" + time_zone = "America/New_York" queries { row_id = "A" query = "_sourceCategory=monitor-manager error" @@ -929,6 +936,7 @@ resource "sumologic_monitor" "test" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "8m" + time_zone = "America/Chicago" queries { row_id = "A" query = "_sourceCategory=monitor-manager info" @@ -1011,6 +1019,7 @@ resource "sumologic_monitor" "test_monitor_connection" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "8m" + time_zone = "IST" queries { row_id = "A" query = "_sourceCategory=monitor-manager info" @@ -1286,6 +1295,7 @@ resource "sumologic_monitor" "test" { is_disabled = false content_type = "Monitor" monitor_type = "Slo" + time_zone = "America/New_York" slo_id = sumologic_slo.slo_tf_window_metric_ratio.id trigger_conditions { %s diff --git a/sumologic/sumologic_monitors_library_monitor.go b/sumologic/sumologic_monitors_library_monitor.go index 7fbd2c38..089ec9c1 100644 --- a/sumologic/sumologic_monitors_library_monitor.go +++ b/sumologic/sumologic_monitors_library_monitor.go @@ -150,6 +150,7 @@ type MonitorsLibraryMonitor struct { SloID string `json:"sloId,omitempty"` NotificationGroupFields []string `json:"notificationGroupFields,omitempty"` Tags map[string]interface{} `json:"tags"` + TimeZone string `json:"timeZone"` } type MonitorQuery struct {