diff --git a/src/Seq.Api/Model/Alerting/AlertActivityPart.cs b/src/Seq.Api/Model/Alerting/AlertActivityPart.cs new file mode 100644 index 0000000..f869be3 --- /dev/null +++ b/src/Seq.Api/Model/Alerting/AlertActivityPart.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +// ReSharper disable UnusedAutoPropertyAccessor.Global + +namespace Seq.Api.Model.Alerting +{ + /// + /// A summary of recent activity on an alert. + /// + + public class AlertActivityPart + { + /// + /// When the last check for the alert was performed. + /// + public DateTime? LastCheck { get; set; } + + /// + /// Whether or not the last check triggered any notifications. + /// + public bool LastCheckTriggered { get; set; } + + /// + /// Any failures that prevented the last check from completing successfully. + /// These failures indicate a problem with the alert itself, not with the + /// data being monitored. + /// + /// A value of null indicates the last check succeeded. + /// + public List LastCheckFailures { get; set; } + + /// + /// When the alert may be checked again after being triggered. + /// + public DateTime? SuppressedUntil { get; set; } + + /// + /// The most recent occurrences of the alert that triggered notifications. + /// + public List RecentOccurrences { get; set; } = new List(); + + /// + /// The number of times this alert has been triggered since its creation. + /// + public int TotalOccurrences { get; set; } + } +} diff --git a/src/Seq.Api/Model/Alerting/AlertEntity.cs b/src/Seq.Api/Model/Alerting/AlertEntity.cs new file mode 100644 index 0000000..5dc1745 --- /dev/null +++ b/src/Seq.Api/Model/Alerting/AlertEntity.cs @@ -0,0 +1,111 @@ +// Copyright Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using Seq.Api.Model.LogEvents; +using Seq.Api.Model.Security; +using Seq.Api.Model.Shared; +using Seq.Api.Model.Signals; + +namespace Seq.Api.Model.Alerting +{ + /// + /// An alert. + /// + public class AlertEntity : Entity + { + /// + /// A friendly, human-readable title for the alert. + /// + public string Title { get; set; } + + /// + /// An optional long-form description of the alert. + /// + public string Description { get; set; } + + /// + /// The user id of the user who owns the alert; if null, the alert is shared. + /// + public string OwnerId { get; set; } + + /// + /// If true, the alert can only be modified by users with the permission. + /// + public bool IsProtected { get; set; } + + /// + /// If true, the alert will not be processed, and notifications will not be sent. + /// + public bool IsDisabled { get; set; } + + /// + /// An optional limiting the data source that triggers the alert. + /// + public SignalExpressionPart SignalExpression { get; set; } + + /// + /// An optional where clause limiting the data source that triggers the alert. + /// + public string Where { get; set; } + + /// + /// Additional groupings applied to the data source. The time() grouping is controlled by the alerting + /// infrastructure according to the property and should not be specified here. + /// + public List GroupBy { get; set; } = new List(); + + /// + /// The interval over which the alert condition will be measured. + /// + public TimeSpan TimeGrouping { get; set; } + + /// + /// The individual measurements that will be tested by the alert condition. + /// + public List Select { get; set; } = new List(); + + /// + /// The alert condition. This is a having clause over the grouped results + /// computed by the alert query. + /// + public string Having { get; set; } + + /// + /// A level indicating the severity or priority of the alert. + /// + public LogEventLevel NotificationLevel { get; set; } + + /// + /// Additional properties that will be attached to the generated notification. + /// + public List NotificationProperties { get; set; } = new List(); + + /// + /// The channels that will receive notifications when the alert is triggered. + /// + public List NotificationChannels { get; set; } = new List(); + + /// + /// The time after the alert is triggered within which no further notifications will be sent. + /// + public TimeSpan SuppressionTime { get; set; } + + /// + /// Any recent activity for the alert. + /// + public AlertActivityPart Activity { get; set; } + } +} diff --git a/src/Seq.Api/Model/Alerting/AlertNotificationPart.cs b/src/Seq.Api/Model/Alerting/AlertNotificationPart.cs new file mode 100644 index 0000000..2145ce9 --- /dev/null +++ b/src/Seq.Api/Model/Alerting/AlertNotificationPart.cs @@ -0,0 +1,16 @@ +using Seq.Api.Model.AppInstances; + +namespace Seq.Api.Model.Alerting +{ + /// + /// A record of the that was notified of an alert occurrence. + /// + public class AlertNotificationPart + { + /// + /// The that was notified. + /// This id is a historical record, so it may be for app instance that no longer exists. + /// + public string HistoricalAppInstanceId { get; set; } + } +} diff --git a/src/Seq.Api/Model/Alerting/AlertOccurrencePart.cs b/src/Seq.Api/Model/Alerting/AlertOccurrencePart.cs new file mode 100644 index 0000000..c5fed8b --- /dev/null +++ b/src/Seq.Api/Model/Alerting/AlertOccurrencePart.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using Seq.Api.Model.AppInstances; +using Seq.Api.Model.LogEvents; +using Seq.Api.Model.Shared; + +namespace Seq.Api.Model.Alerting +{ + /// + /// An occurrence of an alert that triggered notifications. + /// + public class AlertOccurrencePart + { + /// + /// The time when the alert was checked and triggered. + /// + public DateTime DetectedAt { get; set; } + + /// + /// The time grouping that triggered the alert. + /// + public DateTimeRange DetectedOverRange { get; set; } + + /// + /// The level of notifications sent for this instance. + /// + public LogEventLevel NotificationLevel { get; set; } + + /// + /// The NotificationChannelParts that were alerted. + /// + public List Notifications { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/src/Seq.Api/Model/Monitoring/AlertStateEntity.cs b/src/Seq.Api/Model/Alerting/AlertStateEntity.cs similarity index 74% rename from src/Seq.Api/Model/Monitoring/AlertStateEntity.cs rename to src/Seq.Api/Model/Alerting/AlertStateEntity.cs index 27ba7f6..b788d9f 100644 --- a/src/Seq.Api/Model/Monitoring/AlertStateEntity.cs +++ b/src/Seq.Api/Model/Alerting/AlertStateEntity.cs @@ -13,8 +13,9 @@ // limitations under the License. using System; +using System.Collections.Generic; -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Alerting { /// /// Describes the state of an active alert. @@ -31,30 +32,15 @@ public class AlertStateEntity : Entity /// public string Title { get; set; } - /// - /// The title of the chart to which the alert is attached. - /// - public string ChartTitle { get; set; } - - /// - /// The title of the dashboards in which the alert is set. - /// - public string DashboardTitle { get; set; } - /// /// The user id of the user who owns the alert; if null, the alert is shared. /// public string OwnerId { get; set; } /// - /// The notification level associated with the alert. - /// - public string Level { get; set; } - - /// - /// The id of an app instance that will receive notifications when the alert is triggered. + /// The ids of app instances that receive notifications when the alert is triggered. /// - public string NotificationAppInstanceId { get; set; } + public List NotificationAppInstanceIds { get; set; } /// /// The time at which the alert was last checked. Not preserved across server restarts. diff --git a/src/Seq.Api/Model/Alerting/NotificationChannelPart.cs b/src/Seq.Api/Model/Alerting/NotificationChannelPart.cs new file mode 100644 index 0000000..37988dc --- /dev/null +++ b/src/Seq.Api/Model/Alerting/NotificationChannelPart.cs @@ -0,0 +1,63 @@ +// Copyright Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using Seq.Api.Model.AppInstances; + +namespace Seq.Api.Model.Alerting +{ + /// + /// A notification channel belonging to an alert. + /// + public class NotificationChannelPart + { + /// + /// A system-assigned identifier for the channel. This is used when updating channels to carry over unchanged + /// values of sensitive settings, which are not round-tripped to the client for editing. When creating a + /// new channel, this should be null. + /// + public string Id { get; set; } + + /// + /// The message used for the title or subject of the notification. If not specified, a default message based + /// on the alert title will be used. + /// + public string NotificationMessage { get; set; } + + /// + /// If true, notifications will include a sample of the events that contributed to the triggering of + /// the alert. + /// + public bool IncludeContributingEvents { get; set; } + + /// + /// When is true, the maximum number of contributing events to + /// include in the notification. Note that this value is an upper limit, and server resource constraints may + /// prevent all contributing events from being included even below this limit. + /// + public uint? IncludedContributingEventLimit { get; set; } + + /// + /// The id of an that will receive notifications from the alert. + /// + public string NotificationAppInstanceId { get; set; } + + /// + /// Additional properties that will be used to configure the notification app when triggered + /// by the alert. + /// + public Dictionary NotificationAppSettingOverrides { get; set; } = + new Dictionary(); + } +} diff --git a/src/Seq.Api/Model/Cluster/ClusterNodeEntity.cs b/src/Seq.Api/Model/Cluster/ClusterNodeEntity.cs new file mode 100644 index 0000000..f8056e5 --- /dev/null +++ b/src/Seq.Api/Model/Cluster/ClusterNodeEntity.cs @@ -0,0 +1,53 @@ +// Copyright Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Seq.Api.Model.Cluster +{ + /// + /// Describes a node in a Seq cluster. + /// + public class ClusterNodeEntity : Entity + { + /// + /// The role the node is currently acting in. + /// + public NodeRole Role { get; set; } + + /// + /// An informational name associated with the node. + /// + public string Name { get; set; } + + /// + /// An informational representation of the storage generation committed to the node. + /// + public string Generation { get; set; } + + /// + /// Whether any writes have occurred since the node's last completed sync. + /// + public bool? IsUpToDate { get; set; } + + /// + /// The time since the node's last completed sync operation. + /// + public double? MillisecondsSinceLastSync { get; set; } + + /// + /// An informational description of the node's current state, or null if no additional + /// information about the node is available. + /// + public string StateDescription { get; set; } + } +} diff --git a/src/Seq.Api/Model/Inputs/InputAppliedPropertyPart.cs b/src/Seq.Api/Model/Cluster/NodeRole.cs similarity index 60% rename from src/Seq.Api/Model/Inputs/InputAppliedPropertyPart.cs rename to src/Seq.Api/Model/Cluster/NodeRole.cs index 6f4d3d4..0e753e2 100644 --- a/src/Seq.Api/Model/Inputs/InputAppliedPropertyPart.cs +++ b/src/Seq.Api/Model/Cluster/NodeRole.cs @@ -1,4 +1,4 @@ -// Copyright © Datalust and contributors. +// Copyright Datalust and contributors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,22 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Inputs +namespace Seq.Api.Model.Cluster { /// - /// A name/value property attached to events ingested through an API key. + /// The role a node is acting in within a cluster of connected Seq instances. /// - // Note, this duplicates EventPropertyPart. - public class InputAppliedPropertyPart + public enum NodeRole { /// - /// The property name (required). + /// The node is not part of a cluster. /// - public string Name { get; set; } - + Standalone, + + /// + /// The node is a replica, following the state of a leader node. + /// + Follower, + /// - /// The property value, or null. + /// The node is a replication leader. /// - public object Value { get; set; } + Leader } } \ No newline at end of file diff --git a/src/Seq.Api/Model/Monitoring/ChartDisplayStylePart.cs b/src/Seq.Api/Model/Dashboarding/ChartDisplayStylePart.cs similarity index 96% rename from src/Seq.Api/Model/Monitoring/ChartDisplayStylePart.cs rename to src/Seq.Api/Model/Dashboarding/ChartDisplayStylePart.cs index 7f6dbf4..0b79d4d 100644 --- a/src/Seq.Api/Model/Monitoring/ChartDisplayStylePart.cs +++ b/src/Seq.Api/Model/Dashboarding/ChartDisplayStylePart.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// How a chart will be displayed on a dashboard. diff --git a/src/Seq.Api/Model/Monitoring/ChartPart.cs b/src/Seq.Api/Model/Dashboarding/ChartPart.cs similarity index 97% rename from src/Seq.Api/Model/Monitoring/ChartPart.cs rename to src/Seq.Api/Model/Dashboarding/ChartPart.cs index 6e8c092..afbc8aa 100644 --- a/src/Seq.Api/Model/Monitoring/ChartPart.cs +++ b/src/Seq.Api/Model/Dashboarding/ChartPart.cs @@ -15,7 +15,7 @@ using System.Collections.Generic; using Seq.Api.Model.Signals; -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// A chart that appears on a dashboard. diff --git a/src/Seq.Api/Model/Monitoring/ChartQueryPart.cs b/src/Seq.Api/Model/Dashboarding/ChartQueryPart.cs similarity index 89% rename from src/Seq.Api/Model/Monitoring/ChartQueryPart.cs rename to src/Seq.Api/Model/Dashboarding/ChartQueryPart.cs index 069bf86..2f84f5b 100644 --- a/src/Seq.Api/Model/Monitoring/ChartQueryPart.cs +++ b/src/Seq.Api/Model/Dashboarding/ChartQueryPart.cs @@ -13,9 +13,10 @@ // limitations under the License. using System.Collections.Generic; +using Seq.Api.Model.Shared; using Seq.Api.Model.Signals; -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// A query within a chart. @@ -30,7 +31,7 @@ public class ChartQueryPart /// /// Individual measurements included in the query. These are effectively projected columns. /// - public List Measurements { get; set; } = new List(); + public List Measurements { get; set; } = new List(); /// /// An optional filtering where clause limiting the data that contributes to the chart. @@ -52,11 +53,6 @@ public class ChartQueryPart /// public MeasurementDisplayStylePart DisplayStyle { get; set; } = new MeasurementDisplayStylePart(); - /// - /// Alerts attached to the chart. - /// - public List Alerts { get; set; } = new List(); - /// /// A filter that limits which groups will be displayed on the chart. Not supported by all chart types. /// diff --git a/src/Seq.Api/Model/Monitoring/DashboardEntity.cs b/src/Seq.Api/Model/Dashboarding/DashboardEntity.cs similarity index 97% rename from src/Seq.Api/Model/Monitoring/DashboardEntity.cs rename to src/Seq.Api/Model/Dashboarding/DashboardEntity.cs index 9a49d10..edac684 100644 --- a/src/Seq.Api/Model/Monitoring/DashboardEntity.cs +++ b/src/Seq.Api/Model/Dashboarding/DashboardEntity.cs @@ -16,7 +16,7 @@ using Seq.Api.Model.Security; using Seq.Api.Model.Signals; -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// A dashboard. diff --git a/src/Seq.Api/Model/Monitoring/MeasurementDisplayPalette.cs b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayPalette.cs similarity index 97% rename from src/Seq.Api/Model/Monitoring/MeasurementDisplayPalette.cs rename to src/Seq.Api/Model/Dashboarding/MeasurementDisplayPalette.cs index 401c3f8..77c4f16 100644 --- a/src/Seq.Api/Model/Monitoring/MeasurementDisplayPalette.cs +++ b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayPalette.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// The color palette used for displaying a measurement on a chart. diff --git a/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayStylePart.cs similarity index 98% rename from src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs rename to src/Seq.Api/Model/Dashboarding/MeasurementDisplayStylePart.cs index 9cfd9c6..48f703c 100644 --- a/src/Seq.Api/Model/Monitoring/MeasurementDisplayStylePart.cs +++ b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayStylePart.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// How a measurement will be displayed within a chart. diff --git a/src/Seq.Api/Model/Monitoring/MeasurementDisplayType.cs b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayType.cs similarity index 97% rename from src/Seq.Api/Model/Monitoring/MeasurementDisplayType.cs rename to src/Seq.Api/Model/Dashboarding/MeasurementDisplayType.cs index 61e6b57..6a83aeb 100644 --- a/src/Seq.Api/Model/Monitoring/MeasurementDisplayType.cs +++ b/src/Seq.Api/Model/Dashboarding/MeasurementDisplayType.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Dashboarding { /// /// The method used to visually represent a measurement. diff --git a/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs b/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs index 6bb1079..09928ca 100644 --- a/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs +++ b/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs @@ -52,7 +52,7 @@ public ServerMetricsEntity() /// /// Bytes of free space remaining on the disk used for event storage. /// - public long EventStoreDiskRemainingBytes { get; set; } + public long? EventStoreDiskRemainingBytes { get; set; } /// /// The number of events that arrived at the ingestion endpoint in the past minute. diff --git a/src/Seq.Api/Model/Events/EventEntity.cs b/src/Seq.Api/Model/Events/EventEntity.cs index 48181d6..fb38bad 100644 --- a/src/Seq.Api/Model/Events/EventEntity.cs +++ b/src/Seq.Api/Model/Events/EventEntity.cs @@ -14,6 +14,9 @@ using System.Collections.Generic; using Newtonsoft.Json; +using Seq.Api.Model.Shared; + +// ReSharper disable UnusedAutoPropertyAccessor.Global namespace Seq.Api.Model.Events { diff --git a/src/Seq.Api/Model/Inputs/InputSettingsPart.cs b/src/Seq.Api/Model/Inputs/InputSettingsPart.cs index 540b566..cd396c8 100644 --- a/src/Seq.Api/Model/Inputs/InputSettingsPart.cs +++ b/src/Seq.Api/Model/Inputs/InputSettingsPart.cs @@ -28,7 +28,7 @@ public class InputSettingsPart /// Properties that will be automatically added to all events ingested using the key. These will override any properties with /// the same names already present on the event. /// - public List AppliedProperties { get; set; } = new List(); + public List AppliedProperties { get; set; } = new List(); /// /// A filter that selects events to ingest. If null, all events received using the key will be ingested. @@ -48,4 +48,4 @@ public class InputSettingsPart /// public bool UseServerTimestamps { get; set; } } -} \ No newline at end of file +} diff --git a/src/Seq.Api/Model/License/LicenseEntity.cs b/src/Seq.Api/Model/License/LicenseEntity.cs index 0bdb65e..e9ddd3c 100644 --- a/src/Seq.Api/Model/License/LicenseEntity.cs +++ b/src/Seq.Api/Model/License/LicenseEntity.cs @@ -67,5 +67,10 @@ public class LicenseEntity : Entity /// update the license when the subscription is renewed or tier changed. /// public bool AutomaticallyRefresh { get; set; } + + /// + /// If true, the license supports running Seq in a DR configuration. + /// + public bool IncludesDisasterRecovery { get; set; } } } diff --git a/src/Seq.Api/Model/Monitoring/AlertPart.cs b/src/Seq.Api/Model/Monitoring/AlertPart.cs deleted file mode 100644 index 678311d..0000000 --- a/src/Seq.Api/Model/Monitoring/AlertPart.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright © Datalust and contributors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Seq.Api.Model.LogEvents; -using System; -using System.Collections.Generic; -using Seq.Api.Model.AppInstances; - -namespace Seq.Api.Model.Monitoring -{ - /// - /// An alert attached to a dashboard chart. - /// - public class AlertPart - { - Dictionary _notificationAppSettingOverrides = new Dictionary(); - - /// - /// The unique id assigned to the alert. - /// - public string Id { get; set; } - - /// - /// The alert condition. This is effectively a having clause over the grouped results - /// computed by the . - /// - public string Condition { get; set; } - - /// - /// A friendly, human-readable description of the alert. - /// - public string Title { get; set; } - - /// - /// The interval within which the alert condition will be measured. - /// - public TimeSpan MeasurementWindow { get; set; } - - /// - /// The time allowed for events to reach the server before being included in alert calculations. - /// This is relative to the current server clock. - /// - public TimeSpan StabilizationWindow { get; set; } = TimeSpan.FromSeconds(30); - - /// - /// The time after the alert files within which no further notifications will be sent for the - /// alert. - /// - public TimeSpan SuppressionTime { get; set; } - - /// - /// An informational level that suggests the importance of the alert. - /// - public LogEventLevel Level { get; set; } = LogEventLevel.Warning; - - /// - /// The id of an that will receive notifications from the alert. - /// - public string NotificationAppInstanceId { get; set; } - - /// - /// Additional properties that will be used to configure the notification app when triggered - /// by the alert. - /// - public Dictionary NotificationAppSettingOverrides - { - get => _notificationAppSettingOverrides; - set => _notificationAppSettingOverrides = value ?? new Dictionary(); - } - } -} diff --git a/src/Seq.Api/Model/Retention/RetentionPolicyEntity.cs b/src/Seq.Api/Model/Retention/RetentionPolicyEntity.cs index ef8a587..380f850 100644 --- a/src/Seq.Api/Model/Retention/RetentionPolicyEntity.cs +++ b/src/Seq.Api/Model/Retention/RetentionPolicyEntity.cs @@ -13,6 +13,7 @@ // limitations under the License. using System; +using Newtonsoft.Json; using Seq.Api.Model.Signals; namespace Seq.Api.Model.Retention @@ -38,7 +39,8 @@ public class RetentionPolicyEntity : Entity /// /// Obsolete. /// - [Obsolete("Replaced by RemovedSignalExpression.")] + [Obsolete("Replaced by RemovedSignalExpression."), + JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string SignalId { get; set; } } } diff --git a/src/Seq.Api/Model/Root/RootEntity.cs b/src/Seq.Api/Model/Root/RootEntity.cs index ebaacf7..8dcb8da 100644 --- a/src/Seq.Api/Model/Root/RootEntity.cs +++ b/src/Seq.Api/Model/Root/RootEntity.cs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Collections.Generic; +using Newtonsoft.Json; + namespace Seq.Api.Model.Root { /// @@ -41,6 +44,13 @@ public RootEntity() /// An informational name identifying the instance. /// public string InstanceName { get; set; } + + /// + /// A list of non-default features enabled on this server. Normally, null unless + /// an administrator has explicitly opted-into alpha or beta-level features. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public List EnabledFeatures { get; set; } /// /// Links to resources exposed by the API. diff --git a/src/Seq.Api/Model/Events/EventPropertyPart.cs b/src/Seq.Api/Model/Shared/EventPropertyPart.cs similarity index 91% rename from src/Seq.Api/Model/Events/EventPropertyPart.cs rename to src/Seq.Api/Model/Shared/EventPropertyPart.cs index 1c54054..15b71da 100644 --- a/src/Seq.Api/Model/Events/EventPropertyPart.cs +++ b/src/Seq.Api/Model/Shared/EventPropertyPart.cs @@ -1,4 +1,4 @@ -// Copyright © Datalust and contributors. +// Copyright © Datalust and contributors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,12 +14,13 @@ using System; -namespace Seq.Api.Model.Events +// ReSharper disable MemberCanBePrivate.Global + +namespace Seq.Api.Model.Shared { /// /// A name/value property associated with an event. /// - // Note, this duplicates InputAppliedPropertyPart. public class EventPropertyPart { /// diff --git a/src/Seq.Api/Model/Shared/GroupingColumnPart.cs b/src/Seq.Api/Model/Shared/GroupingColumnPart.cs new file mode 100644 index 0000000..043b54d --- /dev/null +++ b/src/Seq.Api/Model/Shared/GroupingColumnPart.cs @@ -0,0 +1,23 @@ +namespace Seq.Api.Model.Shared +{ + /// + /// A column appearing within a group-by clause. + /// + public class GroupingColumnPart + { + /// + /// The expression (selected column) that computes the value of the measurement. + /// + public string Value { get; set; } + + /// + /// An optional label for the measurement (effectively the right-hand size of an as clause). + /// + public string Label { get; set; } + + /// + /// If true, the grouping is case-insensitive; otherwise, the grouping will be case-sensitive. + /// + public bool IsCaseInsensitive { get; set; } + } +} diff --git a/src/Seq.Api/Model/Monitoring/MeasurementPart.cs b/src/Seq.Api/Model/Shared/MeasurementPart.cs similarity index 89% rename from src/Seq.Api/Model/Monitoring/MeasurementPart.cs rename to src/Seq.Api/Model/Shared/MeasurementPart.cs index 97edb6a..3171196 100644 --- a/src/Seq.Api/Model/Monitoring/MeasurementPart.cs +++ b/src/Seq.Api/Model/Shared/MeasurementPart.cs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Monitoring +namespace Seq.Api.Model.Shared { /// - /// A measurement that contributes to a chart. + /// A column with value and label. /// - public class MeasurementPart + public class ColumnPart { /// /// The expression (selected column) that computes the value of the measurement. diff --git a/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs b/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs index 9b5d666..e3c635f 100644 --- a/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs +++ b/src/Seq.Api/Model/Workspaces/WorkspaceContentPart.cs @@ -13,7 +13,7 @@ // limitations under the License. using System.Collections.Generic; -using Seq.Api.Model.Monitoring; +using Seq.Api.Model.Dashboarding; using Seq.Api.Model.Signals; using Seq.Api.Model.SqlQueries; diff --git a/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs b/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs index 887d3f7..23bd0cf 100644 --- a/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs +++ b/src/Seq.Api/Model/Workspaces/WorkspaceEntity.cs @@ -29,7 +29,7 @@ public class WorkspaceEntity : Entity public string Title { get; set; } /// - /// A long-form description of the workspace. + /// An optional long-form description of the workspace. /// public string Description { get; set; } diff --git a/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs b/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs index 8b8fa17..e530ed0 100644 --- a/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs @@ -16,7 +16,8 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Seq.Api.Model.Monitoring; +using Seq.Api.Model.Alerting; +using Seq.Api.Model.Dashboarding; namespace Seq.Api.ResourceGroups { @@ -25,7 +26,7 @@ namespace Seq.Api.ResourceGroups /// public class AlertStateResourceGroup : ApiResourceGroup { - internal AlertStateResourceGroup(ISeqConnection connection) + internal AlertStateResourceGroup(ILoadResourceGroup connection) : base("AlertState", connection) { } diff --git a/src/Seq.Api/ResourceGroups/AlertsResourceGroup.cs b/src/Seq.Api/ResourceGroups/AlertsResourceGroup.cs new file mode 100644 index 0000000..6961422 --- /dev/null +++ b/src/Seq.Api/ResourceGroups/AlertsResourceGroup.cs @@ -0,0 +1,104 @@ +// Copyright Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Seq.Api.Model; +using Seq.Api.Model.Alerting; +using Seq.Api.Model.Users; + +namespace Seq.Api.ResourceGroups +{ + /// + /// Create and manage alerts being monitored by the server. + /// + public class AlertsResourceGroup : ApiResourceGroup + { + internal AlertsResourceGroup(ILoadResourceGroup connection) + : base("Alerts", connection) + { + } + + /// + /// Retrieve the dashboard with the given id; throws if the entity does not exist. + /// + /// The id of the dashboard. + /// A allowing the operation to be canceled. + /// The dashboard. + 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: cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieve alerts. + /// + /// If the id of a is provided, only alerts owned by them will be included in the result; if + /// not specified, personal alerts for all owners will be listed. + /// If true, shared alerts will be included in the result. + /// allowing the operation to be canceled. + /// A list containing matching alerts. + 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, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Construct a alert with server defaults pre-initialized. + /// + /// allowing the operation to be canceled. + /// The unsaved alert. + public async Task TemplateAsync(CancellationToken cancellationToken = default) + { + return await GroupGetAsync("Template", cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Add a new alert. + /// + /// The alert to add. + /// A allowing the operation to be canceled. + /// The alert, with server-allocated properties such as initialized. + public async Task AddAsync(AlertEntity entity, CancellationToken cancellationToken = default) + { + return await GroupCreateAsync(entity, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Remove an existing alert. + /// + /// The alert to remove. + /// A allowing the operation to be canceled. + /// A task indicating completion. + public async Task RemoveAsync(AlertEntity entity, CancellationToken cancellationToken = default) + { + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an existing alert. + /// + /// The alert to update. + /// A allowing the operation to be canceled. + /// A task indicating completion. + public async Task UpdateAsync(AlertEntity entity, CancellationToken cancellationToken = default) + { + await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs index 883ec1d..ad98137 100644 --- a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs @@ -30,7 +30,7 @@ namespace Seq.Api.ResourceGroups /// public class ApiKeysResourceGroup : ApiResourceGroup { - internal ApiKeysResourceGroup(ISeqConnection connection) + internal ApiKeysResourceGroup(ILoadResourceGroup connection) : base("ApiKeys", connection) { } diff --git a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs index a515dd6..4347f64 100644 --- a/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiResourceGroup.cs @@ -30,9 +30,14 @@ namespace Seq.Api.ResourceGroups public abstract class ApiResourceGroup { readonly string _name; - readonly ISeqConnection _connection; + readonly ILoadResourceGroup _connection; - internal ApiResourceGroup(string name, ISeqConnection connection) + /// + /// Construct an for the named + /// + /// + /// + protected ApiResourceGroup(string name, ILoadResourceGroup connection) { _name = name; _connection = connection; diff --git a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs index 0ee6737..2a12737 100644 --- a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs @@ -29,7 +29,7 @@ namespace Seq.Api.ResourceGroups /// public class AppInstancesResourceGroup : ApiResourceGroup { - internal AppInstancesResourceGroup(ISeqConnection connection) + internal AppInstancesResourceGroup(ILoadResourceGroup connection) : base("AppInstances", connection) { } diff --git a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs index 9b9d76d..727c555 100644 --- a/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppsResourceGroup.cs @@ -26,7 +26,7 @@ namespace Seq.Api.ResourceGroups /// public class AppsResourceGroup : ApiResourceGroup { - internal AppsResourceGroup(ISeqConnection connection) + internal AppsResourceGroup(ILoadResourceGroup connection) : base("Apps", connection) { } diff --git a/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs b/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs index 984a651..cfc16f4 100644 --- a/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/BackupsResourceGroup.cs @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class BackupsResourceGroup : ApiResourceGroup { - internal BackupsResourceGroup(ISeqConnection connection) + internal BackupsResourceGroup(ILoadResourceGroup connection) : base("Backups", connection) { } diff --git a/src/Seq.Api/ResourceGroups/ClusterNodesResourceGroup.cs b/src/Seq.Api/ResourceGroups/ClusterNodesResourceGroup.cs new file mode 100644 index 0000000..b32ed4a --- /dev/null +++ b/src/Seq.Api/ResourceGroups/ClusterNodesResourceGroup.cs @@ -0,0 +1,70 @@ +// Copyright Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Seq.Api.Model.Cluster; + +namespace Seq.Api.ResourceGroups +{ + /// + /// Perform operations on a Seq cluster. + /// + /// Seq clustering initially supports a two-node replication + /// topology. + public class ClusterNodesResourceGroup : ApiResourceGroup + { + internal ClusterNodesResourceGroup(ILoadResourceGroup connection) + : base("ClusterNodes", connection) + { + } + + /// + /// Retrieve the cluster node with the given id; throws if the entity does not exist. + /// + /// The id of the cluster node. + /// A allowing the operation to be canceled. + /// The cluster node. + 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); + } + + /// + /// Retrieve all known cluster nodes. + /// + /// allowing the operation to be canceled. + /// A list containing matching dashboards. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + return await GroupListAsync("Items", null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Manually demote a leader node. The operation will proceed asynchronously; the state of the node can be checked + /// using (the node will disappear when demotion has finished). + /// + /// The leader node. + /// A allowing the operation to be canceled. + /// If successfully failed over, the node must be restarted before it can join the cluster as follower. + public async Task DemoteAsync(ClusterNodeEntity leader, CancellationToken cancellationToken = default) + { + if (leader == null) throw new ArgumentNullException(nameof(leader)); + await Client.PostAsync(leader, "Demote", new object(), cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs index 4a673cf..18d71be 100644 --- a/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DashboardsResourceGroup.cs @@ -17,7 +17,7 @@ using System.Threading; using System.Threading.Tasks; using Seq.Api.Model; -using Seq.Api.Model.Monitoring; +using Seq.Api.Model.Dashboarding; using Seq.Api.Model.Users; namespace Seq.Api.ResourceGroups @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class DashboardsResourceGroup : ApiResourceGroup { - internal DashboardsResourceGroup(ISeqConnection connection) + internal DashboardsResourceGroup(ILoadResourceGroup connection) : base("Dashboards", connection) { } diff --git a/src/Seq.Api/ResourceGroups/DataResourceGroup.cs b/src/Seq.Api/ResourceGroups/DataResourceGroup.cs index 33b2690..d8cc53a 100644 --- a/src/Seq.Api/ResourceGroups/DataResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DataResourceGroup.cs @@ -26,7 +26,7 @@ namespace Seq.Api.ResourceGroups /// public class DataResourceGroup : ApiResourceGroup { - internal DataResourceGroup(ISeqConnection connection) + internal DataResourceGroup(ILoadResourceGroup connection) : base("Data", connection) { } diff --git a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs index 644242c..0566efe 100644 --- a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs @@ -18,7 +18,6 @@ using System.Threading.Tasks; using Seq.Api.Model.Diagnostics; using Seq.Api.Model.Diagnostics.Storage; -using Seq.Api.Model.Inputs; // ReSharper disable UnusedMember.Global @@ -29,7 +28,7 @@ namespace Seq.Api.ResourceGroups /// public class DiagnosticsResourceGroup : ApiResourceGroup { - internal DiagnosticsResourceGroup(ISeqConnection connection) + internal DiagnosticsResourceGroup(ILoadResourceGroup connection) : base("Diagnostics", connection) { } diff --git a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs index 01b4259..96ee76f 100644 --- a/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/EventsResourceGroup.cs @@ -29,7 +29,7 @@ namespace Seq.Api.ResourceGroups /// public class EventsResourceGroup : ApiResourceGroup { - internal EventsResourceGroup(ISeqConnection connection) + internal EventsResourceGroup(ILoadResourceGroup connection) : base("Events", connection) { } diff --git a/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs b/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs index 50043c0..7474a74 100644 --- a/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ExpressionsResourceGroup.cs @@ -24,7 +24,7 @@ namespace Seq.Api.ResourceGroups /// public class ExpressionsResourceGroup : ApiResourceGroup { - internal ExpressionsResourceGroup(ISeqConnection connection) + internal ExpressionsResourceGroup(ILoadResourceGroup connection) : base("Expressions", connection) { } diff --git a/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs b/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs index 121ce97..11e369a 100644 --- a/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/FeedsResourceGroup.cs @@ -26,7 +26,7 @@ namespace Seq.Api.ResourceGroups /// public class FeedsResourceGroup : ApiResourceGroup { - internal FeedsResourceGroup(ISeqConnection connection) + internal FeedsResourceGroup(ILoadResourceGroup connection) : base("Feeds", connection) { } diff --git a/src/Seq.Api/ResourceGroups/ISeqConnection.cs b/src/Seq.Api/ResourceGroups/ILoadResourceGroup.cs similarity index 51% rename from src/Seq.Api/ResourceGroups/ISeqConnection.cs rename to src/Seq.Api/ResourceGroups/ILoadResourceGroup.cs index ae29134..a3ac76a 100644 --- a/src/Seq.Api/ResourceGroups/ISeqConnection.cs +++ b/src/Seq.Api/ResourceGroups/ILoadResourceGroup.cs @@ -19,9 +19,25 @@ namespace Seq.Api.ResourceGroups { - interface ISeqConnection + /// + /// The contract between resource groups and the implementing connection type. + /// + /// This interface is an implementation detail that should not be relied on by + /// application-level consumers. + public interface ILoadResourceGroup { + /// + /// Load the resource group with the given . + /// + /// The resource group name. The name is the simple form, for example, + /// "Dashboards". + /// A allowing the operation to be canceled. + /// The requested resource group. Task LoadResourceGroupAsync(string name, CancellationToken cancellationToken = default); + + /// + /// The underlying Seq API client. + /// SeqApiClient Client { get; } } } diff --git a/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs b/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs index 9bb8e17..a26bbb4 100644 --- a/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/LicensesResourceGroup.cs @@ -25,7 +25,7 @@ namespace Seq.Api.ResourceGroups /// public class LicensesResourceGroup : ApiResourceGroup { - internal LicensesResourceGroup(ISeqConnection connection) + internal LicensesResourceGroup(ILoadResourceGroup connection) : base("Licenses", connection) { } diff --git a/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs b/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs index 166821d..9d7faa8 100644 --- a/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/PermalinksResourceGroup.cs @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class PermalinksResourceGroup : ApiResourceGroup { - internal PermalinksResourceGroup(ISeqConnection connection) + internal PermalinksResourceGroup(ILoadResourceGroup connection) : base("Permalinks", connection) { } diff --git a/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs b/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs index 9c3d712..9007ae8 100644 --- a/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/RetentionPoliciesResourceGroup.cs @@ -26,7 +26,7 @@ namespace Seq.Api.ResourceGroups /// public class RetentionPoliciesResourceGroup : ApiResourceGroup { - internal RetentionPoliciesResourceGroup(ISeqConnection connection) + internal RetentionPoliciesResourceGroup(ILoadResourceGroup connection) : base("RetentionPolicies", connection) { } diff --git a/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs b/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs index bdc61ca..728f0f2 100644 --- a/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/RolesResourceGroup.cs @@ -25,7 +25,7 @@ namespace Seq.Api.ResourceGroups /// public class RolesResourceGroup : ApiResourceGroup { - internal RolesResourceGroup(ISeqConnection connection) + internal RolesResourceGroup(ILoadResourceGroup connection) : base("Roles", connection) { } diff --git a/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs b/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs index 0327347..fb0c217 100644 --- a/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs @@ -16,7 +16,8 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Seq.Api.Model.Monitoring; +using Seq.Api.Model.Alerting; +using Seq.Api.Model.Dashboarding; using Seq.Api.Model.Tasks; namespace Seq.Api.ResourceGroups @@ -26,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class RunningTasksResourceGroup : ApiResourceGroup { - internal RunningTasksResourceGroup (ISeqConnection connection) + internal RunningTasksResourceGroup (ILoadResourceGroup connection) : base("RunningTasks", connection) { } diff --git a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs index 8146b97..7d4b0e2 100644 --- a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs @@ -25,7 +25,7 @@ namespace Seq.Api.ResourceGroups /// public class SettingsResourceGroup : ApiResourceGroup { - internal SettingsResourceGroup(ISeqConnection connection) + internal SettingsResourceGroup(ILoadResourceGroup connection) : base("Settings", connection) { } diff --git a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs index c1fb65c..d74c680 100644 --- a/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class SignalsResourceGroup : ApiResourceGroup { - internal SignalsResourceGroup(ISeqConnection connection) + internal SignalsResourceGroup(ILoadResourceGroup connection) : base("Signals", connection) { } diff --git a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs index 7ce7cde..83414ed 100644 --- a/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SqlQueriesResourceGroup.cs @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class SqlQueriesResourceGroup : ApiResourceGroup { - internal SqlQueriesResourceGroup(ISeqConnection connection) + internal SqlQueriesResourceGroup(ILoadResourceGroup connection) : base("SqlQueries", connection) { } diff --git a/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs b/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs index d5146b2..840d215 100644 --- a/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/UpdatesResourceGroup.cs @@ -24,7 +24,7 @@ namespace Seq.Api.ResourceGroups /// public class UpdatesResourceGroup : ApiResourceGroup { - internal UpdatesResourceGroup(ISeqConnection connection) + internal UpdatesResourceGroup(ILoadResourceGroup connection) : base("Updates", connection) { } diff --git a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs index c99dae0..5b95402 100644 --- a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs @@ -28,7 +28,7 @@ namespace Seq.Api.ResourceGroups /// public class UsersResourceGroup : ApiResourceGroup { - internal UsersResourceGroup(ISeqConnection connection) + internal UsersResourceGroup(ILoadResourceGroup connection) : base("Users", connection) { } diff --git a/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs b/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs index 89b4ce0..665d714 100644 --- a/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/WorkspacesResourceGroup.cs @@ -27,7 +27,7 @@ namespace Seq.Api.ResourceGroups /// public class WorkspacesResourceGroup : ApiResourceGroup { - internal WorkspacesResourceGroup(ISeqConnection connection) + internal WorkspacesResourceGroup(ILoadResourceGroup connection) : base("Workspaces", connection) { } diff --git a/src/Seq.Api/Seq.Api.csproj b/src/Seq.Api/Seq.Api.csproj index 83d448f..285f5fa 100644 --- a/src/Seq.Api/Seq.Api.csproj +++ b/src/Seq.Api/Seq.Api.csproj @@ -1,7 +1,7 @@ Client library for the Seq HTTP API. - 2021.2.1 + 2020.3.0 Datalust;Contributors netstandard2.0 true @@ -13,9 +13,13 @@ Apache-2.0 8 + - + + + + diff --git a/src/Seq.Api/SeqConnection.cs b/src/Seq.Api/SeqConnection.cs index 1710ff3..63703ce 100644 --- a/src/Seq.Api/SeqConnection.cs +++ b/src/Seq.Api/SeqConnection.cs @@ -29,7 +29,7 @@ namespace Seq.Api /// /// Exposes high-level (typed) interactions with the Seq API through various resource groups. /// - public class SeqConnection : ISeqConnection, IDisposable + public class SeqConnection : ILoadResourceGroup, IDisposable { readonly object _sync = new object(); readonly Dictionary> _resourceGroups = new Dictionary>(); @@ -74,13 +74,18 @@ public void Dispose() /// the HTTP API. /// public SeqApiClient Client { get; } + + /// + /// Create and manage alerts. + /// + public AlertsResourceGroup Alerts => new AlertsResourceGroup(this); /// /// List and administratively remove active alerts. To create/edit/remove alerts in normal /// circumstances, use . /// public AlertStateResourceGroup AlertState => new AlertStateResourceGroup(this); - + /// /// Perform operations on API keys. /// @@ -100,7 +105,12 @@ public void Dispose() /// Perform operations on backups. /// public BackupsResourceGroup Backups => new BackupsResourceGroup(this); - + + /// + /// Perform operations on the Seq cluster. + /// + public ClusterNodesResourceGroup ClusterNodes => new ClusterNodesResourceGroup(this); + /// /// Perform operations on dashboards. /// @@ -228,8 +238,8 @@ async Task ConnectAsync(bool throwOnFailure) throw new SeqApiException($"Could not connect to the Seq API endpoint: {(int)statusCode}/{statusCode}.", statusCode); } - - async Task ISeqConnection.LoadResourceGroupAsync(string name, CancellationToken cancellationToken) + + async Task ILoadResourceGroup.LoadResourceGroupAsync(string name, CancellationToken cancellationToken) { Task loadRoot; lock (_sync)