-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from datalust/dev
2024.3.0 Release
- Loading branch information
Showing
13 changed files
with
251 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Seq.Api.Model.Indexes | ||
{ | ||
/// <summary> | ||
/// An index over the event stream. May be one of several types discriminated by <see cref="IndexedEntityType"/>. | ||
/// </summary> | ||
public class IndexEntity: Entity | ||
{ | ||
/// <summary> | ||
/// The `Id` of the associated entity (Signal, Alert or Expression index). | ||
/// </summary> | ||
public string IndexedEntityId { get; set; } | ||
|
||
/// <summary> | ||
/// The type of this index. | ||
/// </summary> | ||
public IndexedEntityType IndexedEntityType { get; set; } | ||
|
||
/// <summary> | ||
/// The owner / creator of this index. | ||
/// </summary> | ||
public string OwnerUsername { get; set; } | ||
|
||
/// <summary> | ||
/// The name of this index. May not be applicable to all index types. | ||
/// </summary> | ||
public string Label { get; set; } | ||
|
||
/// <summary> | ||
/// The storage used by this index. | ||
/// </summary> | ||
public ulong StorageBytes { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Seq.Api.Model.Indexes | ||
{ | ||
/// <summary> | ||
/// The type of the index. | ||
/// </summary> | ||
public enum IndexedEntityType | ||
{ | ||
/// <summary> | ||
/// A predicate index for a signal expression. | ||
/// </summary> | ||
Signal, | ||
|
||
/// <summary> | ||
/// An expression index. | ||
/// </summary> | ||
ExpressionIndex, | ||
|
||
/// <summary> | ||
/// A predicate index for an alert filter. | ||
/// </summary> | ||
Alert, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Seq.Api.Model.Indexing | ||
{ | ||
/// <summary> | ||
/// An index based on an expression. | ||
/// </summary> | ||
public class ExpressionIndexEntity: Entity | ||
{ | ||
/// <summary> | ||
/// The expression to be indexed. | ||
/// </summary> | ||
public string Expression { get; set; } | ||
|
||
/// <summary> | ||
/// A user-provided description of the index. | ||
/// </summary> | ||
public string Description { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/Seq.Api/ResourceGroups/ExpressionIndexesResourceGroup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Seq.Api.Model; | ||
using Seq.Api.Model.Indexing; | ||
|
||
namespace Seq.Api.ResourceGroups | ||
{ | ||
/// <summary> | ||
/// Perform operations on expression indexes. | ||
/// </summary> | ||
public class ExpressionIndexesResourceGroup: ApiResourceGroup | ||
{ | ||
internal ExpressionIndexesResourceGroup(ILoadResourceGroup connection) : base("ExpressionIndexes", connection) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve expression indexes. | ||
/// </summary> | ||
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>A list containing matching expression indexes.</returns> | ||
public async Task<List<ExpressionIndexEntity>> ListAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return await GroupListAsync<ExpressionIndexEntity>("Items", cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve the expression index with the given id; throws if the entity does not exist. | ||
/// </summary> | ||
/// <param name="id">The id of the expression index.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>The expression index.</returns> | ||
public async Task<ExpressionIndexEntity> FindAsync(string id, CancellationToken cancellationToken = default) | ||
{ | ||
if (id == null) throw new ArgumentNullException(nameof(id)); | ||
return await GroupGetAsync<ExpressionIndexEntity>("Item", new Dictionary<string, object> { { "id", id } }, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Construct an expression index with server defaults pre-initialized. | ||
/// </summary> | ||
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>The unsaved expression index.</returns> | ||
public async Task<ExpressionIndexEntity> TemplateAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return await GroupGetAsync<ExpressionIndexEntity>("Template", cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Add a new expression index. | ||
/// </summary> | ||
/// <param name="entity">The expression index to add.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>The expression index, with server-allocated properties such as <see cref="Entity.Id"/> initialized.</returns> | ||
public async Task<ExpressionIndexEntity> AddAsync(ExpressionIndexEntity entity, CancellationToken cancellationToken = default) | ||
{ | ||
return await GroupCreateAsync<ExpressionIndexEntity, ExpressionIndexEntity>(entity, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Remove an existing expression index. | ||
/// </summary> | ||
/// <param name="entity">The expression index to remove.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>A task indicating completion.</returns> | ||
public async Task RemoveAsync(ExpressionIndexEntity entity, CancellationToken cancellationToken = default) | ||
{ | ||
await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Seq.Api.Model.Alerting; | ||
using Seq.Api.Model.Indexes; | ||
using Seq.Api.Model.Indexing; | ||
using Seq.Api.Model.Signals; | ||
|
||
namespace Seq.Api.ResourceGroups | ||
{ | ||
/// <summary> | ||
/// Statistics about indexes. | ||
/// </summary> | ||
public class IndexesResourceGroup : ApiResourceGroup | ||
{ | ||
internal IndexesResourceGroup(ILoadResourceGroup connection) | ||
: base("Indexes", connection) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve the index with the given id; throws if the entity does not exist. | ||
/// </summary> | ||
/// <param name="id">The id of the index.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>The index.</returns> | ||
public async Task<IndexEntity> FindAsync(string id, CancellationToken cancellationToken = default) | ||
{ | ||
if (id == null) throw new ArgumentNullException(nameof(id)); | ||
return await GroupGetAsync<IndexEntity>("Item", new Dictionary<string, object> { { "id", id } }, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve statistics on all indexes. | ||
/// </summary> | ||
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>A list containing matching expression indexes.</returns> | ||
public async Task<List<IndexEntity>> ListAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return await GroupListAsync<IndexEntity>("Items", cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Suppress an index. Not all index types can be suppressed: signal indexes do support suppression, in the case | ||
/// of which the <see cref="SignalEntity.IsIndexSuppressed"/> flag will be set to <c langword="false"/>. | ||
/// Expression indexes can only be suppressed by deleting the associated <see cref="ExpressionIndexEntity"/> | ||
/// and alert indexes can only be suppressed by deleting the corresponding <see cref="AlertEntity"/>. | ||
/// </summary> | ||
/// <param name="entity">The index to suppress.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> | ||
/// <returns>A task indicating completion.</returns> | ||
public async Task SuppressAsync(IndexEntity entity, CancellationToken cancellationToken = default) | ||
{ | ||
await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters