You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/src/NzbDrone.Core/HealthCheck/HealthCheck.cs

57 lines
1.5 KiB

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.HealthCheck
{
public class HealthCheck : ModelBase
{
private static readonly Regex CleanFragmentRegex = new ("[^a-z ]", RegexOptions.Compiled);
public Type Source { get; set; }
public HealthCheckResult Type { get; set; }
public string Message { get; set; }
public HttpUri WikiUrl { get; set; }
public List<int> IndexerIds { get; set; } = new ();
public HealthCheck()
{
}
public HealthCheck(Type source)
{
Source = source;
Type = HealthCheckResult.Ok;
}
public HealthCheck(Type source, HealthCheckResult type, string message, string wikiFragment = null)
{
Source = source;
Type = type;
Message = message;
WikiUrl = MakeWikiUrl(wikiFragment ?? MakeWikiFragment(message));
}
private static string MakeWikiFragment(string message)
{
return "#" + CleanFragmentRegex.Replace(message.ToLower(), string.Empty).Replace(' ', '-');
}
private static HttpUri MakeWikiUrl(string fragment)
{
return new HttpUri("https://wiki.servarr.com/prowlarr/system#") + new HttpUri(fragment);
}
}
public enum HealthCheckResult
{
Ok = 0,
Notice = 1,
Warning = 2,
Error = 3
}
}