12
12
13
13
namespace aggregator . cli
14
14
{
15
+ internal enum RemoveOutcome
16
+ {
17
+ Succeeded = 0 ,
18
+ NotFound = 2 ,
19
+ Failed = 1
20
+ }
21
+
15
22
internal class AggregatorMappings
16
23
{
17
24
private readonly VssConnection devops ;
@@ -157,17 +164,17 @@ internal async Task<Guid> AddAsync(string projectName, string @event, EventFilte
157
164
return newSubscription . Id ;
158
165
}
159
166
160
- internal async Task < bool > RemoveInstanceAsync ( InstanceName instance )
167
+ internal async Task < RemoveOutcome > RemoveInstanceAsync ( InstanceName instance )
161
168
{
162
169
return await RemoveRuleEventAsync ( "*" , instance , "*" , "*" ) ;
163
170
}
164
171
165
- internal async Task < bool > RemoveRuleAsync ( InstanceName instance , string rule )
172
+ internal async Task < RemoveOutcome > RemoveRuleAsync ( InstanceName instance , string rule )
166
173
{
167
174
return await RemoveRuleEventAsync ( "*" , instance , "*" , rule ) ;
168
175
}
169
176
170
- internal async Task < bool > RemoveRuleEventAsync ( string @event , InstanceName instance , string projectName , string rule )
177
+ internal async Task < RemoveOutcome > RemoveRuleEventAsync ( string @event , InstanceName instance , string projectName , string rule )
171
178
{
172
179
logger . WriteInfo ( $ "Querying the Azure DevOps subscriptions for rule(s) { instance . PlainName } /{ rule } ") ;
173
180
var serviceHooksClient = devops . GetClient < ServiceHooksPublisherHttpClient > ( ) ;
@@ -200,14 +207,16 @@ internal async Task<bool> RemoveRuleEventAsync(string @event, InstanceName insta
200
207
. StartsWith ( invocationUrl , StringComparison . OrdinalIgnoreCase ) ) ;
201
208
}
202
209
210
+ uint count = 0 ;
203
211
foreach ( var ruleSub in ruleSubs )
204
212
{
205
213
logger . WriteVerbose ( $ "Deleting subscription { ruleSub . EventDescription } { ruleSub . EventType } ...") ;
206
214
await serviceHooksClient . DeleteSubscriptionAsync ( ruleSub . Id ) ;
207
215
logger . WriteInfo ( $ "Subscription { ruleSub . EventDescription } { ruleSub . EventType } deleted.") ;
216
+ count ++ ;
208
217
}
209
218
210
- return true ;
219
+ return count > 0 ? RemoveOutcome . Succeeded : RemoveOutcome . NotFound ;
211
220
}
212
221
}
213
222
@@ -261,4 +270,4 @@ public static IEnumerable<InputFilterCondition> ToFilterConditions(this EventFil
261
270
} ) ;
262
271
}
263
272
}
264
- }
273
+ }
0 commit comments