forked from MediaBrowser/Emby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted to removal of paper-fab
- Loading branch information
Showing
21 changed files
with
669 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using MediaBrowser.Controller.Health; | ||
using MediaBrowser.Controller.News; | ||
using MediaBrowser.Model.News; | ||
using MediaBrowser.Model.Querying; | ||
using ServiceStack; | ||
|
||
namespace MediaBrowser.Api | ||
{ | ||
[Route("/Health/Messages", "GET", Summary = "Gets the health messages.")] | ||
public class GetHealthMessages : IReturn<QueryResult<HealthMessage>> | ||
{ | ||
/// <summary> | ||
/// Restricts to warnings and problems. | ||
/// </summary> | ||
/// <value>The warnings filter flag.</value> | ||
[ApiMember(Name = "WarningsOnly", Description = "Optional. Include only warnings and problems.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] | ||
public bool? WarningsOnly { get; set; } | ||
} | ||
|
||
public class HealthService : BaseApiService | ||
{ | ||
private readonly IHealthService _healthService; | ||
|
||
public HealthService(IHealthService healthService) | ||
{ | ||
_healthService = healthService; | ||
} | ||
|
||
public object Get(GetHealthMessages request) | ||
{ | ||
var result = _healthService.GetHealthMessages(new HealthQuery | ||
{ | ||
WarningsOnly = request.WarningsOnly | ||
}); | ||
|
||
return ToOptimizedSerializedResultUsingCache(result); | ||
} | ||
} | ||
} |
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,133 @@ | ||
using MediaBrowser.Controller.Entities; | ||
using MediaBrowser.Controller.Localization; | ||
using MediaBrowser.Model.Channels; | ||
using MediaBrowser.Model.Querying; | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
/// <summary> | ||
/// Base class for health messages. | ||
/// </summary> | ||
public class HealthMessage | ||
{ | ||
private readonly string _messageId; | ||
private readonly HealthMessageSeverity _severity; | ||
private readonly string _messageType; | ||
private readonly Type _reportingType; | ||
private readonly string _area; | ||
private readonly object[] _parameters; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HealthMessage" /> class. | ||
/// </summary> | ||
/// <param name="reporter">The reporter.</param> | ||
/// <param name="messageId">The message identifier.</param> | ||
/// <param name="messageType">Type of the message.</param> | ||
/// <param name="severity">The severity.</param> | ||
/// <param name="area">The area.</param> | ||
/// <param name="parameters">The parameters.</param> | ||
public HealthMessage(object reporter, string messageId, HealthMessageType messageType, HealthMessageSeverity severity, string area, params object[] parameters) | ||
: this(reporter, messageId, messageType.ToString(), severity, area, parameters) | ||
{} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HealthMessage" /> class. | ||
/// </summary> | ||
protected HealthMessage(object reporter, string messageId, string messageType, HealthMessageSeverity severity, string area, params object[] parameters) | ||
{ | ||
_reportingType = reporter.GetType(); | ||
_messageId = messageId; | ||
_severity = severity; | ||
_messageType = messageType; | ||
_area = area; | ||
_parameters = parameters; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HealthMessage"/> class. | ||
/// </summary> | ||
/// <param name="baseMessage">The base message.</param> | ||
protected HealthMessage(HealthMessage baseMessage) | ||
{ | ||
_reportingType = baseMessage._reportingType; | ||
_messageId = baseMessage._messageId; | ||
_severity = baseMessage._severity; | ||
_messageType = baseMessage._messageType; | ||
_area = baseMessage._area; | ||
_parameters = baseMessage._parameters; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the type of health message. | ||
/// </summary> | ||
public string MessageType | ||
{ | ||
get | ||
{ | ||
return _messageType; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the message id. | ||
/// </summary> | ||
public string MessageId | ||
{ | ||
get | ||
{ | ||
return _messageId; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the area. | ||
/// </summary> | ||
public string Area | ||
{ | ||
get | ||
{ | ||
return _area; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the severity. | ||
/// </summary> | ||
public HealthMessageSeverity Severity | ||
{ | ||
get | ||
{ | ||
return _severity; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the reporting component type. | ||
/// </summary> | ||
public Type ReportingType | ||
{ | ||
get | ||
{ | ||
return _reportingType; | ||
} | ||
} | ||
|
||
protected object[] Parameters | ||
{ | ||
get | ||
{ | ||
return _parameters; | ||
} | ||
} | ||
|
||
public virtual HealthMessageLocalized ToLocalized(ILocalizationManager localizationManager) | ||
{ | ||
return new HealthMessageLocalized(this, localizationManager); | ||
} | ||
} | ||
} |
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,96 @@ | ||
using MediaBrowser.Controller.Entities; | ||
using MediaBrowser.Controller.Localization; | ||
using MediaBrowser.Model.Channels; | ||
using MediaBrowser.Model.Querying; | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
/// <summary> | ||
/// Health message class with localized strings. | ||
/// </summary> | ||
public class HealthMessageLocalized : HealthMessage | ||
{ | ||
private readonly string _messageText; | ||
private readonly string _severityText; | ||
private readonly string _messageTypeText; | ||
private readonly string _areaText; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HealthMessageLocalized"/> class. | ||
/// </summary> | ||
public HealthMessageLocalized(HealthMessage baseMessage, ILocalizationManager localizationManager) | ||
: base(baseMessage) | ||
{ | ||
if (localizationManager != null) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(MessageType)) | ||
{ | ||
_messageTypeText = localizationManager.GetLocalizedString("HealthMessageType" + MessageType); | ||
} | ||
if (!string.IsNullOrWhiteSpace(MessageId)) | ||
{ | ||
var idText = localizationManager.GetLocalizedString(MessageId); | ||
_messageText = string.Format(idText, this.Parameters); | ||
} | ||
|
||
_severityText = localizationManager.GetLocalizedString("HealthMessageSeverity" + Severity.ToString()); | ||
|
||
if (!string.IsNullOrWhiteSpace(Area)) | ||
{ | ||
var areaStrings = Area.Split('|').Select(e => localizationManager.GetLocalizedString(e)); | ||
|
||
_areaText = string.Join(" >> ", areaStrings); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the type of health message. | ||
/// </summary> | ||
public virtual string MessageTypeText | ||
{ | ||
get | ||
{ | ||
return _messageTypeText; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the message text. | ||
/// </summary> | ||
public string MessageText | ||
{ | ||
get | ||
{ | ||
return _messageText; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the area text. | ||
/// </summary> | ||
public string AreaText | ||
{ | ||
get | ||
{ | ||
return _areaText; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the severity text. | ||
/// </summary> | ||
public string SeverityText | ||
{ | ||
get | ||
{ | ||
return _severityText; | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
using MediaBrowser.Controller.Entities; | ||
using MediaBrowser.Model.Channels; | ||
using MediaBrowser.Model.Querying; | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
public enum HealthMessageSeverity | ||
{ | ||
Informational = 0, | ||
Suggestion = 1, | ||
Warning = 2, | ||
Problem = 3 | ||
} | ||
} |
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,19 @@ | ||
using MediaBrowser.Controller.Entities; | ||
using MediaBrowser.Model.Channels; | ||
using MediaBrowser.Model.Querying; | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
public enum HealthMessageType | ||
{ | ||
General = 0, | ||
Configuration = 1, | ||
ServerStatus = 2, | ||
Custom = 999 | ||
} | ||
} |
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,7 @@ | ||
namespace MediaBrowser.Controller.Health | ||
{ | ||
public class HealthQuery | ||
{ | ||
public bool? WarningsOnly { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using MediaBrowser.Model.Notifications; | ||
using System; | ||
using MediaBrowser.Controller.Localization; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
public interface IHealthReporter | ||
{ | ||
void AddHealthMessage(HealthMessage healthMessage, bool replaceExistingById = true); | ||
|
||
void RemoveHealthMessagesById(object reporter, string messageId); | ||
|
||
void AddRemoveHealthMessage(bool condition, HealthMessage healthMessage); | ||
|
||
Task<List<HealthMessage>> GetAllHealthMessages(); | ||
} | ||
} |
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 @@ | ||
using MediaBrowser.Model.News; | ||
using MediaBrowser.Model.Querying; | ||
|
||
namespace MediaBrowser.Controller.Health | ||
{ | ||
/// <summary> | ||
/// Interface IHealthService | ||
/// </summary> | ||
public interface IHealthService | ||
{ | ||
/// <summary> | ||
/// Gets the health messages. | ||
/// </summary> | ||
/// <param name="query">The query.</param> | ||
/// <returns>QueryResult{HealthMessageLocalized}.</returns> | ||
QueryResult<HealthMessageLocalized> GetHealthMessages(HealthQuery query); | ||
} | ||
} |
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
Oops, something went wrong.