Skip to content

Commit 703287c

Browse files
committed
variables and permissions
1 parent 706d26f commit 703287c

File tree

15 files changed

+183
-89
lines changed

15 files changed

+183
-89
lines changed

src/Seq.Api/Client/SeqApiClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ namespace Seq.Api.Client
3535
/// <summary>
3636
/// A low-level client that provides navigation over the linked resource structure of the Seq HTTP API.
3737
/// </summary>
38-
public class SeqApiClient : IDisposable
38+
public sealed class SeqApiClient : IDisposable
3939
{
4040
readonly string _apiKey;
4141

42-
// Future versions of Seq may not completely support v1 features, however
42+
// Future versions of Seq may not completely support vN-1 features, however
4343
// providing this as an Accept header will ensure what compatibility is available
4444
// can be utilized.
45-
const string SeqApiV8MediaType = "application/vnd.datalust.seq.v8+json";
45+
const string SeqApiV9MediaType = "application/vnd.datalust.seq.v9+json";
4646

47-
readonly CookieContainer _cookies = new CookieContainer();
47+
readonly CookieContainer _cookies = new();
4848
readonly JsonSerializer _serializer = JsonSerializer.Create(
4949
new JsonSerializerSettings
5050
{
@@ -89,7 +89,7 @@ public SeqApiClient(string serverUrl, string apiKey = null, Action<HttpClientHan
8989
baseAddress += "/";
9090

9191
HttpClient = new HttpClient(handler) { BaseAddress = new Uri(baseAddress) };
92-
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV8MediaType));
92+
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV9MediaType));
9393

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

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

220220
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class AlertEntity : Entity
4242
public string OwnerId { get; set; }
4343

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

src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,15 @@ public AppInstanceEntity()
160160
[Obsolete("Use !AcceptDirectInvocation instead.")]
161161
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
162162
public bool? DisallowManualInput { get; set; }
163+
164+
/// <summary>
165+
/// The name of the application.
166+
/// </summary>
167+
public string AppName { get; set; }
168+
169+
/// <summary>
170+
/// Is the application an input application?
171+
/// </summary>
172+
public bool IsInput { get; set; }
163173
}
164174
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,16 @@ public class AppSettingPart
5454
/// for the setting.
5555
/// </summary>
5656
public List<AppSettingValuePart> AllowedValues { get; set; } = new List<AppSettingValuePart>();
57+
58+
/// <summary>
59+
/// If the setting value contains code in a programming or markup language, the
60+
/// language name.
61+
/// </summary>
62+
/// <remarks>Valid names are a subset of the names and aliases recognized by
63+
/// <a href="https://github.com/github/linguist/blob/master/lib/linguist/languages.yml">GitHub
64+
/// Linguist</a>. The generic value <c>code</c> will be specified if the language is non-specific but
65+
/// the value should be displayed in fixed-width font. Seq also recognizes the special Seq-specific
66+
/// <c>template</c> and <c>expression</c> syntaxes.</remarks>
67+
public string Syntax { get; set; }
5768
}
5869
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DashboardEntity : Entity
3434
public string Title { get; set; }
3535

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

src/Seq.Api/Model/Data/QueryResultPart.cs

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

15+
using System.Collections.Generic;
1516
using Newtonsoft.Json;
1617

1718
namespace Seq.Api.Model.Data
@@ -50,6 +51,12 @@ public class QueryResultPart
5051
/// </summary>
5152
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
5253
public TimeseriesPart[] Series { get; set; }
54+
55+
/// <summary>
56+
/// Result variables.
57+
/// </summary>
58+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
59+
public Dictionary<string, object> Variables { get; set; }
5360

5461
/// <summary>
5562
/// On error only, a description of the error.

src/Seq.Api/Model/Link.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Seq.Api.Model
2626
/// parameterized in order to produce a complete URI (if the template contains no
2727
/// parameters then it may also be a literal URI).
2828
/// </summary>
29-
public struct Link
29+
public readonly struct Link
3030
{
3131
/// <summary>
3232
/// An empty link.

src/Seq.Api/Model/Security/Permission.cs

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

15+
using System;
16+
1517
namespace Seq.Api.Model.Security
1618
{
1719
/// <summary>
@@ -46,10 +48,23 @@ public enum Permission
4648
/// Write-access to signals, alerts, preferences etc.
4749
/// </summary>
4850
Write,
49-
51+
5052
/// <summary>
5153
/// Access to administrative features of Seq, management of other users, app installation, backups.
5254
/// </summary>
53-
Setup,
55+
[Obsolete("The `Setup` permission has been replaced by `Project` and `System`.")]
56+
Setup = 5,
57+
58+
/// <summary>
59+
/// Access to settings required for day-to-day operation of Seq, such as users, retention policies, API keys.
60+
/// </summary>
61+
Project,
62+
63+
/// <summary>
64+
/// Access to settings and features that interact with, or provide access to, the underlying host server,
65+
/// such as app (plug-in) installation, backup settings, cluster configuration, diagnostics, and features
66+
/// relying on outbound network access like package feeds and update checks.
67+
/// </summary>
68+
System
5469
}
5570
}
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+
using System.Collections.Generic;
16+
using Seq.Api.Model.Signals;
17+
18+
#nullable enable
19+
20+
namespace Seq.Api.Model.Shared
21+
{
22+
/// <summary>
23+
/// Specifies the context that queries and searches execute within.
24+
/// </summary>
25+
public class EvaluationContextPart
26+
{
27+
/// <summary>
28+
/// An unsaved or modified signal.
29+
/// </summary>
30+
public SignalEntity? Signal { get; set; }
31+
32+
/// <summary>
33+
/// Values for free variables that appear in the query or search condition.
34+
/// </summary>
35+
/// <remarks>Variables will only be visible in the query or search being executed: any free variables
36+
/// in signal filters will remain undefined.</remarks>
37+
public Dictionary<string, object?>? Variables { get; set; }
38+
}
39+
}

src/Seq.Api/Model/Signals/SignalEntity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public SignalEntity()
6464
public bool? IsRestricted { get; set; }
6565

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

0 commit comments

Comments
 (0)