Skip to content

Commit

Permalink
Merge pull request #110 from datalust/dev
Browse files Browse the repository at this point in the history
2022.1 Release
  • Loading branch information
nblumhardt authored Mar 15, 2022
2 parents 64fd9bf + b0c8c22 commit 4b8e1b4
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 109 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2019
image: Visual Studio 2022
build_script:
- ps: ./Build.ps1
test: off
Expand Down
22 changes: 12 additions & 10 deletions src/Seq.Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ namespace Seq.Api.Client
/// <summary>
/// A low-level client that provides navigation over the linked resource structure of the Seq HTTP API.
/// </summary>
public class SeqApiClient : IDisposable
public sealed class SeqApiClient : IDisposable
{
readonly string _apiKey;

// Future versions of Seq may not completely support v1 features, however
// 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 SeqApiV8MediaType = "application/vnd.datalust.seq.v8+json";
const string SeqApiV9MediaType = "application/vnd.datalust.seq.v9+json";

readonly CookieContainer _cookies = new CookieContainer();
readonly CookieContainer _cookies = new();
readonly JsonSerializer _serializer = JsonSerializer.Create(
new JsonSerializerSettings
{
Converters = { new StringEnumConverter(), new LinkCollectionConverter() }
Converters = { new StringEnumConverter(), new LinkCollectionConverter() },
DateParseHandling = DateParseHandling.None,
FloatParseHandling = FloatParseHandling.Decimal
});

/// <summary>
Expand Down Expand Up @@ -89,7 +91,7 @@ public SeqApiClient(string serverUrl, string apiKey = null, Action<HttpClientHan
baseAddress += "/";

HttpClient = new HttpClient(handler) { BaseAddress = new Uri(baseAddress) };
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV8MediaType));
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV9MediaType));

if (_apiKey != null)
HttpClient.DefaultRequestHeaders.Add("X-Seq-ApiKey", _apiKey);
Expand Down Expand Up @@ -175,8 +177,8 @@ public async Task PostAsync<TEntity>(ILinked entity, string link, TEntity conten
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
using (var reader = new StreamReader(stream))
reader.ReadToEnd();
using var reader = new StreamReader(stream);
await reader.ReadToEndAsync();
}

/// <summary>
Expand Down Expand Up @@ -213,8 +215,8 @@ public async Task<string> PostReadStringAsync<TEntity>(ILinked entity, string li
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Post, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request, cancellationToken).ConfigureAwait(false);
using (var reader = new StreamReader(stream))
return await reader.ReadToEndAsync();
using var reader = new StreamReader(stream);
return await reader.ReadToEndAsync();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Model/Alerting/AlertEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class AlertEntity : Entity
public string OwnerId { get; set; }

/// <summary>
/// If <c>true</c>, the alert can only be modified by users with the <see cref="Permission.Setup"/> permission.
/// If <c>true</c>, the alert can only be modified by users with the <see cref="Permission.Project"/> permission.
/// </summary>
public bool IsProtected { get; set; }

Expand Down
36 changes: 25 additions & 11 deletions src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using Seq.Api.Model.Signals;
using Seq.Api.ResourceGroups;

#nullable enable

namespace Seq.Api.Model.AppInstances
{
/// <summary>
Expand Down Expand Up @@ -49,17 +51,17 @@ public AppInstanceEntity()
/// <summary>
/// The id of the <see cref="AppEntity"/> that this is an instance of.
/// </summary>
public string AppId { get; set; }
public string? AppId { get; set; }

/// <summary>
/// The user-friendly title of the app instance.
/// </summary>
public string Title { get; set; }
public string? Title { get; set; }

/// <summary>
/// Values for the settings exposed by the app.
/// </summary>
public Dictionary<string, string> Settings { get; set; }
public Dictionary<string, string>? Settings { get; set; }

/// <summary>
/// If <c>true</c>, administrative users may invoke the app manually or through alerts.
Expand All @@ -77,13 +79,13 @@ public AppInstanceEntity()
/// The settings that can be overridden at invocation time (when an event is sent to
/// the instance).
/// </summary>
public List<string> InvocationOverridableSettings { get; set; }
public List<string>? InvocationOverridableSettings { get; set; }

/// <summary>
/// Metadata describing the overridable settings. This field is provided by the server
/// and cannot be modified.
/// </summary>
public List<AppSettingPart> InvocationOverridableSettingDefinitions { get; set; }
public List<AppSettingPart>? InvocationOverridableSettingDefinitions { get; set; }

/// <summary>
/// If <c>true</c>, events will be streamed to the app. Otherwise, events will be
Expand All @@ -95,7 +97,7 @@ public AppInstanceEntity()
/// The signal expression describing which events will be sent to the app; if <c>null</c>,
/// all events will reach the app.
/// </summary>
public SignalExpressionPart StreamedSignalExpression { get; set; }
public SignalExpressionPart? StreamedSignalExpression { get; set; }

/// <summary>
/// If a value is specified, events will be buffered to disk and sorted by timestamp-order
Expand All @@ -121,31 +123,31 @@ public AppInstanceEntity()
/// Settings that control how events are ingested through the app.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public InputSettingsPart InputSettings { get; set; }
public InputSettingsPart? InputSettings { get; set; }

/// <summary>
/// Metrics describing the state and activity of the app process.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public AppInstanceProcessMetricsPart ProcessMetrics { get; set; }
public AppInstanceProcessMetricsPart? ProcessMetrics { get; set; }

/// <summary>
/// Information about ingestion activity through this app.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public InputMetricsPart InputMetrics { get; set; }
public InputMetricsPart? InputMetrics { get; set; }

/// <summary>
/// Information about the app's diagnostic input.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public InputMetricsPart DiagnosticInputMetrics { get; set; }
public InputMetricsPart? DiagnosticInputMetrics { get; set; }

/// <summary>
/// Information about events output through the app.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public AppInstanceOutputMetricsPart OutputMetrics { get; set; }
public AppInstanceOutputMetricsPart? OutputMetrics { get; set; }

/// <summary>
/// Obsolete.
Expand All @@ -160,5 +162,17 @@ public AppInstanceEntity()
[Obsolete("Use !AcceptDirectInvocation instead.")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? DisallowManualInput { get; set; }

/// <summary>
/// The name of the app.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string? AppName { get; set; }

/// <summary>
/// If <c>true</c>, then the app is able to write events to the log.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? IsInput { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/Seq.Api/Model/Apps/AppSettingPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,16 @@ public class AppSettingPart
/// for the setting.
/// </summary>
public List<AppSettingValuePart> AllowedValues { get; set; } = new List<AppSettingValuePart>();

/// <summary>
/// If the setting value contains code in a programming or markup language, the
/// language name.
/// </summary>
/// <remarks>Valid names are a subset of the names and aliases recognized by
/// <a href="https://github.com/github/linguist/blob/master/lib/linguist/languages.yml">GitHub
/// Linguist</a>. The generic value <c>code</c> will be specified if the language is non-specific but
/// the value should be displayed in fixed-width font. Seq also recognizes the special Seq-specific
/// <c>template</c> and <c>expression</c> syntaxes.</remarks>
public string Syntax { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Seq.Api/Model/Dashboarding/DashboardEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class DashboardEntity : Entity
public string Title { get; set; }

/// <summary>
/// If <c>true</c>, only users with <see cref="Permission.Setup"/> can modify the dashboard.
/// If <c>true</c>, only users with <see cref="Permission.Project"/> can modify the dashboard.
/// </summary>
public bool IsProtected { get; set; }

Expand Down
7 changes: 7 additions & 0 deletions src/Seq.Api/Model/Data/QueryResultPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using Newtonsoft.Json;

namespace Seq.Api.Model.Data
Expand Down Expand Up @@ -50,6 +51,12 @@ public class QueryResultPart
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public TimeseriesPart[] Series { get; set; }

/// <summary>
/// Result variables.
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public Dictionary<string, object> Variables { get; set; }

/// <summary>
/// On error only, a description of the error.
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Model/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Seq.Api.Model
/// parameterized in order to produce a complete URI (if the template contains no
/// parameters then it may also be a literal URI).
/// </summary>
public struct Link
public readonly struct Link
{
/// <summary>
/// An empty link.
Expand Down
23 changes: 22 additions & 1 deletion src/Seq.Api/Model/Security/Permission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace Seq.Api.Model.Security
{
/// <summary>
Expand Down Expand Up @@ -46,10 +48,29 @@ public enum Permission
/// Write-access to signals, alerts, preferences etc.
/// </summary>
Write,

/// <summary>
/// Access to administrative features of Seq, management of other users, app installation, backups.
/// </summary>
[Obsolete("The `Setup` permission has been replaced by `Project` and `System`.")]
Setup,

/// <summary>
/// Access to settings that control data ingestion, storage, dashboarding and alerting.
/// </summary>
Project,

/// <summary>
/// Access to settings and features that interact with, or provide access to, the underlying host server,
/// such as app (plug-in) installation, backup settings, cluster configuration, diagnostics, and features
/// relying on outbound network access like package feeds and update checks. This permission is required for
/// configuration of the authentication provider and related settings.
/// </summary>
System,

/// <summary>
/// Create, edit, and delete user accounts, reset local user passwords.
/// </summary>
Organization
}
}
7 changes: 6 additions & 1 deletion src/Seq.Api/Model/Security/RoleEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class RoleEntity : Entity
/// <summary>
/// Permissions granted to users in the role.
/// </summary>
public HashSet<Permission> Permissions { get; set; } = new HashSet<Permission>();
public HashSet<Permission> Permissions { get; set; } = new();

/// <summary>
/// Optionally, an extended description of the role.
/// </summary>
public string Description { get; set; }
}
}
39 changes: 39 additions & 0 deletions src/Seq.Api/Model/Shared/EvaluationContextPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright © Datalust and contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using Seq.Api.Model.Signals;

#nullable enable

namespace Seq.Api.Model.Shared
{
/// <summary>
/// Specifies the context that queries and searches execute within.
/// </summary>
public class EvaluationContextPart
{
/// <summary>
/// An unsaved or modified signal.
/// </summary>
public SignalEntity? Signal { get; set; }

/// <summary>
/// Values for free variables that appear in the query or search condition.
/// </summary>
/// <remarks>Variables will only be visible in the query or search being executed: any free variables
/// in signal filters will remain undefined.</remarks>
public Dictionary<string, object?>? Variables { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Seq.Api/Model/Signals/SignalEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public SignalEntity()
public bool? IsRestricted { get; set; }

/// <summary>
/// If <c>true</c>, the signal can only be modified by users with the <see cref="Permission.Setup"/> permission.
/// If <c>true</c>, the signal can only be modified by users with the <see cref="Permission.Project"/> permission.
/// </summary>
public bool IsProtected { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SqlQueryEntity()
public string Sql { get; set; }

/// <summary>
/// If <c>true</c>, only users with <see cref="Permission.Setup"/> permission can edit the signal.
/// If <c>true</c>, only users with <see cref="Permission.Project"/> permission can edit the SQL query.
/// </summary>
public bool IsProtected { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Seq.Api.Model.Users
/// <summary>
/// An operation applied to a search history item.
/// </summary>
public enum SearchHistoryItemStatus
public enum SearchHistoryItemAction
{
/// <summary>
/// The item was used (make it more recent).
Expand All @@ -28,10 +28,10 @@ public enum SearchHistoryItemStatus
/// The item has been pinned.
/// </summary>
Pinned,

/// <summary>
/// The item has been un-pinned.
/// The item has been unpinned.
/// </summary>
Forgotten
Unpinned
}
}
Loading

0 comments on commit 4b8e1b4

Please sign in to comment.