Skip to content

Commit

Permalink
feat(alert-muting-rule): add actionOnMutingRuleWindowEnded to types.g…
Browse files Browse the repository at this point in the history
…o and update muting rule test
  • Loading branch information
Aashirwadjain committed Dec 16, 2024
1 parent 3d20a45 commit 117b6bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/alerts/muting_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var (
"timeZone": "America/Los_Angeles",
"weeklyRepeatDays": null
},
"actionOnMutingRuleWindowEnded": "CLOSE_ISSUES_ON_INACTIVE",
"status": "INACTIVE",
"updatedAt": "2021-01-12T00:50:39.533Z",
"updatedByUser": {
Expand Down Expand Up @@ -117,7 +118,8 @@ var (
"gravatar": "https://secure.gravatar.com/avatar/692dc9742bd717014494f5093faff304",
"id": 1,
"name": "Test User"
}
},
"actionOnMutingRuleWindowEnded": "CLOSE_ISSUES_ON_INACTIVE",
}
}
}
Expand Down Expand Up @@ -168,7 +170,8 @@ var (
"gravatar": "https://secure.gravatar.com/avatar/692dc9742bd717014494f5093faff304",
"id": 1,
"name": "Test User"
}
},
"actionOnMutingRuleWindowEnded": "CLOSE_ISSUES_ON_INACTIVE",
}
}`

Expand All @@ -182,7 +185,8 @@ var (
"repeat": null,
"repeatCount": null,
"weeklyRepeatDays": null
}
},
"actionOnMutingRuleWindowEnded": "DO_NOTHING",
}
}`

Expand Down Expand Up @@ -248,6 +252,7 @@ func TestListMutingRules(t *testing.T) {
ID: 1,
Name: "Test User",
},
ActionOnMutingRuleWindowEnded: "CLOSE_ISSUES_ON_INACTIVE",
},
}

Expand Down Expand Up @@ -313,6 +318,7 @@ func TestGetMutingRule(t *testing.T) {
ID: 1,
Name: "Test User",
},
ActionOnMutingRuleWindowEnded: "CLOSE_ISSUES_ON_INACTIVE",
}

actual, err := alerts.GetMutingRule(accountID, ruleID)
Expand Down Expand Up @@ -376,6 +382,7 @@ func TestCreateMutingRule(t *testing.T) {
ID: 1,
Name: "Test User",
},
ActionOnMutingRuleWindowEnded: "CLOSE_ISSUES_ON_INACTIVE",
}

actual, err := alerts.CreateMutingRule(accountID, MutingRuleCreateInput{})
Expand Down Expand Up @@ -407,6 +414,7 @@ func TestUpdateMutingRule(t *testing.T) {
EndRepeat: &endRepeat,
StartTime: &startTime,
},
ActionOnMutingRuleWindowEnded: "DO_NOTHING",
}

actual, err := alerts.UpdateMutingRule(accountID, ruleID, MutingRuleUpdateInput{})
Expand Down
17 changes: 17 additions & 0 deletions pkg/alerts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ package alerts

import "github.com/newrelic/newrelic-client-go/v2/pkg/nrtime"

// AlertsActionOnMutingRuleWindowEnded - Configuration on the action when the muting rule window is ended or disabled
type AlertsActionOnMutingRuleWindowEnded string

var AlertsActionOnMutingRuleWindowEndedTypes = struct {
// Muting Rule closes issues when the muting rule window is ended or disabled to notify users.
CLOSE_ISSUES_ON_INACTIVE AlertsActionOnMutingRuleWindowEnded
// The currently opened issues will not be notified even if the muting rule window is ended or disabled.
DO_NOTHING AlertsActionOnMutingRuleWindowEnded
}{
// Muting Rule closes issues when the muting rule window is ended or disabled to notify users.
CLOSE_ISSUES_ON_INACTIVE: "CLOSE_ISSUES_ON_INACTIVE",
// The currently opened issues will not be notified even if the muting rule window is ended or disabled.
DO_NOTHING: "DO_NOTHING",
}

// AlertsDayOfWeek - The day of the week used to configure a WEEKLY scheduled MutingRule
type AlertsDayOfWeek string

Expand Down Expand Up @@ -221,6 +236,8 @@ type AlertsMutingRuleConditionInput struct {

// AlertsMutingRuleInput - Input for creating MutingRules for New Relic Alerts Violations.
type AlertsMutingRuleInput struct {
// The action when the muting rule window is ended or disabled.
ActionOnMutingRuleWindowEnded AlertsActionOnMutingRuleWindowEnded `json:"actionOnMutingRuleWindowEnded,omitempty"`
// The condition that defines which violations to target.
Condition AlertsMutingRuleConditionGroupInput `json:"condition,omitempty"`
// The description of the MutingRule.
Expand Down

0 comments on commit 117b6bf

Please sign in to comment.