Skip to content

Commit

Permalink
Merge pull request #132 from nblumhardt/2024.2
Browse files Browse the repository at this point in the history
Seq 2024.2 API updates
  • Loading branch information
nblumhardt authored Mar 24, 2024
2 parents a9dcffc + e9d71aa commit 6aad9ee
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,5 @@ paket-files/

.vscode/
*.orig

.DS_Store
8 changes: 4 additions & 4 deletions example/SeqEnableAAD/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ static async Task Run(string server, string? username, string? tenantId, string?

var user = await connection.Users.FindCurrentAsync();
var provider = await connection.Settings.FindNamedAsync(SettingName.AuthenticationProvider);
var cid = await connection.Settings.FindNamedAsync(SettingName.AzureADClientId);
var ckey = await connection.Settings.FindNamedAsync(SettingName.AzureADClientKey);
var aut = await connection.Settings.FindNamedAsync(SettingName.AzureADAuthority);
var tid = await connection.Settings.FindNamedAsync(SettingName.AzureADTenantId);
var cid = await connection.Settings.FindNamedAsync(SettingName.EntraIDClientId);
var ckey = await connection.Settings.FindNamedAsync(SettingName.EntraIDClientKey);
var aut = await connection.Settings.FindNamedAsync(SettingName.EntraIDAuthority);
var tid = await connection.Settings.FindNamedAsync(SettingName.EntraIDTenantId);

user.Username = username;
provider.Value = "Azure Active Directory";
Expand Down
1 change: 1 addition & 0 deletions seq-api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{7DCED6
Build.ps1 = Build.ps1
LICENSE = LICENSE
README.md = README.md
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5E7A565B-A8EE-43E7-A225-5B640A5D29A0}"
Expand Down
6 changes: 3 additions & 3 deletions src/Seq.Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class SeqApiClient : IDisposable
// Future versions of Seq may not completely support vN-1 features, however
// providing this as an Accept header will ensure what compatibility is available
// can be utilized.
const string SeqApiV9MediaType = "application/vnd.datalust.seq.v9+json";
const string SeqApiV10MediaType = "application/vnd.datalust.seq.v10+json";

readonly CookieContainer _cookies = new();
readonly JsonSerializer _serializer = JsonSerializer.Create(
Expand Down Expand Up @@ -106,12 +106,12 @@ public SeqApiClient(string serverUrl, string apiKey = null, Func<CookieContainer
_apiKey = apiKey;

var baseAddress = serverUrl;
if (!baseAddress.EndsWith("/"))
if (!baseAddress.EndsWith("/", StringComparison.Ordinal))
baseAddress += "/";

HttpClient = new HttpClient(httpMessageHandler);
HttpClient.BaseAddress = new Uri(baseAddress);
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV9MediaType));
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV10MediaType));

if (_apiKey != null)
HttpClient.DefaultRequestHeaders.Add("X-Seq-ApiKey", _apiKey);
Expand Down
8 changes: 8 additions & 0 deletions src/Seq.Api/Model/Events/EventEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ public class EventEntity : Entity
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string ParentId { get; set; }

/// <summary>
/// If the event is a span, its kind. This will typically be one of either <c>Client</c>, <c>Server</c>,
/// <c>Producer</c>, <c>Consumer</c>, or <c>Internal</c>. The span kind records how the span relates to its
/// parent or child span within a trace.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string SpanKind { get; set; }

/// <summary>
/// A collection of properties describing the origin of the event, if any. These correspond to resource
Expand Down
26 changes: 15 additions & 11 deletions src/Seq.Api/Model/Settings/SettingName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum SettingName
{
/// <summary>
/// The authentication provider to use. Allowed values are <c>null</c> (local username/password),
/// <c>"Active Directory"</c>, <c>"Azure Active Directory"</c> and <c>"OpenID Connect"</c>.
/// <c>"Active Directory"</c>, <c>"Microsoft Entra ID"</c> and <c>"OpenID Connect"</c>.
/// </summary>
AuthenticationProvider,

Expand All @@ -38,7 +38,7 @@ public enum SettingName
AutomaticAccessADGroup,

/// <summary>
/// If <c>true</c>, Azure Active Directory accounts in the configured tenant will
/// If <c>true</c>, Microsoft Entra ID accounts in the configured tenant will
/// be automatically granted user access to Seq.
/// </summary>
[Obsolete("Use `AutomaticallyProvisionAuthenticatedUsers`.", error: true)]
Expand All @@ -51,25 +51,29 @@ public enum SettingName
AutomaticallyProvisionAuthenticatedUsers,

/// <summary>
/// The AAD authority. The default is <c>login.windows.net</c>; government cloud users may
/// The Microsoft Entra ID authority. The default is <c>login.windows.net</c>; government cloud users may
/// require <c>login.microsoftonline.us</c> or similar.
/// </summary>
AzureADAuthority,
// ReSharper disable once InconsistentNaming
EntraIDAuthority,

/// <summary>
/// The Azure Active Directory client id.
/// The Microsoft Entra ID client id.
/// </summary>
AzureADClientId,
// ReSharper disable once InconsistentNaming
EntraIDClientId,

/// <summary>
/// The Azure Active Directory client key.
/// The Microsoft Entra ID client key.
/// </summary>
AzureADClientKey,
// ReSharper disable once InconsistentNaming
EntraIDClientKey,

/// <summary>
/// The Azure Active Directory tenant id.
/// The Microsoft Entra ID tenant id.
/// </summary>
AzureADTenantId,
// ReSharper disable once InconsistentNaming
EntraIDTenantId,

/// <summary>
/// Server-local filesystem location where automatic backups are stored.
Expand Down Expand Up @@ -170,7 +174,7 @@ public enum SettingName
/// If using OpenID Connect, overrides the URI of the provider's metadata endpoint.
/// </summary>
OpenIdConnectMetadataAddress,

/// <summary>
/// If <c>true</c>, ingestion requests incoming via HTTP must be authenticated using an API key or
/// logged-in user session. Only effective when <see cref="IsAuthenticationEnabled"/> is <c>true</c>.
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Seq.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Client library for the Seq HTTP API.</Description>
<VersionPrefix>2024.1.0</VersionPrefix>
<VersionPrefix>2024.2.0</VersionPrefix>
<Authors>Datalust;Contributors</Authors>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
2 changes: 2 additions & 0 deletions test/Seq.Api.Tests/SeqConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public void WhenConstructedTheHandlerConfigurationCallbackIsCalled()
{
var callCount = 0;

#pragma warning disable CS0618 // Type or member is obsolete
using var _ = new SeqConnection("https://test.example.com", null, handler => {
Assert.NotNull(handler);
++callCount;
});
#pragma warning restore CS0618 // Type or member is obsolete

Assert.Equal(1, callCount);
}
Expand Down

0 comments on commit 6aad9ee

Please sign in to comment.