|
18 | 18 | using System.Threading.Tasks; |
19 | 19 | using Seq.Api.Model; |
20 | 20 | using Seq.Api.Model.Alerting; |
| 21 | +using Seq.Api.Model.Signals; |
21 | 22 | using Seq.Api.Model.Users; |
22 | 23 |
|
23 | 24 | namespace Seq.Api.ResourceGroups |
@@ -55,17 +56,25 @@ public async Task<AlertEntity> FindAsync(string id, CancellationToken cancellati |
55 | 56 | public async Task<List<AlertEntity>> ListAsync(string ownerId = null, bool shared = false, CancellationToken cancellationToken = default) |
56 | 57 | { |
57 | 58 | var parameters = new Dictionary<string, object> { { "ownerId", ownerId }, { "shared", shared } }; |
58 | | - return await GroupListAsync<AlertEntity>("Items", parameters, cancellationToken: cancellationToken).ConfigureAwait(false); |
| 59 | + return await GroupListAsync<AlertEntity>("Items", parameters, cancellationToken).ConfigureAwait(false); |
59 | 60 | } |
60 | 61 |
|
61 | 62 | /// <summary> |
62 | 63 | /// Construct a alert with server defaults pre-initialized. |
63 | 64 | /// </summary> |
64 | 65 | /// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param> |
| 66 | + /// <param name="signal">The source of events that will contribute to the alert.</param> |
| 67 | + /// <param name="query">An SQL query that will supply default clauses to the new alert.</param> |
65 | 68 | /// <returns>The unsaved alert.</returns> |
66 | | - public async Task<AlertEntity> TemplateAsync(CancellationToken cancellationToken = default) |
| 69 | + public async Task<AlertEntity> TemplateAsync(SignalExpressionPart signal = null, string query = null, CancellationToken cancellationToken = default) |
67 | 70 | { |
68 | | - return await GroupGetAsync<AlertEntity>("Template", cancellationToken: cancellationToken).ConfigureAwait(false); |
| 71 | + var parameters = new Dictionary<string, object> |
| 72 | + { |
| 73 | + ["signal"] = signal?.ToString(), |
| 74 | + ["q"] = query |
| 75 | + }; |
| 76 | + |
| 77 | + return await GroupGetAsync<AlertEntity>("Template", parameters, cancellationToken).ConfigureAwait(false); |
69 | 78 | } |
70 | 79 |
|
71 | 80 | /// <summary> |
|
0 commit comments