Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions automations_fire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,30 @@ func TestAutomationRuleUpdateRequestCanSendFalseValues(t *testing.T) {
t.Fatalf("zero rotate flag should stay omitted: %s", got)
}
}

func TestAutomationRuleUpdateRequestPreservesOncallIncidentTriggerFields(t *testing.T) {
var req AutomationRuleUpdateRequest
if err := json.Unmarshal([]byte(`{
"rule_id":"auto_1",
"oncall_incident_trigger_enabled":false,
"oncall_incident_channel_ids":[],
"oncall_incident_severities":[]
}`), &req); err != nil {
t.Fatal(err)
}
payload, err := json.Marshal(&req)
if err != nil {
t.Fatal(err)
}
got := string(payload)
for _, want := range []string{
`"rule_id":"auto_1"`,
`"oncall_incident_trigger_enabled":false`,
`"oncall_incident_channel_ids":[]`,
`"oncall_incident_severities":[]`,
} {
if !strings.Contains(got, want) {
t.Fatalf("payload %s missing %s", got, want)
}
}
}
6 changes: 6 additions & 0 deletions automations_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ type AutomationRuleUpdateRequest struct {
HTTPPostTriggerEnabled *bool `json:"http_post_trigger_enabled,omitempty" toon:"http_post_trigger_enabled,omitempty"`
// Whether to rotate the HTTP POST trigger token. The new token is returned only in this response.
RotateHTTPPostTriggerToken bool `json:"rotate_http_post_trigger_token,omitempty" toon:"rotate_http_post_trigger_token,omitempty"`
// Whether the on-call incident trigger is enabled. Sending true creates it when missing and channel/severity filters are provided.
OncallIncidentTriggerEnabled *bool `json:"oncall_incident_trigger_enabled,omitempty" toon:"oncall_incident_trigger_enabled,omitempty"`
// On-call channel IDs whose new incidents can trigger this rule.
OncallIncidentChannelIDs *[]int64 `json:"oncall_incident_channel_ids,omitempty" toon:"oncall_incident_channel_ids,omitempty"`
// Incident severities that can trigger this rule.
OncallIncidentSeverities *[]string `json:"oncall_incident_severities,omitempty" toon:"oncall_incident_severities,omitempty"`
}