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"
@@ -209,6 +210,18 @@ type RulesResult struct {
209210 Rules map [int64 ]RuleResp // Rules is a map of rule IDs to their corresponding RuleResp objects.
210211}
211212
213+ // Iter returns an iterator over the rules in the RulesResp.
214+ // It yields each RuleResp object until all rules have been processed or the yield function returns false.
215+ func (r * RulesResult ) Iter () iter.Seq [RuleResp ] {
216+ return func (yield func (RuleResp ) bool ) {
217+ for _ , rule := range r .Rules {
218+ if ! yield (rule ) {
219+ break
220+ }
221+ }
222+ }
223+ }
224+
212225// RuleResp describes a rule response object from Icinga Notifications /event-rules API.
213226// It contains the rule ID, name, and the object filter expression associated with the rule.
214227type RuleResp struct {
You can’t perform that action at this time.
0 commit comments