Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Seq.Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,20 @@ static string ResolveLink(ILinked entity, string link, IDictionary<string, objec
{
Link linkItem;
if (!entity.Links.TryGetValue(link, out linkItem))
throw new NotSupportedException("The requested link isn't available.");
throw new NotSupportedException($"The requested link `{link}` isn't available on entity `{entity}`.");

var expression = linkItem.GetUri();
var template = new UriTemplate(expression);
if (parameters != null)
{
var missing = parameters.Select(p => p.Key).Except(template.GetParameterNames()).ToArray();
if (missing.Any())
throw new ArgumentException("The URI template '" + expression + "' does not contain parameter: " + string.Join(",", missing));
throw new ArgumentException($"The URI template `{expression}` does not contain parameter: `{string.Join("`, `", missing)}`.");

foreach (var parameter in parameters)
{
var value = parameter.Value is DateTime
? ((DateTime) parameter.Value).ToString("O")
var value = parameter.Value is DateTime time
? time.ToString("O")
: parameter.Value;

template.SetParameter(parameter.Key, value);
Expand Down
6 changes: 6 additions & 0 deletions src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Seq.Api.Model.Apps;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.AppInstances
Expand All @@ -9,6 +10,8 @@ public class AppInstanceEntity : Entity
public AppInstanceEntity()
{
Settings = new Dictionary<string, string>();
InvocationOverridableSettings = new List<string>();
InvocationOverridableSettingDefinitions = new List<AppSettingPart>();
EventsPerSuppressionWindow = 1;
#pragma warning disable 618
SignalIds = new List<string>();
Expand All @@ -19,6 +22,7 @@ public AppInstanceEntity()
public bool IsManualInputOnly { get; set; }
public string AppId { get; set; }
public Dictionary<string, string> Settings { get; set; }
public List<string> InvocationOverridableSettings { get; set; }
public TimeSpan? ArrivalWindow { get; set; }
public SignalExpressionPart InputSignalExpression { get; set; }
public bool DisallowManualInput { get; set; }
Expand All @@ -29,5 +33,7 @@ public AppInstanceEntity()

[Obsolete("Replaced by InputSignalExpression.")]
public List<string> SignalIds { get; set; }

public List<AppSettingPart> InvocationOverridableSettingDefinitions { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/Seq.Api/Model/Monitoring/AlertPart.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
using Seq.Api.Model.LogEvents;
using System;
using System.Collections.Generic;

namespace Seq.Api.Model.Monitoring
{
public class AlertPart
{
Dictionary<string, string> _notificationAppSettingOverrides = new Dictionary<string, string>();

public string Id { get; set; }
public string Condition { get; set; }
public TimeSpan MeasurementWindow { get; set; }
public TimeSpan StabilizationWindow { get; set; } = TimeSpan.FromSeconds(30);
public TimeSpan SuppressionTime { get; set; }
public LogEventLevel Level { get; set; } = LogEventLevel.Warning;
public string NotificationAppInstanceId { get; set; }

public Dictionary<string, string> NotificationAppSettingOverrides
{
get => _notificationAppSettingOverrides;
set => _notificationAppSettingOverrides = value ?? new Dictionary<string, string>();
}
}
}
3 changes: 2 additions & 1 deletion src/Seq.Api/Model/Monitoring/MeasurementDisplayType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum MeasurementDisplayType
Line,
Bar,
Point,
Value
Value,
Pie
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Seq.Api.Model.Settings
{
public class InternalErrorReportingSettingsPart
{
public bool InternalErrorReportingEnabled { get; set; }
public string ReplyEmail { get; set; }
}
}
14 changes: 13 additions & 1 deletion src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ public async Task<AppInstanceEntity> TemplateAsync(string appId)

public async Task<AppInstanceEntity> AddAsync(AppInstanceEntity entity, bool runOnExisting = false)
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
return await Client.PostAsync<AppInstanceEntity, AppInstanceEntity>(entity, "Create", entity, new Dictionary<string, object> { { "runOnExisting", runOnExisting } }).ConfigureAwait(false);
}

public async Task RemoveAsync(AppInstanceEntity entity)
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
await Client.DeleteAsync(entity, "Self", entity).ConfigureAwait(false);
}

public async Task UpdateAsync(AppInstanceEntity entity)
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
await Client.PutAsync(entity, "Self", entity).ConfigureAwait(false);
}

public async Task InvokeAsync(AppInstanceEntity entity, string eventId, IReadOnlyDictionary<string, string> settingOverrides)
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
if (eventId == null) throw new ArgumentNullException(nameof(eventId));

var postedSettings = settingOverrides ?? new Dictionary<string, string>();
await Client.PostAsync(entity, "Invoke", postedSettings, new Dictionary<string, object>{{"eventId", eventId}});
}
}
}
}
17 changes: 13 additions & 4 deletions src/Seq.Api/ResourceGroups/DataResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ internal DataResourceGroup(ISeqConnection connection)
/// <param name="signal">A signal expression over which the query will be executed.</param>
/// <param name="unsavedSignal">A constructed signal that may not appear on the server, for example, a <see cref="SignalEntity"/> that has been
/// created but not saved, a signal from another server, or the modified representation of an entity already persisted.</param>
/// <param name="timeout">The query timeout; if not specified, the query will run until completion.</param>
/// <returns>A structured result set.</returns>
public async Task<QueryResultPart> QueryAsync(
string query,
DateTime rangeStartUtc,
DateTime? rangeEndUtc = null,
SignalExpressionPart signal = null,
SignalEntity unsavedSignal = null)
SignalEntity unsavedSignal = null,
TimeSpan? timeout = null)
{
MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, out var body, out var parameters);
MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, timeout, out var body, out var parameters);
return await GroupPostAsync<SignalEntity, QueryResultPart>("Query", body, parameters).ConfigureAwait(false);
}

Expand All @@ -43,15 +45,17 @@ public async Task<QueryResultPart> QueryAsync(
/// <param name="signal">A signal expression over which the query will be executed.</param>
/// <param name="unsavedSignal">A constructed signal that may not appear on the server, for example, a <see cref="SignalEntity"/> that has been
/// created but not saved, a signal from another server, or the modified representation of an entity already persisted.</param>
/// <param name="timeout">The query timeout; if not specified, the query will run until completion.</param>
/// <returns>A CSV result set.</returns>
public async Task<string> QueryCsvAsync(
string query,
DateTime rangeStartUtc,
DateTime? rangeEndUtc = null,
SignalExpressionPart signal = null,
SignalEntity unsavedSignal = null)
SignalEntity unsavedSignal = null,
TimeSpan? timeout = null)
{
MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, out var body, out var parameters);
MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, timeout, out var body, out var parameters);
parameters.Add("format", "text/csv");
return await GroupPostReadStringAsync("Query", body, parameters).ConfigureAwait(false);
}
Expand All @@ -62,6 +66,7 @@ static void MakeParameters(
DateTime? rangeEndUtc,
SignalExpressionPart signal,
SignalEntity unsavedSignal,
TimeSpan? timeout,
out SignalEntity body,
out Dictionary<string, object> parameters)
{
Expand All @@ -79,6 +84,10 @@ static void MakeParameters(
{
parameters.Add(nameof(signal), signal.ToString());
}
if (timeout != null)
{
parameters.Add("timeoutMS", timeout.Value.TotalMilliseconds.ToString("0"));
}

body = unsavedSignal ?? new SignalEntity();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Seq.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>
</Project>