@@ -42,6 +42,12 @@ public interface IAction
4242 [ IgnoreDataMember ]
4343 string Foreach { get ; set ; }
4444
45+ [ IgnoreDataMember ]
46+ /// <summary>The maximum number of iterations that each watch executes. If this limit is reached,
47+ /// the execution is gracefully stopped. Defaults to <c>100</c>.
48+ /// </summary>
49+ int ? MaxIterations { get ; set ; }
50+
4551 /// <summary>
4652 /// Transforms the payload before executing the action. The transformation is only applied
4753 /// for the payload for this action.
@@ -75,6 +81,9 @@ internal ActionBase() { }
7581 /// <inheritdoc />
7682 public string Foreach { get ; set ; }
7783
84+ /// <inheritdoc />
85+ public int ? MaxIterations { get ; set ; }
86+
7887 /// <inheritdoc />
7988 public TransformContainer Transform { get ; set ; }
8089
@@ -125,7 +134,8 @@ internal class ActionsFormatter : IJsonFormatter<Actions>
125134 { "pagerduty" , 6 } ,
126135 { "foreach" , 7 } ,
127136 { "transform" , 8 } ,
128- { "condition" , 9 }
137+ { "condition" , 9 } ,
138+ { "max_iterations" , 10 } ,
129139 } ;
130140
131141 public Actions Deserialize ( ref JsonReader reader , IJsonFormatterResolver formatterResolver )
@@ -140,6 +150,7 @@ public Actions Deserialize(ref JsonReader reader, IJsonFormatterResolver formatt
140150 Time throttlePeriod = null ;
141151 IAction action = null ;
142152 string @foreach = null ;
153+ int ? maxIterations = null ;
143154 TransformContainer transform = null ;
144155 ConditionContainer condition = null ;
145156
@@ -190,6 +201,9 @@ public Actions Deserialize(ref JsonReader reader, IJsonFormatterResolver formatt
190201 condition = formatterResolver . GetFormatter < ConditionContainer > ( )
191202 . Deserialize ( ref reader , formatterResolver ) ;
192203 break ;
204+ case 10 :
205+ maxIterations = reader . ReadInt32 ( ) ;
206+ break ;
193207 }
194208 }
195209 else
@@ -201,6 +215,7 @@ public Actions Deserialize(ref JsonReader reader, IJsonFormatterResolver formatt
201215 action . Name = name ;
202216 action . ThrottlePeriod = throttlePeriod ;
203217 action . Foreach = @foreach ;
218+ action . MaxIterations = maxIterations ;
204219 action . Transform = transform ;
205220 action . Condition = condition ;
206221 dictionary . Add ( name , action ) ;
@@ -238,6 +253,12 @@ public void Serialize(ref JsonWriter writer, Actions value, IJsonFormatterResolv
238253 writer . WriteString ( action . Foreach ) ;
239254 writer . WriteValueSeparator ( ) ;
240255 }
256+ if ( action . MaxIterations . HasValue )
257+ {
258+ writer . WritePropertyName ( "max_iterations" ) ;
259+ writer . WriteInt32 ( action . MaxIterations . Value ) ;
260+ writer . WriteValueSeparator ( ) ;
261+ }
241262
242263 if ( action . Transform != null )
243264 {
0 commit comments