Skip to content

Commit 64209e7

Browse files
committed
Add Iter() function to RulesResult
1 parent 428554a commit 64209e7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

notifications/source/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ type RulesInfo struct {
176176
Rules map[int64]RuleResp // Rules is a map of rule IDs to their corresponding RuleResp objects.
177177
}
178178

179+
// Iter returns an iterator over the rules in the RulesInfo.
180+
// It yields each RuleResp object until all rules have been processed or the yield function returns false.
181+
func (r *RulesInfo) Iter() iter.Seq[RuleResp] {
182+
return func(yield func(RuleResp) bool) {
183+
for _, rule := range r.Rules {
184+
if !yield(rule) {
185+
break
186+
}
187+
}
188+
}
189+
}
190+
179191
// RuleResp represents a response object for a rule in the Icinga Notifications API.
180192
type RuleResp struct {
181193
Id int64 // Id is the unique identifier of the rule.

0 commit comments

Comments
 (0)