Skip to content

Commit 5be59cc

Browse files
authored
Merge pull request #141 from nblumhardt/2025.1-api
Update to the Seq 2025.1 API
2 parents 4c650b2 + 8f1d74f commit 5be59cc

30 files changed

+401
-202
lines changed

src/Seq.Api/Client/SeqApiClient.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using System.Threading;
3030
using Seq.Api.Streams;
3131
using System.Net.WebSockets;
32+
using Seq.Api.Model.Shared;
3233

3334
namespace Seq.Api.Client
3435
{
@@ -42,7 +43,7 @@ public sealed class SeqApiClient : IDisposable
4243
// Future versions of Seq may not completely support vN-1 features, however
4344
// providing this as an Accept header will ensure what compatibility is available
4445
// can be utilized.
45-
const string SeqApiV10MediaType = "application/vnd.datalust.seq.v10+json";
46+
const string SeqApiV11MediaType = "application/vnd.datalust.seq.v11+json";
4647

4748
readonly CookieContainer _cookies = new();
4849
readonly JsonSerializer _serializer = JsonSerializer.Create(
@@ -111,7 +112,7 @@ public SeqApiClient(string serverUrl, string apiKey = null, Func<CookieContainer
111112

112113
HttpClient = new HttpClient(httpMessageHandler);
113114
HttpClient.BaseAddress = new Uri(baseAddress);
114-
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV10MediaType));
115+
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV11MediaType));
115116

116117
if (_apiKey != null)
117118
HttpClient.DefaultRequestHeaders.Add("X-Seq-ApiKey", _apiKey);
@@ -372,23 +373,25 @@ async Task<string> HttpGetStringAsync(string url, CancellationToken cancellation
372373
async Task<Stream> HttpSendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
373374
{
374375
var response = await HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
376+
// ReSharper disable once MethodSupportsCancellation
375377
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
376378

377379
if (response.IsSuccessStatusCode)
378380
return stream;
379381

380-
Dictionary<string, object> payload = null;
382+
ErrorPart error = null;
381383
try
382384
{
383-
payload = _serializer.Deserialize<Dictionary<string, object>>(new JsonTextReader(new StreamReader(stream)));
385+
error = _serializer.Deserialize<ErrorPart>(new JsonTextReader(new StreamReader(stream)));
384386
}
385387
// ReSharper disable once EmptyGeneralCatchClause
386388
catch { }
387389

388-
if (payload != null && payload.TryGetValue("Error", out var error) && error != null)
389-
throw new SeqApiException($"{(int)response.StatusCode} - {error}", response.StatusCode);
390+
var exceptionMessage = $"The Seq request failed ({(int)response.StatusCode}/{response.StatusCode}).";
391+
if (error?.Error != null)
392+
exceptionMessage += $" {error.Error}";
390393

391-
throw new SeqApiException($"The Seq request failed ({(int)response.StatusCode}/{response.StatusCode}).", response.StatusCode);
394+
throw new SeqApiException(exceptionMessage, response.StatusCode);
392395
}
393396

394397
HttpContent MakeJsonContent(object content)

src/Seq.Api/Model/Alerting/AlertOccurrencePart.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using Seq.Api.Model.AppInstances;
43
using Seq.Api.Model.LogEvents;
54
using Seq.Api.Model.Shared;
65

src/Seq.Api/Model/Alerting/AlertOccurrenceRangePart.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Seq.Api.Model.LogEvents;
2-
using Seq.Api.Model.Shared;
1+
using Seq.Api.Model.Shared;
32

43
namespace Seq.Api.Model.Alerting
54
{

src/Seq.Api/Model/Alerting/AlertStateEntity.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
using System;
1615
using System.Collections.Generic;
16+
using Seq.Api.Model.LogEvents;
1717

1818
namespace Seq.Api.Model.Alerting
1919
{
@@ -41,25 +41,15 @@ public class AlertStateEntity : Entity
4141
/// The ids of app instances that receive notifications when the alert is triggered.
4242
/// </summary>
4343
public List<string> NotificationAppInstanceIds { get; set; }
44-
45-
/// <summary>
46-
/// The time at which the alert was last checked. Not preserved across server restarts.
47-
/// </summary>
48-
public DateTime? LastCheck { get; set; }
49-
50-
/// <summary>
51-
/// The time at which the alert last triggered a notification. Not preserved across server restarts.
52-
/// </summary>
53-
public DateTime? LastNotification { get; set; }
5444

5545
/// <summary>
56-
/// The time until which no further notifications will be sent by the alert.
46+
/// A level indicating the severity or priority of the alert.
5747
/// </summary>
58-
public DateTime? SuppressedUntil { get; set; }
59-
48+
public LogEventLevel NotificationLevel { get; set; }
49+
6050
/// <summary>
61-
/// <c>true</c> if the alert is in the failing state; otherwise, <c>false</c>.
51+
/// Any recent activity for the alert.
6252
/// </summary>
63-
public bool IsFailing { get; set; }
53+
public AlertActivityPart Activity { get; set; }
6454
}
6555
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright © Datalust and contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Seq.Api.Model.Apps
16+
{
17+
/// <summary>
18+
/// The data required to identify a NuGet package version.
19+
/// </summary>
20+
public class AppPackageIdentityPart
21+
{
22+
/// <summary>
23+
/// The id of the <see cref="Seq.Api.Model.Feeds.NuGetFeedEntity"/> from which the package was installed.
24+
/// </summary>
25+
public string NuGetFeedId { get; set; }
26+
27+
/// <summary>
28+
/// The package id, for example <c>Seq.Input.HealthCheck</c>.
29+
/// </summary>
30+
public string PackageId { get; set; }
31+
32+
/// <summary>
33+
/// The version of the package.
34+
/// </summary>
35+
public string Version { get; set; }
36+
}
37+
}

src/Seq.Api/Model/Apps/AppPackagePart.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,8 @@ namespace Seq.Api.Model.Apps
1919
/// <summary>
2020
/// Describes a NuGet package containing executable app components.
2121
/// </summary>
22-
public class AppPackagePart
22+
public class AppPackagePart : AppPackageIdentityPart
2323
{
24-
/// <summary>
25-
/// The id of the <see cref="NuGetFeedEntity"/> from which the package was installed.
26-
/// </summary>
27-
public string NuGetFeedId { get; set; }
28-
29-
/// <summary>
30-
/// The package id, for example <c>Seq.Input.HealthCheck</c>.
31-
/// </summary>
32-
public string PackageId { get; set; }
33-
34-
/// <summary>
35-
/// The version of the package.
36-
/// </summary>
37-
public string Version { get; set; }
38-
3924
/// <summary>
4025
/// Package authorship information.
4126
/// </summary>

src/Seq.Api/Model/Cluster/ClusterNodeEntity.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,40 @@ namespace Seq.Api.Model.Cluster
2020
public class ClusterNodeEntity : Entity
2121
{
2222
/// <summary>
23-
/// The role the node is currently acting in.
23+
/// An informational name associated with the node.
2424
/// </summary>
25-
public NodeRole Role { get; set; }
25+
public string Name { get; set; }
2626

2727
/// <summary>
28-
/// An informational name associated with the node.
28+
/// The address the node will serve intra-cluster traffic on.
2929
/// </summary>
30-
public string Name { get; set; }
31-
30+
public string ClusterListenUri { get; set; }
31+
3232
/// <summary>
33-
/// An informational representation of the storage generation committed to the node.
33+
/// The address the node will serve regular API requests on.
3434
/// </summary>
35-
public string Generation { get; set; }
35+
public string InternalListenUri { get; set; }
3636

3737
/// <summary>
3838
/// Whether any writes have occurred since the node's last completed sync.
3939
/// </summary>
40-
public bool? IsUpToDate { get; set; }
40+
public bool IsUpToDate { get; set; }
4141

4242
/// <summary>
4343
/// The time since the node's last completed sync operation.
4444
/// </summary>
45-
public double? MillisecondsSinceLastSync { get; set; }
45+
public double? DataAgeMilliseconds { get; set; }
4646

4747
/// <summary>
4848
/// The time since the follower's active sync was started.
4949
/// </summary>
5050
public double? MillisecondsSinceActiveSync { get; set; }
5151

52+
/// <summary>
53+
/// The time since the follower's last heartbeat.
54+
/// </summary>
55+
public double? MillisecondsSinceLastHeartbeat { get; set; }
56+
5257
/// <summary>
5358
/// The total number of operations in the active sync.
5459
/// </summary>
@@ -64,5 +69,10 @@ public class ClusterNodeEntity : Entity
6469
/// information about the node is available.
6570
/// </summary>
6671
public string StateDescription { get; set; }
72+
73+
/// <summary>
74+
/// Whether the node is currently leading the cluster.
75+
/// </summary>
76+
public bool IsLeading { get; set; }
6777
}
6878
}

src/Seq.Api/Model/Cluster/NodeRole.cs renamed to src/Seq.Api/Model/Cluster/HealthCheckResultPart.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,18 @@
1515
namespace Seq.Api.Model.Cluster
1616
{
1717
/// <summary>
18-
/// The role a node is acting in within a cluster of connected Seq instances.
18+
/// A result reported from a health check endpoint.
1919
/// </summary>
20-
public enum NodeRole
20+
public class HealthCheckResultPart
2121
{
2222
/// <summary>
23-
/// The node is not part of a cluster.
23+
/// The status reported by the endpoint.
2424
/// </summary>
25-
Standalone,
26-
27-
/// <summary>
28-
/// The node is a replica, following the state of a leader node.
29-
/// </summary>
30-
Follower,
31-
25+
public HealthStatus Status { get; set; }
26+
3227
/// <summary>
33-
/// The node is a replication leader.
28+
/// An informational description of the reported status.
3429
/// </summary>
35-
Leader
30+
public string Description { get; set; }
3631
}
3732
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright Datalust and contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Seq.Api.Model.Cluster
16+
{
17+
/// <summary>
18+
/// A status value returned from a health check endpoint.
19+
/// </summary>
20+
/// <remarks>Note that HTTP status code values returned from health checks should be inspected prior to
21+
/// reading status information from the health check response payload.</remarks>
22+
public enum HealthStatus
23+
{
24+
/// <summary>
25+
/// The target is healthy.
26+
/// </summary>
27+
Healthy,
28+
29+
/// <summary>
30+
/// The target is functioning in a degraded state; attention is required.
31+
/// </summary>
32+
Degraded,
33+
34+
/// <summary>
35+
/// The target is unhealthy.
36+
/// </summary>
37+
Unhealthy
38+
}
39+
}

src/Seq.Api/Model/Dashboarding/ChartPart.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ public class ChartPart
4141
/// The individual queries making up the chart. In most instances, only one query is currently supported
4242
/// here.
4343
/// </summary>
44-
public List<ChartQueryPart> Queries { get; set; } = new List<ChartQueryPart>();
44+
public List<ChartQueryPart> Queries { get; set; } = new();
4545

4646
/// <summary>
4747
/// How the chart will appear on the dashboard.
4848
/// </summary>
49-
public ChartDisplayStylePart DisplayStyle { get; set; } = new ChartDisplayStylePart();
49+
public ChartDisplayStylePart DisplayStyle { get; set; } = new();
50+
51+
/// <summary>
52+
/// A short summary of the chart contents.
53+
/// </summary>
54+
public string Description { get; set; }
5055
}
5156
}

0 commit comments

Comments
 (0)