From b2eb01cf2813790f66861168dd0aaf9b4ca77f00 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 29 Oct 2018 15:57:24 +1000 Subject: [PATCH 1/2] Merge latest Seq 5 API changes --- .../Model/AppInstances/AppInstanceEntity.cs | 12 ++--- .../AppInstances/AppInstanceMetricsPart.cs | 10 ++++ src/Seq.Api/Model/Events/DeleteResultPart.cs | 1 - src/Seq.Api/Model/Inputs/ApiKeyEntity.cs | 7 +-- src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs | 1 + src/Seq.Api/Model/Monitoring/AlertPart.cs | 1 + .../Model/Monitoring/DashboardEntity.cs | 2 + .../Monitoring/MeasurementDisplayStylePart.cs | 1 + src/Seq.Api/Model/Settings/SettingName.cs | 5 +- src/Seq.Api/Model/Signals/SignalEntity.cs | 6 ++- .../Model/SqlQueries/SqlQueryEntity.cs | 7 ++- .../Model/Workspaces/WorkspaceContentPart.cs | 11 +++++ .../Model/Workspaces/WorkspaceEntity.cs | 12 +++++ .../ResourceGroups/ApiResourceGroup.cs | 2 +- .../ResourceGroups/AppsResourceGroup.cs | 11 ++++- .../ResourceGroups/DashboardsResourceGroup.cs | 2 +- .../ResourceGroups/SettingsResourceGroup.cs | 12 ++++- .../ResourceGroups/SignalsResourceGroup.cs | 5 +- .../ResourceGroups/SqlQueriesResourceGroup.cs | 7 +-- .../ResourceGroups/WorkspacesResourceGroup.cs | 47 +++++++++++++++++++ src/Seq.Api/Seq.Api.csproj | 2 +- src/Seq.Api/SeqConnection.cs | 4 ++ test/Seq.Api.Tests/Seq.Api.Tests.csproj | 2 +- 23 files changed, 143 insertions(+), 27 deletions(-) create mode 100644 src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs create mode 100644 src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs create mode 100644 src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs create mode 100644 src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs diff --git a/src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs b/src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs index f4921c5..cbae7ef 100644 --- a/src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs +++ b/src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Newtonsoft.Json; using Seq.Api.Model.Apps; using Seq.Api.Model.Signals; @@ -13,9 +14,7 @@ public AppInstanceEntity() InvocationOverridableSettings = new List(); InvocationOverridableSettingDefinitions = new List(); EventsPerSuppressionWindow = 1; -#pragma warning disable 618 - SignalIds = new List(); -#pragma warning restore 618 + Metrics = new AppInstanceMetricsPart(); } public string Title { get; set; } @@ -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 SignalIds { get; set; } public List InvocationOverridableSettingDefinitions { get; set; } + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public AppInstanceMetricsPart Metrics { get; set; } } } diff --git a/src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs b/src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs new file mode 100644 index 0000000..0f94b74 --- /dev/null +++ b/src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs @@ -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; } + } +} diff --git a/src/Seq.Api/Model/Events/DeleteResultPart.cs b/src/Seq.Api/Model/Events/DeleteResultPart.cs index f9e6e43..ebab4f2 100644 --- a/src/Seq.Api/Model/Events/DeleteResultPart.cs +++ b/src/Seq.Api/Model/Events/DeleteResultPart.cs @@ -2,6 +2,5 @@ { public class DeleteResultPart { - public long DeletedEventCount { get; set; } } } diff --git a/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs b/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs index 3ce4b36..058ffd3 100644 --- a/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs +++ b/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs @@ -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; @@ -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 AssignedPermissions { get; set; } = new HashSet(); + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public ApiKeyMetricsPart Metrics { get; set; } = new ApiKeyMetricsPart(); } } diff --git a/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs b/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs index b0c3dfd..5ac3870 100644 --- a/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs +++ b/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs @@ -4,5 +4,6 @@ public class ApiKeyMetricsPart { public int ArrivalsPerMinute { get; set; } public int InfluxPerMinute { get; set; } + public long IngestedBytesPerMinute { get; set; } } } \ No newline at end of file diff --git a/src/Seq.Api/Model/Monitoring/AlertPart.cs b/src/Seq.Api/Model/Monitoring/AlertPart.cs index 6e3b8c0..cb3a9fe 100644 --- a/src/Seq.Api/Model/Monitoring/AlertPart.cs +++ b/src/Seq.Api/Model/Monitoring/AlertPart.cs @@ -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; } diff --git a/src/Seq.Api/Model/Monitoring/DashboardEntity.cs b/src/Seq.Api/Model/Monitoring/DashboardEntity.cs index a94b268..0e932ea 100644 --- a/src/Seq.Api/Model/Monitoring/DashboardEntity.cs +++ b/src/Seq.Api/Model/Monitoring/DashboardEntity.cs @@ -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 Charts { get; set; } = new List(); diff --git a/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs b/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs index 4c47411..75209f4 100644 --- a/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs +++ b/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs @@ -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; } } diff --git a/src/Seq.Api/Model/Settings/SettingName.cs b/src/Seq.Api/Model/Settings/SettingName.cs index d5cb31d..f9ab369 100644 --- a/src/Seq.Api/Model/Settings/SettingName.cs +++ b/src/Seq.Api/Model/Settings/SettingName.cs @@ -18,9 +18,12 @@ public enum SettingName LazilyFlushEventWrites, MasterKeyIsBackedUp, MinimumFreeStorageSpace, + NewUserShowSignalIds, + NewUserShowQueryIds, + NewUserShowDashboardIds, RequireApiKeyForWritingEvents, RawEventMaximumContentLength, RawPayloadMaximumContentLength, ThemeStyles } -} \ No newline at end of file +} diff --git a/src/Seq.Api/Model/Signals/SignalEntity.cs b/src/Seq.Api/Model/Signals/SignalEntity.cs index c7aa3c4..a755264 100644 --- a/src/Seq.Api/Model/Signals/SignalEntity.cs +++ b/src/Seq.Api/Model/Signals/SignalEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Newtonsoft.Json; namespace Seq.Api.Model.Signals { @@ -20,9 +21,8 @@ public SignalEntity() public List TaggedProperties { get; set; } - public bool IsWatched { get; set; } - [Obsolete("This member has been renamed `IsProtected` to better reflect its purpose.")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] // ReSharper disable once UnusedMember.Global public bool? IsRestricted { get; set; } @@ -31,5 +31,7 @@ public SignalEntity() public SignalGrouping Grouping { get; set; } public string ExplicitGroupName { get; set; } + + public string OwnerId { get; set; } } } diff --git a/src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs b/src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs index a09112a..289d4c1 100644 --- a/src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs +++ b/src/Seq.Api/Model/SqlQueries/SqlQueryEntity.cs @@ -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; } + } -} \ No newline at end of file +} diff --git a/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs b/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs new file mode 100644 index 0000000..bc32a5d --- /dev/null +++ b/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Seq.Api.Model.Workspaces +{ + public class WorkspaceContentPart + { + public List SignalIds { get; set; } = new List(); + public List QueryIds { get; set; } = new List(); + public List DashboardIds { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs b/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs new file mode 100644 index 0000000..27ed398 --- /dev/null +++ b/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs @@ -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(); + } +} diff --git a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs index 23cf62b..9aa77a2 100644 --- a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs @@ -19,7 +19,7 @@ internal ApiResourceGroup(string name, ISeqConnection connection) _connection = connection; } - protected SeqApiClient Client { get { return _connection.Client; } } + protected SeqApiClient Client => _connection.Client; protected Task LoadGroupAsync() { diff --git a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs index 6488b3b..b46e543 100644 --- a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs @@ -47,9 +47,18 @@ public async Task InstallPackageAsync(string feedId, string packageId { if (feedId == null) throw new ArgumentNullException(nameof(feedId)); if (packageId == null) throw new ArgumentNullException(nameof(packageId)); - var parameters = new Dictionary{{ "feedId", feedId}, {"packageId", packageId}}; + var parameters = new Dictionary { { "feedId", feedId }, { "packageId", packageId } }; if (version != null) parameters.Add("version", version); return await GroupPostAsync("InstallPackage", new object(), parameters).ConfigureAwait(false); } + + public async Task UpdatePackageAsync(AppEntity entity, string version = null, bool force = false) + { + if (entity == null) throw new ArgumentNullException(nameof(entity)); + var parameters = new Dictionary(); + if (force) parameters.Add("force", true); + if (version != null) parameters.Add("version", version); + return await Client.PostAsync(entity, "UpdatePackage", new object(), parameters).ConfigureAwait(false); + } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs index 39eee61..6fbbf79 100644 --- a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs @@ -31,7 +31,7 @@ public async Task TemplateAsync() public async Task AddAsync(DashboardEntity entity) { - return await Client.PostAsync(entity, "Create", entity).ConfigureAwait(false); + return await GroupCreateAsync(entity).ConfigureAwait(false); } public async Task RemoveAsync(DashboardEntity entity) diff --git a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs index 1ec5292..36a88ec 100644 --- a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs @@ -47,5 +47,15 @@ public async Task UpdateAsync(SettingEntity entity) { await Client.PutAsync(entity, "Self", entity).ConfigureAwait(false); } + + public async Task GetInternalErrorReportingAsync() + { + return await GroupGetAsync("InternalErrorReporting").ConfigureAwait(false); + } + + public async Task UpdateInternalErrorReportingAsync(InternalErrorReportingSettingsPart internalErrorReporting) + { + await GroupPutAsync("InternalErrorReporting", internalErrorReporting).ConfigureAwait(false); + } } -} \ No newline at end of file +} diff --git a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs index cf68e2b..ce0aab2 100644 --- a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs @@ -18,9 +18,10 @@ public async Task FindAsync(string id) return await GroupGetAsync("Item", new Dictionary { { "id", id } }).ConfigureAwait(false); } - public async Task> ListAsync() + public async Task> ListAsync(string ownerId = null, bool shared = false) { - return await GroupListAsync("Items").ConfigureAwait(false); + var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; + return await GroupListAsync("Items", parameters).ConfigureAwait(false); } public async Task TemplateAsync() diff --git a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs index 3b84725..3279188 100644 --- a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs @@ -18,9 +18,10 @@ public async Task FindAsync(string id) return await GroupGetAsync("Item", new Dictionary { { "id", id } }).ConfigureAwait(false); } - public async Task> ListAsync() + public async Task> ListAsync(string ownerId = null, bool shared = false) { - return await GroupListAsync("Items").ConfigureAwait(false); + var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; + return await GroupListAsync("Items", parameters).ConfigureAwait(false); } public async Task TemplateAsync() @@ -30,7 +31,7 @@ public async Task TemplateAsync() public async Task AddAsync(SqlQueryEntity entity) { - return await Client.PostAsync(entity, "Create", entity).ConfigureAwait(false); + return await GroupCreateAsync(entity).ConfigureAwait(false); } public async Task RemoveAsync(SqlQueryEntity entity) diff --git a/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs b/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs new file mode 100644 index 0000000..2dd6109 --- /dev/null +++ b/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Seq.Api.Model.Workspaces; + +namespace Seq.Api.ResourceGroups +{ + public class WorkspacesResourceGroup : ApiResourceGroup + { + internal WorkspacesResourceGroup(ISeqConnection connection) + : base("Workspaces", connection) + { + } + + public async Task FindAsync(string id) + { + if (id == null) throw new ArgumentNullException(nameof(id)); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }).ConfigureAwait(false); + } + + public async Task> ListAsync(string ownerId = null, bool shared = false) + { + var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; + return await GroupListAsync("Items", parameters).ConfigureAwait(false); + } + + public async Task TemplateAsync() + { + return await GroupGetAsync("Template").ConfigureAwait(false); + } + + public async Task AddAsync(WorkspaceEntity entity) + { + return await GroupCreateAsync(entity).ConfigureAwait(false); + } + + public async Task RemoveAsync(WorkspaceEntity entity) + { + await Client.DeleteAsync(entity, "Self", entity).ConfigureAwait(false); + } + + public async Task UpdateAsync(WorkspaceEntity entity) + { + await Client.PutAsync(entity, "Self", entity).ConfigureAwait(false); + } + } +} diff --git a/src/Seq.Api/Seq.Api.csproj b/src/Seq.Api/Seq.Api.csproj index a1dddf3..9cef215 100644 --- a/src/Seq.Api/Seq.Api.csproj +++ b/src/Seq.Api/Seq.Api.csproj @@ -3,7 +3,7 @@ Client library for the Seq HTTP API. 5.0.0 Datalust;Contributors - netstandard1.3 + netstandard1.3;net46;netstandard2.0 $(NoWarn);CS1591 true true diff --git a/src/Seq.Api/SeqConnection.cs b/src/Seq.Api/SeqConnection.cs index 9789aa5..976ce13 100644 --- a/src/Seq.Api/SeqConnection.cs +++ b/src/Seq.Api/SeqConnection.cs @@ -52,10 +52,14 @@ public SeqConnection(string serverUrl, string apiKey = null, bool useDefaultCred public SignalsResourceGroup Signals => new SignalsResourceGroup(this); + public SqlQueriesResourceGroup SqlQueries => new SqlQueriesResourceGroup(this); + public UpdatesResourceGroup Updates => new UpdatesResourceGroup(this); public UsersResourceGroup Users => new UsersResourceGroup(this); + public WorkspacesResourceGroup Workspaces => new WorkspacesResourceGroup(this); + public async Task LoadResourceGroupAsync(string name) { return await _resourceGroups.GetOrAdd(name, ResourceGroupFactory).ConfigureAwait(false); diff --git a/test/Seq.Api.Tests/Seq.Api.Tests.csproj b/test/Seq.Api.Tests/Seq.Api.Tests.csproj index 397fd34..b7980fb 100644 --- a/test/Seq.Api.Tests/Seq.Api.Tests.csproj +++ b/test/Seq.Api.Tests/Seq.Api.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp1.0;net46 + net46;netcoreapp2.0 Seq.Api.Tests Seq.Api.Tests true From 4976ce0f75e63eef5ba88d15e60c7406b52fbb20 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 29 Oct 2018 16:18:03 +1000 Subject: [PATCH 2/2] Use the name cancellationToken for cancellation toke parameters in line with BCL conventions --- src/Seq.Api/Client/SeqApiClient.cs | 68 +++++++++--------- src/Seq.Api/Model/Signals/SignalEntity.cs | 1 - .../ResourceGroups/ApiKeysResourceGroup.cs | 24 +++---- .../ResourceGroups/ApiResourceGroup.cs | 70 +++++++++---------- .../AppInstancesResourceGroup.cs | 28 ++++---- .../ResourceGroups/AppsResourceGroup.cs | 28 ++++---- .../ResourceGroups/BackupsResourceGroup.cs | 12 ++-- .../ResourceGroups/DashboardsResourceGroup.cs | 24 +++---- .../ResourceGroups/DataResourceGroup.cs | 10 +-- .../DiagnosticsResourceGroup.cs | 12 ++-- .../ResourceGroups/EventsResourceGroup.cs | 39 ++++++----- .../ExpressionsResourceGroup.cs | 8 +-- .../ResourceGroups/FeedsResourceGroup.cs | 24 +++---- .../ResourceGroups/LicensesResourceGroup.cs | 20 +++--- .../ResourceGroups/PermalinksResourceGroup.cs | 24 +++---- .../RetentionPoliciesResourceGroup.cs | 24 +++---- .../ResourceGroups/SettingsResourceGroup.cs | 28 ++++---- .../ResourceGroups/SignalsResourceGroup.cs | 24 +++---- .../ResourceGroups/SqlQueriesResourceGroup.cs | 24 +++---- .../ResourceGroups/UpdatesResourceGroup.cs | 4 +- .../ResourceGroups/UsersResourceGroup.cs | 48 ++++++------- src/Seq.Api/Seq.Api.csproj | 1 + src/Seq.Api/SeqConnection.cs | 15 ++-- src/Seq.Api/Streams/ObservableStream.cs | 18 ++--- test/Seq.Api.Tests/Seq.Api.Tests.csproj | 7 -- 25 files changed, 294 insertions(+), 291 deletions(-) diff --git a/src/Seq.Api/Client/SeqApiClient.cs b/src/Seq.Api/Client/SeqApiClient.cs index fb097a6..d5256c4 100644 --- a/src/Seq.Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Client/SeqApiClient.cs @@ -60,95 +60,95 @@ public SeqApiClient(string serverUrl, string apiKey = null, bool useDefaultCrede public HttpClient HttpClient => _httpClient; - public Task GetRootAsync(CancellationToken token = default) + public Task GetRootAsync(CancellationToken cancellationToken = default) { - return HttpGetAsync("api", token); + return HttpGetAsync("api", cancellationToken); } - public Task GetAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken token = default) + public Task GetAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { var linkUri = ResolveLink(entity, link, parameters); - return HttpGetAsync(linkUri, token); + return HttpGetAsync(linkUri, cancellationToken); } - public Task GetStringAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken token = default) + public Task GetStringAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { var linkUri = ResolveLink(entity, link, parameters); - return HttpGetStringAsync(linkUri, token); + return HttpGetStringAsync(linkUri, cancellationToken); } - public Task> ListAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken token = default) + public Task> ListAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { var linkUri = ResolveLink(entity, link, parameters); - return HttpGetAsync>(linkUri, token); + return HttpGetAsync>(linkUri, cancellationToken); } - public async Task PostAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task PostAsync(ILinked entity, string link, TEntity content, IDictionary 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 PostAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task PostAsync(ILinked entity, string link, TEntity content, IDictionary 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(new JsonTextReader(new StreamReader(stream))); } - public async Task PostReadStringAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task PostReadStringAsync(ILinked entity, string link, TEntity content, IDictionary 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 PostReadStreamAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task PostReadStreamAsync(ILinked entity, string link, TEntity content, IDictionary 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(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task PutAsync(ILinked entity, string link, TEntity content, IDictionary 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(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task DeleteAsync(ILinked entity, string link, TEntity content, IDictionary 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 DeleteAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + public async Task DeleteAsync(ILinked entity, string link, TEntity content, IDictionary 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(new JsonTextReader(new StreamReader(stream))); } - public async Task> StreamAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken token = default) + public async Task> StreamAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { - return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize(new JsonTextReader(reader)), token); + return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize(new JsonTextReader(reader)), cancellationToken); } - public async Task> StreamTextAsync(ILinked entity, string link, IDictionary parameters = null, CancellationToken token = default) + public async Task> StreamTextAsync(ILinked entity, string link, IDictionary 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> WebSocketStreamAsync(ILinked entity, string link, IDictionary parameters, Func deserialize, CancellationToken token = default) + async Task> WebSocketStreamAsync(ILinked entity, string link, IDictionary parameters, Func deserialize, CancellationToken cancellationToken = default) { var linkUri = ResolveLink(entity, link, parameters); @@ -157,33 +157,33 @@ async Task> WebSocketStreamAsync(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(socket, deserialize); } - async Task HttpGetAsync(string url, CancellationToken token = default) + async Task HttpGetAsync(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(new JsonTextReader(new StreamReader(stream))); } - async Task HttpGetStringAsync(string url, CancellationToken token = default) + async Task 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 HttpSendAsync(HttpRequestMessage request, CancellationToken token = default) + async Task 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) diff --git a/src/Seq.Api/Model/Signals/SignalEntity.cs b/src/Seq.Api/Model/Signals/SignalEntity.cs index a8c5ed6..cab6ddd 100644 --- a/src/Seq.Api/Model/Signals/SignalEntity.cs +++ b/src/Seq.Api/Model/Signals/SignalEntity.cs @@ -21,7 +21,6 @@ public SignalEntity() public List TaggedProperties { get; set; } - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] // ReSharper disable once UnusedMember.Global [Obsolete("This member has been renamed `IsProtected` to better reflect its purpose.")] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] diff --git a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs index f46b805..0771ced 100644 --- a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs @@ -13,36 +13,36 @@ internal ApiKeysResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(string ownerId = null, CancellationToken token = default) + public async Task> ListAsync(string ownerId = null, CancellationToken cancellationToken = default) { var parameters = new Dictionary { { "ownerId", ownerId } }; - return await GroupListAsync("Items", parameters, token).ConfigureAwait(false); + return await GroupListAsync("Items", parameters, cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(ApiKeyEntity entity, CancellationToken token = default) + public async Task AddAsync(ApiKeyEntity entity, CancellationToken cancellationToken = default) { - return await GroupCreateAsync(entity, token: token).ConfigureAwait(false); + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(ApiKeyEntity entity, CancellationToken token = default) + public async Task RemoveAsync(ApiKeyEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(ApiKeyEntity entity, CancellationToken token = default) + public async Task UpdateAsync(ApiKeyEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs index 778f3a3..9c3ef4d 100644 --- a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs @@ -22,69 +22,69 @@ internal ApiResourceGroup(string name, ISeqConnection connection) protected SeqApiClient Client => _connection.Client; - protected Task LoadGroupAsync(CancellationToken token = default) + protected Task LoadGroupAsync(CancellationToken cancellationToken = default) { - return _connection.LoadResourceGroupAsync(_name, token); + return _connection.LoadResourceGroupAsync(_name, cancellationToken); } - protected async Task GroupGetAsync(string link, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupGetAsync(string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.GetAsync(group, link, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.GetAsync(group, link, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupGetStringAsync(string link, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupGetStringAsync(string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.GetStringAsync(group, link, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.GetStringAsync(group, link, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task> GroupListAsync(string link, IDictionary parameters = null, CancellationToken token = default) + protected async Task> GroupListAsync(string link, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.ListAsync(group, link, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.ListAsync(group, link, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupPostAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupPostAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - await Client.PostAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + await Client.PostAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupPostReadStringAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupPostReadStringAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.PostReadStringAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.PostReadStringAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupPostReadBytesAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupPostReadBytesAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.PostReadStreamAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.PostReadStreamAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupPostAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupPostAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.PostAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.PostAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupPutAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupPutAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - await Client.PutAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + await Client.PutAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupDeleteAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupDeleteAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - await Client.DeleteAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + await Client.DeleteAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } - protected async Task GroupDeleteAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken token = default) + protected async Task GroupDeleteAsync(string link, TEntity content, IDictionary parameters = null, CancellationToken cancellationToken = default) { - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.DeleteAsync(group, link, content, parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.DeleteAsync(group, link, content, parameters, cancellationToken).ConfigureAwait(false); } protected string GetLink(TEntity entity, string link, string orElse) where TEntity : ILinked @@ -93,7 +93,7 @@ protected string GetLink(TEntity entity, string link, string orElse) wh } protected async Task GroupCreateAsync(TEntity entity, - IDictionary parameters = null, CancellationToken token = default) + IDictionary parameters = null, CancellationToken cancellationToken = default) where TEntity : ILinked { ILinked resource; @@ -106,11 +106,11 @@ protected async Task GroupCreateAsync(TEntity ent } else { - resource = await LoadGroupAsync(token).ConfigureAwait(false); + resource = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); link = "Items"; } - return await Client.PostAsync(resource, link, entity, parameters, token).ConfigureAwait(false); + return await Client.PostAsync(resource, link, entity, parameters, cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs index 7672744..32327a9 100644 --- a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs @@ -13,49 +13,49 @@ internal AppInstancesResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(string appId, CancellationToken token = default) + public async Task TemplateAsync(string appId, CancellationToken cancellationToken = default) { if (appId == null) throw new ArgumentNullException(nameof(appId)); - return await GroupGetAsync("Template", new Dictionary { { "appId", appId } }, token).ConfigureAwait(false); + return await GroupGetAsync("Template", new Dictionary { { "appId", appId } }, cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(AppInstanceEntity entity, bool runOnExisting = false, CancellationToken token = default) + public async Task AddAsync(AppInstanceEntity entity, bool runOnExisting = false, CancellationToken cancellationToken = default) { if (entity == null) throw new ArgumentNullException(nameof(entity)); - return await Client.PostAsync(entity, "Create", entity, new Dictionary { { "runOnExisting", runOnExisting } }, token) + return await Client.PostAsync(entity, "Create", entity, new Dictionary { { "runOnExisting", runOnExisting } }, cancellationToken) .ConfigureAwait(false); } - public async Task RemoveAsync(AppInstanceEntity entity, CancellationToken token = default) + public async Task RemoveAsync(AppInstanceEntity entity, CancellationToken cancellationToken = default) { if (entity == null) throw new ArgumentNullException(nameof(entity)); - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(AppInstanceEntity entity, CancellationToken token = default) + public async Task UpdateAsync(AppInstanceEntity entity, CancellationToken cancellationToken = default) { if (entity == null) throw new ArgumentNullException(nameof(entity)); - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task InvokeAsync(AppInstanceEntity entity, string eventId, IReadOnlyDictionary settingOverrides, CancellationToken token = default) + public async Task InvokeAsync(AppInstanceEntity entity, string eventId, IReadOnlyDictionary settingOverrides, CancellationToken cancellationToken = default) { if (entity == null) throw new ArgumentNullException(nameof(entity)); if (eventId == null) throw new ArgumentNullException(nameof(eventId)); var postedSettings = settingOverrides ?? new Dictionary(); - await Client.PostAsync(entity, "Invoke", postedSettings, new Dictionary{{"eventId", eventId}}, token); + await Client.PostAsync(entity, "Invoke", postedSettings, new Dictionary{{"eventId", eventId}}, cancellationToken); } } } diff --git a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs index 437b96c..751d2ea 100644 --- a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs @@ -13,44 +13,44 @@ internal AppsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(AppEntity entity, CancellationToken token = default) + public async Task AddAsync(AppEntity entity, CancellationToken cancellationToken = default) { - return await Client.PostAsync(entity, "Create", entity, token: token).ConfigureAwait(false); + return await Client.PostAsync(entity, "Create", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(AppEntity entity, CancellationToken token = default) + public async Task RemoveAsync(AppEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(AppEntity entity, CancellationToken token = default) + public async Task UpdateAsync(AppEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task InstallPackageAsync(string feedId, string packageId, string version = null, CancellationToken token = default) + public async Task InstallPackageAsync(string feedId, string packageId, string version = null, CancellationToken cancellationToken = default) { if (feedId == null) throw new ArgumentNullException(nameof(feedId)); if (packageId == null) throw new ArgumentNullException(nameof(packageId)); var parameters = new Dictionary { { "feedId", feedId }, { "packageId", packageId } }; if (version != null) parameters.Add("version", version); - return await GroupPostAsync("InstallPackage", new object(), parameters, token).ConfigureAwait(false); + return await GroupPostAsync("InstallPackage", new object(), parameters, cancellationToken).ConfigureAwait(false); } public async Task UpdatePackageAsync(AppEntity entity, string version = null, bool force = false) diff --git a/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs b/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs index 2b54591..08398d4 100644 --- a/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs @@ -14,20 +14,20 @@ internal BackupsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task DownloadImmediateAsync(CancellationToken token = default) + public async Task DownloadImmediateAsync(CancellationToken cancellationToken = default) { - return await GroupPostReadBytesAsync("Immediate", new object(), token: token).ConfigureAwait(false); + return await GroupPostReadBytesAsync("Immediate", new object(), cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs index a9d3bc6..5b63e9b 100644 --- a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs @@ -13,36 +13,36 @@ internal DashboardsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken token = default) + public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken cancellationToken = default) { var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; - return await GroupListAsync("Items", parameters, token).ConfigureAwait(false); + return await GroupListAsync("Items", parameters, cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(DashboardEntity entity, CancellationToken token = default) + public async Task AddAsync(DashboardEntity entity, CancellationToken cancellationToken = default) { - return await GroupCreateAsync(entity, token: token).ConfigureAwait(false); + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(DashboardEntity entity, CancellationToken token = default) + public async Task RemoveAsync(DashboardEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(DashboardEntity entity, CancellationToken token = default) + public async Task UpdateAsync(DashboardEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/DataResourceGroup.cs b/src/Seq.Api/ResourceGroups/DataResourceGroup.cs index 398e130..c06f518 100644 --- a/src/Seq.Api/ResourceGroups/DataResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DataResourceGroup.cs @@ -24,6 +24,7 @@ internal DataResourceGroup(ISeqConnection connection) /// A constructed signal that may not appear on the server, for example, a that has been /// created but not saved, a signal from another server, or the modified representation of an entity already persisted. /// The query timeout; if not specified, the query will run until completion. + /// Token through which the operation can be cancelled. /// A structured result set. public async Task QueryAsync( string query, @@ -32,10 +33,10 @@ public async Task QueryAsync( SignalExpressionPart signal = null, SignalEntity unsavedSignal = null, TimeSpan? timeout = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, timeout, out var body, out var parameters); - return await GroupPostAsync("Query", body, parameters, token).ConfigureAwait(false); + return await GroupPostAsync("Query", body, parameters, cancellationToken).ConfigureAwait(false); } /// @@ -48,6 +49,7 @@ public async Task QueryAsync( /// A constructed signal that may not appear on the server, for example, a that has been /// created but not saved, a signal from another server, or the modified representation of an entity already persisted. /// The query timeout; if not specified, the query will run until completion. + /// Token through which the operation can be cancelled. /// A CSV result set. public async Task QueryCsvAsync( string query, @@ -56,11 +58,11 @@ public async Task QueryCsvAsync( SignalExpressionPart signal = null, SignalEntity unsavedSignal = null, TimeSpan? timeout = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { MakeParameters(query, rangeStartUtc, rangeEndUtc, signal, unsavedSignal, timeout, out var body, out var parameters); parameters.Add("format", "text/csv"); - return await GroupPostReadStringAsync("Query", body, parameters, token).ConfigureAwait(false); + return await GroupPostReadStringAsync("Query", body, parameters, cancellationToken).ConfigureAwait(false); } static void MakeParameters( diff --git a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs index 9844dfd..4ae8e7c 100644 --- a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs @@ -11,19 +11,19 @@ internal DiagnosticsResourceGroup(ISeqConnection connection) { } - public async Task GetServerMetricsAsync(CancellationToken token = default) + public async Task GetServerMetricsAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("ServerMetrics", token: token).ConfigureAwait(false); + return await GroupGetAsync("ServerMetrics", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task GetServerStatusAsync(CancellationToken token = default) + public async Task GetServerStatusAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("ServerStatus", token: token).ConfigureAwait(false); + return await GroupGetAsync("ServerStatus", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task GetIngestionLogAsync(CancellationToken token = default) + public async Task GetIngestionLogAsync(CancellationToken cancellationToken = default) { - return await GroupGetStringAsync("IngestionLog", token: token).ConfigureAwait(false); + return await GroupGetStringAsync("IngestionLog", cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs index db4d529..cca68e7 100644 --- a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs @@ -23,18 +23,19 @@ internal EventsResourceGroup(ISeqConnection connection) /// If the request is for a permalinked event, specifying the id of the permalink here will /// allow events that have otherwise been deleted to be found. The special value `"unknown"` provides backwards compatibility /// with versions prior to 5.0, which did not mark permalinks explicitly. + /// Token through which the operation can be cancelled. /// The event. public async Task FindAsync( string id, bool render = false, string permalinkId = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); var parameters = new Dictionary {{"id", id}}; - return await GroupGetAsync("Item", parameters, token).ConfigureAwait(false); + return await GroupGetAsync("Item", parameters, cancellationToken).ConfigureAwait(false); } /// @@ -56,6 +57,7 @@ public async Task FindAsync( /// If the request is for a permalinked event, specifying the id of the permalink here will /// allow events that have otherwise been deleted to be found. The special value `"unknown"` provides backwards compatibility /// with versions prior to 5.0, which did not mark permalinks explicitly. + /// Token through which the operation can be cancelled. /// The complete list of events, ordered from least to most recent. public async Task> ListAsync( SignalExpressionPart signal = null, @@ -68,7 +70,7 @@ public async Task> ListAsync( DateTime? toDateUtc = null, int? shortCircuitAfter = null, string permalinkId = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary { { "count", count } }; if (signal != null) { parameters.Add("signal", signal.ToString()); } @@ -86,7 +88,7 @@ public async Task> ListAsync( while (true) { - var resultSet = await GroupGetAsync("InSignal", parameters, token).ConfigureAwait(false); + var resultSet = await GroupGetAsync("InSignal", parameters, cancellationToken).ConfigureAwait(false); chunks.Add(resultSet.Events); remaining -= resultSet.Events.Count; @@ -128,6 +130,7 @@ public async Task> ListAsync( /// If the request is for a permalinked event, specifying the id of the permalink here will /// allow events that have otherwise been deleted to be found. The special value `"unknown"` provides backwards compatibility /// with versions prior to 5.0, which did not mark permalinks explicitly. + /// Token through which the operation can be cancelled. /// The complete list of events, ordered from least to most recent. public async Task InSignalAsync( SignalEntity unsavedSignal = null, @@ -141,7 +144,7 @@ public async Task InSignalAsync( DateTime? toDateUtc = null, int? shortCircuitAfter = null, string permalinkId = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary{{ "count", count }}; if (signal != null) { parameters.Add("signal", signal.ToString()); } @@ -155,7 +158,7 @@ public async Task InSignalAsync( if (permalinkId != null) { parameters.Add("permalinkId", permalinkId); } var body = unsavedSignal ?? new SignalEntity(); - return await GroupPostAsync("InSignal", body, parameters, token).ConfigureAwait(false); + return await GroupPostAsync("InSignal", body, parameters, cancellationToken).ConfigureAwait(false); } /// @@ -177,6 +180,7 @@ public async Task InSignalAsync( /// If the request is for a permalinked event, specifying the id of the permalink here will /// allow events that have otherwise been deleted to be found. The special value `"unknown"` provides backwards compatibility /// with versions prior to 5.0, which did not mark permalinks explicitly. + /// Token through which the operation can be cancelled. /// The complete list of events, ordered from least to most recent. public async Task InSignalAsync( SignalExpressionPart signal, @@ -189,7 +193,7 @@ public async Task InSignalAsync( DateTime? toDateUtc = null, int? shortCircuitAfter = null, string permalinkId = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { if (signal == null) throw new ArgumentNullException(nameof(signal)); @@ -207,7 +211,7 @@ public async Task InSignalAsync( if (shortCircuitAfter != null) { parameters.Add("shortCircuitAfter", shortCircuitAfter.Value); } if (permalinkId != null) { parameters.Add("permalinkId", permalinkId); } - return await GroupGetAsync("InSignal", parameters, token).ConfigureAwait(false); + return await GroupGetAsync("InSignal", parameters, cancellationToken).ConfigureAwait(false); } /// @@ -220,6 +224,7 @@ public async Task InSignalAsync( /// convert a "fuzzy" filter into a strict one the way the Seq UI does, use connection.Expressions.ToStrictAsync(). /// Earliest (inclusive) date/time from which to delete. /// Latest (exclusive) date/time from which to delete. + /// Token through which the operation can be cancelled. /// A result carrying the count of events deleted. public async Task DeleteInSignalAsync( SignalEntity unsavedSignal = null, @@ -227,7 +232,7 @@ public async Task DeleteInSignalAsync( string filter = null, DateTime? fromDateUtc = null, DateTime? toDateUtc = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary(); if (signal != null) { parameters.Add("signal", signal.ToString()); } @@ -236,7 +241,7 @@ public async Task DeleteInSignalAsync( if (toDateUtc != null) { parameters.Add("toDateUtc", toDateUtc.Value); } var body = unsavedSignal ?? new SignalEntity(); - return await GroupDeleteAsync("DeleteInSignal", body, parameters, token).ConfigureAwait(false); + return await GroupDeleteAsync("DeleteInSignal", body, parameters, cancellationToken).ConfigureAwait(false); } /// @@ -246,19 +251,20 @@ public async Task DeleteInSignalAsync( /// If provided, a signal expression describing the set of events that will be filtered for the result. /// A strict Seq filter expression to match (text expressions must be in double quotes). To /// convert a "fuzzy" filter into a strict one the way the Seq UI does, use connection.Expressions.ToStrictAsync(). + /// Token through which the operation can be cancelled. /// An observable that will stream events from the server to subscribers. Events will be buffered server-side until the first /// subscriber connects, ensure at least one subscription is made in order to avoid event loss. public async Task> StreamAsync( SignalExpressionPart signal = null, string filter = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary(); if (signal != null) { parameters.Add("signal", signal.ToString()); } if (filter != null) { parameters.Add("filter", filter); } - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.StreamAsync(group, "Stream", parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.StreamAsync(group, "Stream", parameters, cancellationToken).ConfigureAwait(false); } /// @@ -268,19 +274,20 @@ public async Task> StreamAsync( /// If provided, a signal expression describing the set of events that will be filtered for the result. /// A strict Seq filter expression to match (text expressions must be in double quotes). To /// convert a "fuzzy" filter into a strict one the way the Seq UI does, use connection.Expressions.ToStrictAsync(). + /// Token through which the operation can be cancelled. /// An observable that will stream events from the server to subscribers. Events will be buffered server-side until the first /// subscriber connects, ensure at least one subscription is made in order to avoid event loss. public async Task> StreamDocumentsAsync( SignalExpressionPart signal = null, string filter = null, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary(); if (signal != null) { parameters.Add("signal", signal.ToString()); } if (filter != null) { parameters.Add("filter", filter); } - var group = await LoadGroupAsync(token).ConfigureAwait(false); - return await Client.StreamTextAsync(group, "Stream", parameters, token).ConfigureAwait(false); + var group = await LoadGroupAsync(cancellationToken).ConfigureAwait(false); + return await Client.StreamTextAsync(group, "Stream", parameters, cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs b/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs index b39c23e..1088f8b 100644 --- a/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs @@ -12,20 +12,20 @@ internal ExpressionsResourceGroup(ISeqConnection connection) { } - public Task ToStrictAsync(string fuzzy, CancellationToken token = default) + public Task ToStrictAsync(string fuzzy, CancellationToken cancellationToken = default) { return GroupGetAsync("ToStrict", new Dictionary { {"fuzzy", fuzzy} - }, token); + }, cancellationToken); } - public Task ToSqlAsync(string fuzzy, CancellationToken token = default) + public Task ToSqlAsync(string fuzzy, CancellationToken cancellationToken = default) { return GroupGetAsync("ToSql", new Dictionary { {"fuzzy", fuzzy} - }, token); + }, cancellationToken); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs b/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs index 5aafeb5..3e0e1bb 100644 --- a/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs @@ -13,35 +13,35 @@ internal FeedsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(NuGetFeedEntity entity, CancellationToken token = default) + public async Task AddAsync(NuGetFeedEntity entity, CancellationToken cancellationToken = default) { - return await Client.PostAsync(entity, "Create", entity, token: token).ConfigureAwait(false); + return await Client.PostAsync(entity, "Create", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(NuGetFeedEntity entity, CancellationToken token = default) + public async Task RemoveAsync(NuGetFeedEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(NuGetFeedEntity entity, CancellationToken token = default) + public async Task UpdateAsync(NuGetFeedEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs b/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs index 302ac93..af40301 100644 --- a/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs @@ -13,30 +13,30 @@ internal LicensesResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task FindCurrentAsync(CancellationToken token = default) + public async Task FindCurrentAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Current", token: token).ConfigureAwait(false); + return await GroupGetAsync("Current", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(LicenseEntity entity, CancellationToken token = default) + public async Task UpdateAsync(LicenseEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task DowngradeAsync(CancellationToken token = default) + public async Task DowngradeAsync(CancellationToken cancellationToken = default) { - await GroupPostAsync("Downgrade", new object(), token: token).ConfigureAwait(false); + await GroupPostAsync("Downgrade", new object(), cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs b/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs index 3fc3fd5..a899911 100644 --- a/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs @@ -17,7 +17,7 @@ public async Task FindAsync( string id, bool includeEvent = false, bool renderEvent = false, - CancellationToken token = default) + CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); var parameters = new Dictionary @@ -26,13 +26,13 @@ public async Task FindAsync( {"includeEvent", includeEvent}, {"renderEvent", renderEvent} }; - return await GroupGetAsync("Item", parameters, token).ConfigureAwait(false); + return await GroupGetAsync("Item", parameters, cancellationToken).ConfigureAwait(false); } public async Task> ListAsync( bool includeEvent = false, bool renderEvent = false, - CancellationToken token = default) + CancellationToken cancellationToken = default) { var parameters = new Dictionary { @@ -40,27 +40,27 @@ public async Task> ListAsync( {"renderEvent", renderEvent} }; - return await GroupListAsync("Items", parameters, token).ConfigureAwait(false); + return await GroupListAsync("Items", parameters, cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(PermalinkEntity entity, CancellationToken token = default) + public async Task AddAsync(PermalinkEntity entity, CancellationToken cancellationToken = default) { - return await GroupCreateAsync(entity, token: token).ConfigureAwait(false); + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(PermalinkEntity entity, CancellationToken token = default) + public async Task RemoveAsync(PermalinkEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(PermalinkEntity entity, CancellationToken token = default) + public async Task UpdateAsync(PermalinkEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs b/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs index 430fad8..1e3ac18 100644 --- a/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs @@ -13,35 +13,35 @@ internal RetentionPoliciesResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(RetentionPolicyEntity entity, CancellationToken token = default) + public async Task AddAsync(RetentionPolicyEntity entity, CancellationToken cancellationToken = default) { - return await Client.PostAsync(entity, "Create", entity, token: token).ConfigureAwait(false); + return await Client.PostAsync(entity, "Create", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(RetentionPolicyEntity entity, CancellationToken token = default) + public async Task RemoveAsync(RetentionPolicyEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(RetentionPolicyEntity entity, CancellationToken token = default) + public async Task UpdateAsync(RetentionPolicyEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs index 53375e8..9968d1c 100644 --- a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs @@ -13,40 +13,40 @@ internal SettingsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task FindNamedAsync(SettingName name, CancellationToken token = default) + public async Task FindNamedAsync(SettingName name, CancellationToken cancellationToken = default) { - return await GroupGetAsync(name.ToString(), token: token).ConfigureAwait(false); + return await GroupGetAsync(name.ToString(), cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(SettingEntity entity, CancellationToken token = default) + public async Task AddAsync(SettingEntity entity, CancellationToken cancellationToken = default) { - return await Client.PostAsync(entity, "Create", entity, token: token).ConfigureAwait(false); + return await Client.PostAsync(entity, "Create", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(SettingEntity entity, CancellationToken token = default) + public async Task RemoveAsync(SettingEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(SettingEntity entity, CancellationToken token = default) + public async Task UpdateAsync(SettingEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task GetInternalErrorReportingAsync() diff --git a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs index c210678..594143c 100644 --- a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs @@ -13,36 +13,36 @@ internal SignalsResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken token) + public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken cancellationToken = default) { var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; - return await GroupListAsync("Items", parameters, token: token).ConfigureAwait(false); + return await GroupListAsync("Items", parameters, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(SignalEntity entity, CancellationToken token = default) + public async Task AddAsync(SignalEntity entity, CancellationToken cancellationToken = default) { - return await GroupCreateAsync(entity, token: token).ConfigureAwait(false); + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(SignalEntity entity, CancellationToken token = default) + public async Task RemoveAsync(SignalEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(SignalEntity entity, CancellationToken token = default) + public async Task UpdateAsync(SignalEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs index 1f36192..7d5aac3 100644 --- a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs @@ -13,36 +13,36 @@ internal SqlQueriesResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken token) + public async Task> ListAsync(string ownerId = null, bool shared = false, CancellationToken cancellationToken = default) { var parameters = new Dictionary { { "ownerId", ownerId }, { "shared", shared } }; - return await GroupListAsync("Items", parameters, token: token).ConfigureAwait(false); + return await GroupListAsync("Items", parameters, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(SqlQueryEntity entity, CancellationToken token = default) + public async Task AddAsync(SqlQueryEntity entity, CancellationToken cancellationToken = default) { - return await GroupCreateAsync(entity, token: token).ConfigureAwait(false); + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(SqlQueryEntity entity, CancellationToken token = default) + public async Task RemoveAsync(SqlQueryEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(SqlQueryEntity entity, CancellationToken token = default) + public async Task UpdateAsync(SqlQueryEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs b/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs index 61149aa..953d136 100644 --- a/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs @@ -12,9 +12,9 @@ internal UpdatesResourceGroup(ISeqConnection connection) { } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs index e885083..2f94120 100644 --- a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs @@ -15,69 +15,69 @@ internal UsersResourceGroup(ISeqConnection connection) { } - public async Task FindAsync(string id, CancellationToken token = default) + public async Task FindAsync(string id, CancellationToken cancellationToken = default) { if (id == null) throw new ArgumentNullException(nameof(id)); - return await GroupGetAsync("Item", new Dictionary { { "id", id } }, token).ConfigureAwait(false); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); } - public async Task FindCurrentAsync(CancellationToken token = default) + public async Task FindCurrentAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Current", token: token).ConfigureAwait(false); + return await GroupGetAsync("Current", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task> ListAsync(CancellationToken token = default) + public async Task> ListAsync(CancellationToken cancellationToken = default) { - return await GroupListAsync("Items", token: token).ConfigureAwait(false); + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task TemplateAsync(CancellationToken token = default) + public async Task TemplateAsync(CancellationToken cancellationToken = default) { - return await GroupGetAsync("Template", token: token).ConfigureAwait(false); + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task AddAsync(UserEntity entity, CancellationToken token = default) + public async Task AddAsync(UserEntity entity, CancellationToken cancellationToken = default) { - return await Client.PostAsync(entity, "Create", entity, token: token).ConfigureAwait(false); + return await Client.PostAsync(entity, "Create", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task RemoveAsync(UserEntity entity, CancellationToken token = default) + public async Task RemoveAsync(UserEntity entity, CancellationToken cancellationToken = default) { - await Client.DeleteAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task UpdateAsync(UserEntity entity, CancellationToken token = default) + public async Task UpdateAsync(UserEntity entity, CancellationToken cancellationToken = default) { - await Client.PutAsync(entity, "Self", entity, token: token).ConfigureAwait(false); + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task LoginAsync(string username, string password, CancellationToken token = default) + public async Task LoginAsync(string username, string password, CancellationToken cancellationToken = default) { if (username == null) throw new ArgumentNullException(nameof(username)); if (password == null) throw new ArgumentNullException(nameof(password)); var credentials = new CredentialsPart {Username = username, Password = password}; - return await GroupPostAsync("Login", credentials, token: token).ConfigureAwait(false); + return await GroupPostAsync("Login", credentials, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task LogoutAsync(CancellationToken token = default) + public async Task LogoutAsync(CancellationToken cancellationToken = default) { - await GroupPostAsync("Logout", new object(), token: token).ConfigureAwait(false); + await GroupPostAsync("Logout", new object(), cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task GetSearchHistoryAsync(UserEntity entity, CancellationToken token = default) + public async Task GetSearchHistoryAsync(UserEntity entity, CancellationToken cancellationToken = default) { - return await Client.GetAsync(entity, "SearchHistory", token: token).ConfigureAwait(false); + return await Client.GetAsync(entity, "SearchHistory", cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task LoginWindowsIntegratedAsync(CancellationToken token = default) + public async Task LoginWindowsIntegratedAsync(CancellationToken cancellationToken = default) { - var providers = await GroupGetAsync("AuthenticationProviders", token: token).ConfigureAwait(false); + var providers = await GroupGetAsync("AuthenticationProviders", cancellationToken: cancellationToken).ConfigureAwait(false); var provider = providers.Providers.SingleOrDefault(p => p.Name == "Integrated Windows Authentication"); if (provider == null) throw new SeqApiException("The Integrated Windows Authentication provider is not available.", null); - var response = await Client.HttpClient.GetAsync(provider.Url, token).ConfigureAwait(false); + var response = await Client.HttpClient.GetAsync(provider.Url, cancellationToken).ConfigureAwait(false); response.EnsureSuccessStatusCode(); - return await FindCurrentAsync(token).ConfigureAwait(false); + return await FindCurrentAsync(cancellationToken).ConfigureAwait(false); } } } diff --git a/src/Seq.Api/Seq.Api.csproj b/src/Seq.Api/Seq.Api.csproj index 455e49a..e8b24b0 100644 --- a/src/Seq.Api/Seq.Api.csproj +++ b/src/Seq.Api/Seq.Api.csproj @@ -15,6 +15,7 @@ https://github.com/datalust/seq-api http://www.apache.org/licenses/LICENSE-2.0 Seq.Api + 7.1 diff --git a/src/Seq.Api/SeqConnection.cs b/src/Seq.Api/SeqConnection.cs index bcf5fb9..6d3e722 100644 --- a/src/Seq.Api/SeqConnection.cs +++ b/src/Seq.Api/SeqConnection.cs @@ -11,16 +11,15 @@ namespace Seq.Api { public class SeqConnection : ISeqConnection { - readonly SeqApiClient _client; readonly ConcurrentDictionary> _resourceGroups = new ConcurrentDictionary>(); readonly Lazy> _root; public SeqConnection(string serverUrl, string apiKey = null, bool useDefaultCredentials = true) { if (serverUrl == null) throw new ArgumentNullException(nameof(serverUrl)); - _client = new SeqApiClient(serverUrl, apiKey, useDefaultCredentials); + Client = new SeqApiClient(serverUrl, apiKey, useDefaultCredentials); - _root = new Lazy>(() => _client.GetRootAsync()); + _root = new Lazy>(() => Client.GetRootAsync()); } public ApiKeysResourceGroup ApiKeys => new ApiKeysResourceGroup(this); @@ -61,16 +60,16 @@ public SeqConnection(string serverUrl, string apiKey = null, bool useDefaultCred public WorkspacesResourceGroup Workspaces => new WorkspacesResourceGroup(this); - public async Task LoadResourceGroupAsync(string name, CancellationToken token = default) + public async Task LoadResourceGroupAsync(string name, CancellationToken cancellationToken = default) { - return await _resourceGroups.GetOrAdd(name, s => ResourceGroupFactory(s, token)).ConfigureAwait(false); + return await _resourceGroups.GetOrAdd(name, s => ResourceGroupFactory(s, cancellationToken)).ConfigureAwait(false); } - async Task ResourceGroupFactory(string name, CancellationToken token = default) + async Task ResourceGroupFactory(string name, CancellationToken cancellationToken = default) { - return await _client.GetAsync(await _root.Value, name + "Resources", token: token).ConfigureAwait(false); + return await Client.GetAsync(await _root.Value, name + "Resources", cancellationToken: cancellationToken).ConfigureAwait(false); } - public SeqApiClient Client => _client; + public SeqApiClient Client { get; } } } diff --git a/src/Seq.Api/Streams/ObservableStream.cs b/src/Seq.Api/Streams/ObservableStream.cs index 983c65c..0ddc419 100644 --- a/src/Seq.Api/Streams/ObservableStream.cs +++ b/src/Seq.Api/Streams/ObservableStream.cs @@ -38,11 +38,8 @@ public sealed partial class ObservableStream : IObservable, IDisposable internal ObservableStream(ClientWebSocket socket, Func deserialize) { - if (socket == null) throw new ArgumentNullException(nameof(socket)); - if (deserialize == null) throw new ArgumentNullException(nameof(deserialize)); - - _deserialize = deserialize; - _socket = socket; + _deserialize = deserialize ?? throw new ArgumentNullException(nameof(deserialize)); + _socket = socket ?? throw new ArgumentNullException(nameof(socket)); } public IDisposable Subscribe(IObserver observer) @@ -179,7 +176,7 @@ void End() OnError(exceptions); } - void OnError(IList exceptions) + static void OnError(IEnumerable exceptions) { // This will hit TaskScheduler.UnobservedTaskException throw new AggregateException("At least one observer failed to accept the event", exceptions); @@ -205,7 +202,10 @@ public void Dispose() } } } - catch { } + catch + { + // Don't mask exceptions by throwing here during unwinding + } if (_run != null) { @@ -213,7 +213,9 @@ public void Dispose() { _run.ConfigureAwait(false).GetAwaiter().GetResult(); } - catch (TaskCanceledException) { } + catch (TaskCanceledException) + { + } } _socket.Dispose(); diff --git a/test/Seq.Api.Tests/Seq.Api.Tests.csproj b/test/Seq.Api.Tests/Seq.Api.Tests.csproj index 9445e64..b573d26 100644 --- a/test/Seq.Api.Tests/Seq.Api.Tests.csproj +++ b/test/Seq.Api.Tests/Seq.Api.Tests.csproj @@ -2,14 +2,7 @@ net46;netcoreapp2.0 - Seq.Api.Tests - Seq.Api.Tests true - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - 1.0.4 - false - false - false