From bb1204533ed9685e91db92bfc53cfddccf6b69ae Mon Sep 17 00:00:00 2001 From: Alena Pantuzenko Date: Fri, 14 Feb 2025 16:54:29 -0500 Subject: [PATCH 1/3] point to a branch of go client --- go.mod | 2 ++ go.sum | 4 ++-- .../pagerduty/event_orchestration_cache_variable.go | 3 +++ vendor/modules.txt | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7b66f7284..963138f1f 100644 --- a/go.mod +++ b/go.mod @@ -76,3 +76,5 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + +replace github.com/heimweh/go-pagerduty => github.com/alenapan/go-pagerduty v0.0.0-20250214201653-b8d11443fbc3 diff --git a/go.sum b/go.sum index 9efef3b59..f1bb21d6f 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alenapan/go-pagerduty v0.0.0-20250214201653-b8d11443fbc3 h1:MBfCyrZBjR+vny6GBIdZlIelQZA11YL7EQK1GjdSiwQ= +github.com/alenapan/go-pagerduty v0.0.0-20250214201653-b8d11443fbc3/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= @@ -95,8 +97,6 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/heimweh/go-pagerduty v0.0.0-20250214190935-c474ec404dae h1:le7p/QnSPOQ4tnt+xjrAIu58JOdPyiNauGR8B2hRaoU= -github.com/heimweh/go-pagerduty v0.0.0-20250214190935-c474ec404dae/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= diff --git a/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_cache_variable.go b/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_cache_variable.go index 5d7232e40..da25ed60d 100644 --- a/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_cache_variable.go +++ b/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_cache_variable.go @@ -15,10 +15,12 @@ type EventOrchestrationCacheVariableCondition struct { // Configuration for a cache variable changes depending on the type: // - if `Type` is `recent_value`; then use `Regex` and `Source` // - if `Type` is `trigger_event_count`; then use `TTLSeconds` +// - if `Type` is `external_data`; then use `DataType` and `TTLSeconds` type EventOrchestrationCacheVariableConfiguration struct { Type string `json:"type,omitempty"` Regex string `json:"regex,omitempty"` Source string `json:"source,omitempty"` + DataType string `json:"data_type,omitempty"` TTLSeconds int `json:"ttl_seconds,omitempty"` } @@ -28,6 +30,7 @@ type EventOrchestrationCacheVariable struct { Disabled bool `json:"disabled"` Conditions []*EventOrchestrationCacheVariableCondition `json:"conditions"` Configuration *EventOrchestrationCacheVariableConfiguration `json:"configuration,omitempty"` + DataEndpoint string `json:"data_endpoint,omitempty"` CreatedAt string `json:"created_at,omitempty"` CreatedBy *UserReference `json:"created_by,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 57cb66d8b..75a5120e0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -261,7 +261,7 @@ github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.1.1 ## explicit; go 1.15 github.com/hashicorp/yamux -# github.com/heimweh/go-pagerduty v0.0.0-20250214190935-c474ec404dae +# github.com/heimweh/go-pagerduty v0.0.0-20250214190935-c474ec404dae => github.com/alenapan/go-pagerduty v0.0.0-20250214201653-b8d11443fbc3 ## explicit; go 1.17 github.com/heimweh/go-pagerduty/pagerduty github.com/heimweh/go-pagerduty/persistentconfig @@ -561,3 +561,4 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 +# github.com/heimweh/go-pagerduty => github.com/alenapan/go-pagerduty v0.0.0-20250214201653-b8d11443fbc3 From dc17a959a708c32102d5c3094aea3916e47b24a5 Mon Sep 17 00:00:00 2001 From: Alena Pantuzenko Date: Fri, 14 Feb 2025 18:00:44 -0500 Subject: [PATCH 2/3] ORCA-5140 - add support for Event Orchestration External Data Cache Variables --- ...event_orchestration_cache_variable_util.go | 61 +++++++++++++-- ...ent_orchestration_global_cache_variable.go | 2 +- ...rchestration_global_cache_variable_test.go | 76 ++++++++++++++++--- ...nt_orchestration_service_cache_variable.go | 2 +- ...chestration_service_cache_variable_test.go | 76 ++++++++++++++++--- 5 files changed, 188 insertions(+), 29 deletions(-) diff --git a/pagerduty/event_orchestration_cache_variable_util.go b/pagerduty/event_orchestration_cache_variable_util.go index 978136546..d339e857b 100644 --- a/pagerduty/event_orchestration_cache_variable_util.go +++ b/pagerduty/event_orchestration_cache_variable_util.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -27,6 +28,7 @@ var resourceEventOrchestrationCacheVariableConfigurationSchema = map[string]*sch ValidateDiagFunc: validateValueDiagFunc([]string{ "recent_value", "trigger_event_count", + "external_data", }), }, "regex": { @@ -37,6 +39,10 @@ var resourceEventOrchestrationCacheVariableConfigurationSchema = map[string]*sch Type: schema.TypeString, Optional: true, }, + "data_type": { + Type: schema.TypeString, + Optional: true, + }, "ttl_seconds": { Type: schema.TypeInt, Optional: true, @@ -63,30 +69,69 @@ var dataSourceEventOrchestrationCacheVariableConfigurationSchema = map[string]*s Type: schema.TypeString, Computed: true, }, + "data_type": { + Type: schema.TypeString, + Optional: true, + }, "ttl_seconds": { Type: schema.TypeInt, Computed: true, }, } -func checkConfiguration(context context.Context, diff *schema.ResourceDiff, i interface{}) error { +func checkEventOrchestrationCacheVariableConfiguration(context context.Context, diff *schema.ResourceDiff, i interface{}) error { + c := diff.Get("condition").([]interface{}) t := diff.Get("configuration.0.type").(string) s := diff.Get("configuration.0.source").(string) r := diff.Get("configuration.0.regex").(string) + dt := diff.Get("configuration.0.data_type").(string) ts := diff.Get("configuration.0.ttl_seconds").(int) - if t == "recent_value" && (r == "" || s == "") { - return fmt.Errorf("Invalid configuration: regex and source cannot be null when type is recent_value") + missingAttrErr := "" + unsupportedAttrErr := "" + + if t == "recent_value" { + if r == "" || s == "" { + missingAttrErr = "regex and source cannot be null" + } + if dt != "" || ts != 0 { + unsupportedAttrErr = "data_type and ttl_seconds cannot be used" + } } - if t == "trigger_event_count" && ts == 0 { - return fmt.Errorf("Invalid configuration: ttl_seconds cannot be null when type is trigger_event_count") + if t == "trigger_event_count" { + if ts == 0 { + missingAttrErr = "ttl_seconds cannot be null" + } + if r != "" || s != "" || dt != "" { + unsupportedAttrErr = "regex, source, and data_type cannot be used" + } } - if (r != "" || s != "") && ts != 0 { - return fmt.Errorf("Invalid configuration: ttl_seconds cannot be used in conjuction with regex and source") + if t == "external_data" { + if dt == "" || ts == 0 { + missingAttrErr = "data_type and ttl_seconds cannot be null" + } + if len(c) > 0 || r != "" || s != "" { + unsupportedAttrErr = "condition, regex and source cannot be used" + } + } + + if missingAttrErr != "" || unsupportedAttrErr != "" { + errors := formatErrors([]string{missingAttrErr, unsupportedAttrErr}) + return fmt.Errorf("Invalid configuration: %s when type is %s", errors, t) } return nil } +func formatErrors(errors []string) string { + var filtered []string + for _, s := range errors { + if s != "" { + filtered = append(filtered, s) + } + } + return strings.Join(filtered, ", and ") +} + func getIdentifier(cacheVariableType string) string { switch cacheVariableType { case pagerduty.CacheVariableTypeGlobal: @@ -169,6 +214,7 @@ func expandEventOrchestrationCacheVariableConfiguration(v interface{}) *pagerdut conf.Type = c["type"].(string) conf.Regex = c["regex"].(string) conf.Source = c["source"].(string) + conf.DataType = c["data_type"].(string) conf.TTLSeconds = c["ttl_seconds"].(int) } @@ -193,6 +239,7 @@ func flattenEventOrchestrationCacheVariableConfiguration(conf *pagerduty.EventOr "type": conf.Type, "regex": conf.Regex, "source": conf.Source, + "data_type": conf.DataType, "ttl_seconds": conf.TTLSeconds, } diff --git a/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable.go b/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable.go index a830d7975..9b13a52b0 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable.go +++ b/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable.go @@ -16,7 +16,7 @@ func resourcePagerDutyEventOrchestrationGlobalCacheVariable() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: resourcePagerDutyEventOrchestrationGlobalCacheVariableImport, }, - CustomizeDiff: checkConfiguration, + CustomizeDiff: checkEventOrchestrationCacheVariableConfiguration, Schema: map[string]*schema.Schema{ "event_orchestration": { Type: schema.TypeString, diff --git a/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable_test.go b/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable_test.go index c4bab0169..8c097fa36 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_global_cache_variable_test.go @@ -3,6 +3,7 @@ package pagerduty import ( "context" "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" @@ -26,20 +27,46 @@ func TestAccPagerDutyEventOrchestrationGlobalCacheVariable_Basic(t *testing.T) { orchn1 := "orch_1" name2 := fmt.Sprintf("tf_global_cache_variable_updated_%s", acctest.RandString(5)) orchn2 := "orch_2" - + invalidConfigRecentValue := ` + configuration { + type = "recent_value" + regex = ".*" + ttl_seconds = 300 + } + ` + invalidConfigTriggerEventCount := ` + configuration { + type = "trigger_event_count" + data_type = "string" + ttl_seconds = 60 + } + ` + invalidConfigExternalData := ` + configuration { + type = "external_data" + data_type = "boolean" + } + ` config1 := ` configuration { - type = "trigger_event_count" - ttl_seconds = 60 - } - ` + type = "trigger_event_count" + ttl_seconds = 60 + } + ` config2 := ` configuration { - type = "recent_value" - source = "event.summary" - regex = ".*" - } - ` + type = "recent_value" + source = "event.summary" + regex = ".*" + } + ` + config3 := ` + configuration { + type = "external_data" + data_type = "boolean" + ttl_seconds = 1200 + } + ` cond1 := `` cond2 := ` condition { @@ -54,6 +81,25 @@ func TestAccPagerDutyEventOrchestrationGlobalCacheVariable_Basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableDestroy, Steps: []resource.TestStep{ + // cache variable with an invalid configuration - recent_value: + { + Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, invalidConfigRecentValue, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: regex and source cannot be null, and data_type and ttl_seconds cannot be used when type is recent_value"), + }, + // cache variable with an invalid configuration - trigger_event_count: + { + Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, invalidConfigTriggerEventCount, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: regex, source, and data_type cannot be used when type is trigger_event_count"), + }, + // cache variable with an invalid configuration - external_data: + { + Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, invalidConfigExternalData, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: data_type and ttl_seconds cannot be null when type is external_data"), + }, + // configure a valid cache variable: { Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, config1, cond1), Check: resource.ComposeTestCheckFunc( @@ -80,6 +126,16 @@ func TestAccPagerDutyEventOrchestrationGlobalCacheVariable_Basic(t *testing.T) { resource.TestCheckResourceAttr(cv, "configuration.0.regex", ".*"), ), }, + // update config again: + { + Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, config3, cond1), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableID(cv, orchn1), + resource.TestCheckResourceAttr(cv, "configuration.0.type", "external_data"), + resource.TestCheckResourceAttr(cv, "configuration.0.data_type", "boolean"), + resource.TestCheckResourceAttr(cv, "configuration.0.ttl_seconds", "1200"), + ), + }, // update condition: { Config: testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableConfig(orch, name1, orchn1, disabled1, config1, cond2), diff --git a/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable.go b/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable.go index 8be92d645..424f6b15f 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable.go +++ b/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable.go @@ -16,7 +16,7 @@ func resourcePagerDutyEventOrchestrationServiceCacheVariable() *schema.Resource Importer: &schema.ResourceImporter{ StateContext: resourcePagerDutyEventOrchestrationServiceCacheVariableImport, }, - CustomizeDiff: checkConfiguration, + CustomizeDiff: checkEventOrchestrationCacheVariableConfiguration, Schema: map[string]*schema.Schema{ "service": { Type: schema.TypeString, diff --git a/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable_test.go b/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable_test.go index 07fdee1f4..59ee6b4d4 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_service_cache_variable_test.go @@ -3,6 +3,7 @@ package pagerduty import ( "context" "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" @@ -26,20 +27,46 @@ func TestAccPagerDutyEventOrchestrationServiceCacheVariable_Basic(t *testing.T) svcn1 := "svc_1" name2 := fmt.Sprintf("tf_service_cache_variable_updated_%s", acctest.RandString(5)) svcn2 := "svc_2" - + invalidConfigRecentValue := ` + configuration { + type = "recent_value" + regex = ".*" + ttl_seconds = 300 + } + ` + invalidConfigTriggerEventCount := ` + configuration { + type = "trigger_event_count" + data_type = "string" + ttl_seconds = 60 + } + ` + invalidConfigExternalData := ` + configuration { + type = "external_data" + data_type = "boolean" + } + ` config1 := ` configuration { - type = "trigger_event_count" - ttl_seconds = 60 - } - ` + type = "trigger_event_count" + ttl_seconds = 60 + } + ` config2 := ` configuration { - type = "recent_value" - source = "event.summary" - regex = ".*" - } - ` + type = "recent_value" + source = "event.summary" + regex = ".*" + } + ` + config3 := ` + configuration { + type = "external_data" + data_type = "boolean" + ttl_seconds = 1200 + } + ` cond1 := `` cond2 := ` condition { @@ -54,6 +81,25 @@ func TestAccPagerDutyEventOrchestrationServiceCacheVariable_Basic(t *testing.T) Providers: testAccProviders, CheckDestroy: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableDestroy, Steps: []resource.TestStep{ + // cache variable with an invalid configuration - recent_value: + { + Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, invalidConfigRecentValue, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: regex and source cannot be null, and data_type and ttl_seconds cannot be used when type is recent_value"), + }, + // cache variable with an invalid configuration - trigger_event_count: + { + Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, invalidConfigTriggerEventCount, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: regex, source, and data_type cannot be used when type is trigger_event_count"), + }, + // cache variable with an invalid configuration - external_data: + { + Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, invalidConfigExternalData, cond1), + PlanOnly: true, + ExpectError: regexp.MustCompile("Invalid configuration: data_type and ttl_seconds cannot be null when type is external_data"), + }, + // configure a valid cache variable: { Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, config1, cond1), Check: resource.ComposeTestCheckFunc( @@ -80,6 +126,16 @@ func TestAccPagerDutyEventOrchestrationServiceCacheVariable_Basic(t *testing.T) resource.TestCheckResourceAttr(cv, "configuration.0.regex", ".*"), ), }, + // update config again: + { + Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, config3, cond1), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyEventOrchestrationServiceCacheVariableID(cv, svcn1), + resource.TestCheckResourceAttr(cv, "configuration.0.type", "external_data"), + resource.TestCheckResourceAttr(cv, "configuration.0.data_type", "boolean"), + resource.TestCheckResourceAttr(cv, "configuration.0.ttl_seconds", "1200"), + ), + }, // update condition: { Config: testAccCheckPagerDutyEventOrchestrationServiceCacheVariableConfig(svc, name1, svcn1, disabled1, config1, cond2), From 686bd2c0f8065b44543785bf83914154bea29914 Mon Sep 17 00:00:00 2001 From: Alena Pantuzenko Date: Wed, 19 Feb 2025 17:04:09 -0500 Subject: [PATCH 3/3] update cache var docs --- ...ration_global_cache_variable.html.markdown | 7 +++-- ...ation_service_cache_variable.html.markdown | 7 +++-- ...ration_global_cache_variable.html.markdown | 30 ++++++++++++++++--- ...ation_service_cache_variable.html.markdown | 28 +++++++++++++++-- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/website/docs/d/event_orchestration_global_cache_variable.html.markdown b/website/docs/d/event_orchestration_global_cache_variable.html.markdown index 1a2e7ab64..8664877d4 100644 --- a/website/docs/d/event_orchestration_global_cache_variable.html.markdown +++ b/website/docs/d/event_orchestration_global_cache_variable.html.markdown @@ -36,13 +36,14 @@ The following arguments are supported: ## Attributes Reference * `disabled` - Indicates whether the Cache Variable is disabled and would therefore not be evaluated. -* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. +* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. This attribute can only be used when `configuration.0.type` is `recent_value` or `trigger_event_count`. * `expression`- A [PCL condition][2] string. * `configuration` - A configuration object to define what and how values will be stored in the Cache Variable. - * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value` or `trigger_event_count`. + * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value`, `trigger_event_count` or `external_data`. * `source` - The path to the event field where the `regex` will be applied to extract a value. You can use any valid [PCL path][3]. This field is only used when `type` is `recent_value` * `regex` - A [RE2 regular expression][4] that will be matched against the field specified via the `source` argument. This field is only used when `type` is `recent_value` - * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` + * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` or `external_data` + * `data_type` - The type of data that will eventually be set for the Cache Variable via an API request. This field is only used when type is `external_data` [1]: https://support.pagerduty.com/docs/event-orchestration-variables diff --git a/website/docs/d/event_orchestration_service_cache_variable.html.markdown b/website/docs/d/event_orchestration_service_cache_variable.html.markdown index e711bdab6..c49b95395 100644 --- a/website/docs/d/event_orchestration_service_cache_variable.html.markdown +++ b/website/docs/d/event_orchestration_service_cache_variable.html.markdown @@ -63,13 +63,14 @@ The following arguments are supported: ## Attributes Reference * `disabled` - Indicates whether the Cache Variable is disabled and would therefore not be evaluated. -* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. +* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. This attribute can only be used when `configuration.0.type` is `recent_value` or `trigger_event_count`. * `expression`- A [PCL condition][2] string. * `configuration` - A configuration object to define what and how values will be stored in the Cache Variable. - * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value` or `trigger_event_count`. + * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value`, `trigger_event_count` or `external_data`. * `source` - The path to the event field where the `regex` will be applied to extract a value. You can use any valid [PCL path][3]. This field is only used when `type` is `recent_value` * `regex` - A [RE2 regular expression][4] that will be matched against the field specified via the `source` argument. This field is only used when `type` is `recent_value` - * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` + * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` or `external_data` + * `data_type` - The type of data that will eventually be set for the Cache Variable via an API request. This field is only used when type is `external_data` [1]: https://support.pagerduty.com/docs/event-orchestration-variables diff --git a/website/docs/r/event_orchestration_global_cache_variable.html.markdown b/website/docs/r/event_orchestration_global_cache_variable.html.markdown index 892d9ac9f..2e5a1b1a9 100644 --- a/website/docs/r/event_orchestration_global_cache_variable.html.markdown +++ b/website/docs/r/event_orchestration_global_cache_variable.html.markdown @@ -24,7 +24,7 @@ resource "pagerduty_event_orchestration" "event_orchestration" { team = pagerduty_team.database_team.id } -resource "pagerduty_event_orchestration_global_cache_variable" "cache_var" { +resource "pagerduty_event_orchestration_global_cache_variable" "recent_host" { event_orchestration = pagerduty_event_orchestration.event_orchestration.id name = "recent_host" @@ -39,10 +39,31 @@ resource "pagerduty_event_orchestration_global_cache_variable" "cache_var" { } } +resource "pagerduty_event_orchestration_service_cache_variable" "host_ignore_list" { + event_orchestration = pagerduty_event_orchestration.event_orchestration.id + name = "host_ignore_list" + + configuration { + type = "external_data" + data_type = "string" + ttl_seconds = 3000 + } +} + resource "pagerduty_event_orchestration_global" "global" { event_orchestration = pagerduty_event_orchestration.event_orchestration.id set { id = "start" + rule { + label = "Drop events originating from hosts on the ignore list" + condition { + expression = "cache_var.host_ignore_list matches part event.custom_details.host" + } + actions { + drop = true + } + } + rule { label = "Always annotate the incident with the event source for all events" actions { @@ -64,13 +85,14 @@ The following arguments are supported: * `event_orchestration` - (Required) ID of the Global Event Orchestration to which this Cache Variable belongs. * `name` - (Required) Name of the Cache Variable associated with the Global Event Orchestration. * `disabled` - (Optional) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. -* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. +* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. This attribute can only be used when `configuration.0.type` is `recent_value` or `trigger_event_count`. * `expression`- A [PCL condition][2] string. * `configuration` - A configuration object to define what and how values will be stored in the Cache Variable. - * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value` or `trigger_event_count`. + * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value`, `trigger_event_count` or `external_data`. * `source` - The path to the event field where the `regex` will be applied to extract a value. You can use any valid [PCL path][3]. This field is only used when `type` is `recent_value` * `regex` - A [RE2 regular expression][4] that will be matched against the field specified via the `source` argument. This field is only used when `type` is `recent_value` - * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` + * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` or `external_data` + * `data_type` - The type of data that will eventually be set for the Cache Variable via an API request. This field is only used when type is `external_data` ## Attributes Reference diff --git a/website/docs/r/event_orchestration_service_cache_variable.html.markdown b/website/docs/r/event_orchestration_service_cache_variable.html.markdown index 7562725eb..90474b0cb 100644 --- a/website/docs/r/event_orchestration_service_cache_variable.html.markdown +++ b/website/docs/r/event_orchestration_service_cache_variable.html.markdown @@ -60,12 +60,33 @@ resource "pagerduty_event_orchestration_service_cache_variable" "num_db_triggers } } +resource "pagerduty_event_orchestration_service_cache_variable" "is_maintenance" { + service = pagerduty_service.svc.id + name = "is_maintenance" + + configuration { + type = "external_data" + data_type = "boolean" + ttl_seconds = 7200 + } +} + resource "pagerduty_event_orchestration_service" "event_orchestration" { service = pagerduty_service.svc.id enable_event_orchestration_for_service = true set { id = "start" + rule { + label = "Suppress alerts if the service is in maintenance" + condition { + expression = "cache_var.is_maintenance == true" + } + actions { + suppress = true + } + } + rule { label = "Set severity to critical if we see at least 5 triggers on the DB within the last 1 minute" condition { @@ -90,13 +111,14 @@ The following arguments are supported: * `service` - (Required) ID of the Service Event Orchestration to which this Cache Variable belongs. * `name` - (Required) Name of the Cache Variable associated with the Service Event Orchestration. * `disabled` - (Optional) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. -* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. +* `condition` - Conditions to be evaluated in order to determine whether or not to update the Cache Variable's stored value. This attribute can only be used when `configuration.0.type` is `recent_value` or `trigger_event_count`. * `expression`- A [PCL condition][2] string. * `configuration` - A configuration object to define what and how values will be stored in the Cache Variable. - * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value` or `trigger_event_count`. + * `type` - The [type of value][1] to store into the Cache Variable. Can be one of: `recent_value`, `trigger_event_count` or `external_data`. * `source` - The path to the event field where the `regex` will be applied to extract a value. You can use any valid [PCL path][3]. This field is only used when `type` is `recent_value` * `regex` - A [RE2 regular expression][4] that will be matched against the field specified via the `source` argument. This field is only used when `type` is `recent_value` - * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` + * `ttl_seconds` - The number of seconds indicating how long to count incoming trigger events for. This field is only used when `type` is `trigger_event_count` or `external_data` + * `data_type` - The type of data that will eventually be set for the Cache Variable via an API request. This field is only used when type is `external_data` ## Attributes Reference