Skip to content

Commit 641e970

Browse files
committed
Add Iter() function to RulesResult
1 parent ec64634 commit 641e970

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

notifications/client.go

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

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

0 commit comments

Comments
 (0)