diff --git a/src/Seq.Api/Model/Security/WellKnownRole.cs b/src/Seq.Api/Model/Security/WellKnownRole.cs index 19678c6..c3f56f4 100644 --- a/src/Seq.Api/Model/Security/WellKnownRole.cs +++ b/src/Seq.Api/Model/Security/WellKnownRole.cs @@ -1,5 +1,8 @@ -namespace Seq.Api.Model.Security +using System; + +namespace Seq.Api.Model.Security { + [Obsolete("It's recommended that new code look up roles by name in `SeqConnection.Roles`.")] public static class WellKnownRole { public const string AdministratorRoleId = "role-administrator"; diff --git a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs index c8b736c..7f21346 100644 --- a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs @@ -247,7 +247,7 @@ public async Task DeleteInSignalAsync( } /// - /// Connect to the live event stream. Dispose the resulting stream to disconnect. + /// Connect to the live event stream, read as strongly-typed objects. Dispose the resulting stream to disconnect. /// /// The type into which events should be deserialized. /// If provided, a signal expression describing the set of events that will be filtered for the result. @@ -256,6 +256,8 @@ public async Task DeleteInSignalAsync( /// 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. + /// See the Seq ingestion + /// docs for event schema information. public async Task> StreamAsync( SignalExpressionPart signal = null, string filter = null, @@ -270,8 +272,7 @@ public async Task> StreamAsync( } /// - /// Retrieve a list of events that match a set of conditions. The complete result is buffered into memory, - /// so if a large result set is expected, use InSignalAsync() and lastReadEventId to page the results. + /// Connect to the live event stream, read as raw JSON documents. Dispose the resulting stream to disconnect. /// /// 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 @@ -279,6 +280,8 @@ public async Task> StreamAsync( /// 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. + /// See the Seq ingestion + /// docs for event schema information. public async Task> StreamDocumentsAsync( SignalExpressionPart signal = null, string filter = null, diff --git a/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs b/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs new file mode 100644 index 0000000..396b6ee --- /dev/null +++ b/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs @@ -0,0 +1,55 @@ +// Copyright 2019 Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; +using Seq.Api.Model.Security; + +namespace Seq.Api.ResourceGroups +{ + /// + /// Perform operations on user roles. + /// + public class RolesResourceGroup : ApiResourceGroup + { + internal RolesResourceGroup(ISeqConnection connection) + : base("Roles", connection) + { + } + + /// + /// Find a role given its id. + /// + /// The id of a role to find. + /// allowing the operation to be canceled. + /// The matching role. + 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 } }, cancellationToken).ConfigureAwait(false); + } + + /// + /// List all roles. + /// + /// allowing the operation to be canceled. + /// A list containing all roles available on the server. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + return await GroupListAsync("Items", cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/Seq.Api/SeqConnection.cs b/src/Seq.Api/SeqConnection.cs index 900968b..046e82a 100644 --- a/src/Seq.Api/SeqConnection.cs +++ b/src/Seq.Api/SeqConnection.cs @@ -141,6 +141,11 @@ public SeqConnection(string serverUrl, string apiKey = null, bool useDefaultCred /// public UsersResourceGroup Users => new UsersResourceGroup(this); + /// + /// Perform operations on user roles. + /// + public RolesResourceGroup Roles => new RolesResourceGroup(this); + /// /// Perform operations on workspaces. ///