File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 66 "encoding/json"
77 "fmt"
88 "io"
9+ "iter"
910 "net/http"
1011 "net/url"
1112 "strconv"
@@ -205,6 +206,18 @@ type RulesResult struct {
205206 Rules map [int64 ]RuleResp // Rules is a map of rule IDs to their corresponding RuleResp objects.
206207}
207208
209+ // Iter returns an iterator over the rules in the RulesResp.
210+ // It yields each RuleResp object until all rules have been processed or the yield function returns false.
211+ func (r * RulesResult ) Iter () iter.Seq [RuleResp ] {
212+ return func (yield func (RuleResp ) bool ) {
213+ for _ , rule := range r .Rules {
214+ if ! yield (rule ) {
215+ break
216+ }
217+ }
218+ }
219+ }
220+
208221// RuleResp describes a rule response object from Icinga Notifications /event-rules API.
209222// It contains the rule ID, name, and the object filter expression associated with the rule.
210223type RuleResp struct {
You can’t perform that action at this time.
0 commit comments