2013-05-20 22:22:27 +02:00
|
|
|
|
using Nancy;
|
2013-05-24 23:28:13 +02:00
|
|
|
|
using Nancy.Routing;
|
2013-05-20 22:22:27 +02:00
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Api.Extensions;
|
2013-06-28 02:04:52 +02:00
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-20 22:22:27 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.System
|
|
|
|
|
{
|
|
|
|
|
public class SystemModule : NzbDroneApiModule
|
|
|
|
|
{
|
2013-06-28 02:04:52 +02:00
|
|
|
|
private readonly IAppDirectoryInfo _appDirectoryInfo;
|
|
|
|
|
private readonly IRuntimeInfo _runtimeInfo;
|
2013-05-24 23:28:13 +02:00
|
|
|
|
private readonly IRouteCacheProvider _routeCacheProvider;
|
2013-05-20 22:22:27 +02:00
|
|
|
|
|
2013-06-28 02:04:52 +02:00
|
|
|
|
public SystemModule(IAppDirectoryInfo appDirectoryInfo, IRuntimeInfo runtimeInfo, IRouteCacheProvider routeCacheProvider)
|
2013-05-20 22:22:27 +02:00
|
|
|
|
: base("system")
|
|
|
|
|
{
|
2013-06-28 02:04:52 +02:00
|
|
|
|
_appDirectoryInfo = appDirectoryInfo;
|
|
|
|
|
_runtimeInfo = runtimeInfo;
|
2013-05-24 23:28:13 +02:00
|
|
|
|
_routeCacheProvider = routeCacheProvider;
|
2013-05-20 22:22:27 +02:00
|
|
|
|
Get["/status"] = x => GetStatus();
|
2013-05-24 23:28:13 +02:00
|
|
|
|
Get["/routes"] = x => GetRoutes();
|
2013-05-20 22:22:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Response GetStatus()
|
|
|
|
|
{
|
|
|
|
|
return new
|
|
|
|
|
{
|
2013-06-28 02:04:52 +02:00
|
|
|
|
Version = BuildInfo.Version.ToString(),
|
|
|
|
|
BuildTime = BuildInfo.BuildDateTime,
|
|
|
|
|
IsDebug = BuildInfo.IsDebug,
|
|
|
|
|
IsProduction = RuntimeInfo.IsProduction,
|
|
|
|
|
IsAdmin = _runtimeInfo.IsAdmin,
|
|
|
|
|
IsUserInteractive = _runtimeInfo.IsUserInteractive,
|
|
|
|
|
StartupPath = _appDirectoryInfo.StartUpPath,
|
|
|
|
|
AppData = _appDirectoryInfo.GetAppDataPath(),
|
|
|
|
|
OsVersion = OsInfo.Version.ToString(),
|
|
|
|
|
IsMono = OsInfo.IsMono,
|
|
|
|
|
IsLinux = OsInfo.IsLinux,
|
2013-05-20 22:22:27 +02:00
|
|
|
|
}.AsResponse();
|
|
|
|
|
|
|
|
|
|
}
|
2013-05-24 23:28:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Response GetRoutes()
|
|
|
|
|
{
|
|
|
|
|
return _routeCacheProvider.GetCache().Values.AsResponse();
|
|
|
|
|
}
|
2013-05-20 22:22:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|