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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,4 @@ paket-files/
*.sln.iml

.vscode/
*.orig
68 changes: 34 additions & 34 deletions src/Seq.Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,95 +60,95 @@ public SeqApiClient(string serverUrl, string apiKey = null, bool useDefaultCrede

public HttpClient HttpClient => _httpClient;

public Task<RootEntity> GetRootAsync(CancellationToken token = default)
public Task<RootEntity> GetRootAsync(CancellationToken cancellationToken = default)
{
return HttpGetAsync<RootEntity>("api", token);
return HttpGetAsync<RootEntity>("api", cancellationToken);
}

public Task<TEntity> GetAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken token = default)
public Task<TEntity> GetAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
return HttpGetAsync<TEntity>(linkUri, token);
return HttpGetAsync<TEntity>(linkUri, cancellationToken);
}

public Task<string> GetStringAsync(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken token = default)
public Task<string> GetStringAsync(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
return HttpGetStringAsync(linkUri, token);
return HttpGetStringAsync(linkUri, cancellationToken);
}

public Task<List<TEntity>> ListAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken token = default)
public Task<List<TEntity>> ListAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
return HttpGetAsync<List<TEntity>>(linkUri, token);
return HttpGetAsync<List<TEntity>>(linkUri, cancellationToken);
}

public async Task PostAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task PostAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
new StreamReader(stream).ReadToEnd();
}

public async Task<TResponse> PostAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<TResponse> PostAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
return _serializer.Deserialize<TResponse>(new JsonTextReader(new StreamReader(stream)));
}

public async Task<string> PostReadStringAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<string> PostReadStringAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
return await new StreamReader(stream).ReadToEndAsync();
}

public async Task<Stream> PostReadStreamAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<Stream> PostReadStreamAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
return await HttpSendAsync(request, token).ConfigureAwait(false);
return await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
}

public async Task PutAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task PutAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Put, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
new StreamReader(stream).ReadToEnd();
}

public async Task DeleteAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task DeleteAsync<TEntity>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Delete, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
new StreamReader(stream).ReadToEnd();
}

public async Task<TResponse> DeleteAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<TResponse> DeleteAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Delete, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
return _serializer.Deserialize<TResponse>(new JsonTextReader(new StreamReader(stream)));
}

public async Task<ObservableStream<TEntity>> StreamAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<ObservableStream<TEntity>> StreamAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize<TEntity>(new JsonTextReader(reader)), token);
return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize<TEntity>(new JsonTextReader(reader)), cancellationToken);
}

public async Task<ObservableStream<string>> StreamTextAsync(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken token = default)
public async Task<ObservableStream<string>> StreamTextAsync(ILinked entity, string link, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default)
{
return await WebSocketStreamAsync(entity, link, parameters, reader => reader.ReadToEnd(), token);
return await WebSocketStreamAsync(entity, link, parameters, reader => reader.ReadToEnd(), cancellationToken);
}

async Task<ObservableStream<T>> WebSocketStreamAsync<T>(ILinked entity, string link, IDictionary<string, object> parameters, Func<TextReader, T> deserialize, CancellationToken token = default)
async Task<ObservableStream<T>> WebSocketStreamAsync<T>(ILinked entity, string link, IDictionary<string, object> parameters, Func<TextReader, T> deserialize, CancellationToken cancellationToken = default)
{
var linkUri = ResolveLink(entity, link, parameters);

Expand All @@ -157,33 +157,33 @@ async Task<ObservableStream<T>> WebSocketStreamAsync<T>(ILinked entity, string l
if (_apiKey != null)
socket.Options.SetRequestHeader("X-Seq-ApiKey", _apiKey);

await socket.ConnectAsync(new Uri(linkUri), token);
await socket.ConnectAsync(new Uri(linkUri), cancellationToken);

return new ObservableStream<T>(socket, deserialize);
}

async Task<T> HttpGetAsync<T>(string url, CancellationToken token = default)
async Task<T> HttpGetAsync<T>(string url, CancellationToken cancellationToken = default)
{
var request = new HttpRequestMessage(HttpMethod.Get, url);
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
return _serializer.Deserialize<T>(new JsonTextReader(new StreamReader(stream)));
}

async Task<string> HttpGetStringAsync(string url, CancellationToken token = default)
async Task<string> HttpGetStringAsync(string url, CancellationToken cancellationToken = default)
{
var request = new HttpRequestMessage(HttpMethod.Get, url);
var stream = await HttpSendAsync(request, token).ConfigureAwait(false);
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
return await new StreamReader(stream).ReadToEndAsync();
}

async Task<Stream> HttpSendAsync(HttpRequestMessage request, CancellationToken token = default)
async Task<Stream> HttpSendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
{
if (_apiKey != null)
request.Headers.Add("X-Seq-ApiKey", _apiKey);

request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV6MediaType));

var response = await _httpClient.SendAsync(request, token).ConfigureAwait(false);
var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

if (response.IsSuccessStatusCode)
Expand Down
12 changes: 5 additions & 7 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 Newtonsoft.Json;
using Seq.Api.Model.Apps;
using Seq.Api.Model.Signals;

Expand All @@ -13,9 +14,7 @@ public AppInstanceEntity()
InvocationOverridableSettings = new List<string>();
InvocationOverridableSettingDefinitions = new List<AppSettingPart>();
EventsPerSuppressionWindow = 1;
#pragma warning disable 618
SignalIds = new List<string>();
#pragma warning restore 618
Metrics = new AppInstanceMetricsPart();
}

public string Title { get; set; }
Expand All @@ -29,11 +28,10 @@ public AppInstanceEntity()
public int ChannelCapacity { get; set; }
public TimeSpan SuppressionTime { get; set; }
public int EventsPerSuppressionWindow { get; set; }
public int? ProcessedEventsPerMinute { get; set; }

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

public List<AppSettingPart> InvocationOverridableSettingDefinitions { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public AppInstanceMetricsPart Metrics { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Seq.Api.Model.AppInstances
{
public class AppInstanceMetricsPart
{
public int ReceivedEventsPerMinute { get; set; }
public int EmittedEventsPerMinute { get; set; }
public long ProcessWorkingSetBytes { get; set; }
public bool IsRunning { get; set; }
}
}
1 change: 0 additions & 1 deletion src/Seq.Api/Model/Events/DeleteResultPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
{
public class DeleteResultPart
{
public long DeletedEventCount { get; set; }
}
}
7 changes: 4 additions & 3 deletions src/Seq.Api/Model/Inputs/ApiKeyEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Security;
using Seq.Api.Model.Signals;
Expand All @@ -14,11 +15,11 @@ public class ApiKeyEntity : Entity
public SignalFilterPart InputFilter { get; set; } = new SignalFilterPart();
public LogEventLevel? MinimumLevel { get; set; }
public bool UseServerTimestamps { get; set; }
public int InfluxPerMinute { get; set; }
public int ArrivalsPerMinute { get; set; }
public ApiKeyMetricsPart Metrics { get; set; } = new ApiKeyMetricsPart();
public bool IsDefault { get; set; }
public string OwnerId { get; set; }
public HashSet<Permission> AssignedPermissions { get; set; } = new HashSet<Permission>();

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public ApiKeyMetricsPart Metrics { get; set; } = new ApiKeyMetricsPart();
}
}
1 change: 1 addition & 0 deletions src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class ApiKeyMetricsPart
{
public int ArrivalsPerMinute { get; set; }
public int InfluxPerMinute { get; set; }
public long IngestedBytesPerMinute { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Seq.Api/Model/Monitoring/AlertPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class AlertPart

public string Id { get; set; }
public string Condition { get; set; }
public string Title { get; set; }
public TimeSpan MeasurementWindow { get; set; }
public TimeSpan StabilizationWindow { get; set; } = TimeSpan.FromSeconds(30);
public TimeSpan SuppressionTime { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/Seq.Api/Model/Monitoring/DashboardEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class DashboardEntity : Entity

public string Title { get; set; }

public bool IsProtected { get; set; }

public SignalExpressionPart SignalExpression { get; set; }

public List<ChartPart> Charts { get; set; } = new List<ChartPart>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class MeasurementDisplayStylePart
public bool LineFillToZeroY { get; set; }
public bool LineShowMarkers { get; set; } = true;
public bool BarOverlaySum { get; set; }
public bool SuppressLegend { get; set; }
public MeasurementDisplayPalette Palette { get; set; } = MeasurementDisplayPalette.Default;
}
}
5 changes: 4 additions & 1 deletion src/Seq.Api/Model/Settings/SettingName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public enum SettingName
LazilyFlushEventWrites,
MasterKeyIsBackedUp,
MinimumFreeStorageSpace,
NewUserShowSignalIds,
NewUserShowQueryIds,
NewUserShowDashboardIds,
RequireApiKeyForWritingEvents,
RawEventMaximumContentLength,
RawPayloadMaximumContentLength,
ThemeStyles
}
}
}
4 changes: 2 additions & 2 deletions src/Seq.Api/Model/Signals/SignalEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public SignalEntity()

public List<TaggedPropertyPart> TaggedProperties { get; set; }

public bool IsWatched { get; set; }

// ReSharper disable once UnusedMember.Global
[Obsolete("This member has been renamed `IsProtected` to better reflect its purpose.")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
Expand All @@ -33,5 +31,7 @@ public SignalEntity()
public SignalGrouping Grouping { get; set; }

public string ExplicitGroupName { get; set; }

public string OwnerId { get; set; }
}
}
7 changes: 5 additions & 2 deletions src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public SqlQueryEntity()

public string Sql { get; set; }

public bool Show { get; set; }
public bool IsProtected { get; set; }

public string OwnerId { get; set; }

}
}
}
11 changes: 11 additions & 0 deletions src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace Seq.Api.Model.Workspaces
{
public class WorkspaceContentPart
{
public List<string> SignalIds { get; set; } = new List<string>();
public List<string> QueryIds { get; set; } = new List<string>();
public List<string> DashboardIds { get; set; } = new List<string>();
}
}
12 changes: 12 additions & 0 deletions src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Seq.Api.Model.Workspaces
{
public class WorkspaceEntity : Entity
{
public string Title { get; set; }
public string Description { get; set; }
public string OwnerId { get; set; }
public bool IsProtected { get; set; }

public WorkspaceContentPart Content { get; set; } = new WorkspaceContentPart();
}
}
Loading