2013-05-20 23:22:27 +03:00
|
|
|
using Nancy;
|
2013-05-25 00:28:13 +03:00
|
|
|
using Nancy.Routing;
|
2013-05-20 23:22:27 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Api.Extensions;
|
2013-05-25 00:28:13 +03:00
|
|
|
using System.Linq;
|
2013-05-20 23:22:27 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Api.System
|
|
|
|
{
|
|
|
|
public class SystemModule : NzbDroneApiModule
|
|
|
|
{
|
|
|
|
private readonly IEnvironmentProvider _environmentProvider;
|
2013-05-25 00:28:13 +03:00
|
|
|
private readonly IRouteCacheProvider _routeCacheProvider;
|
2013-05-20 23:22:27 +03:00
|
|
|
|
2013-05-25 00:28:13 +03:00
|
|
|
public SystemModule(IEnvironmentProvider environmentProvider, IRouteCacheProvider routeCacheProvider)
|
2013-05-20 23:22:27 +03:00
|
|
|
: base("system")
|
|
|
|
{
|
|
|
|
_environmentProvider = environmentProvider;
|
2013-05-25 00:28:13 +03:00
|
|
|
_routeCacheProvider = routeCacheProvider;
|
2013-05-20 23:22:27 +03:00
|
|
|
Get["/status"] = x => GetStatus();
|
2013-05-25 00:28:13 +03:00
|
|
|
Get["/routes"] = x => GetRoutes();
|
2013-05-20 23:22:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private Response GetStatus()
|
|
|
|
{
|
|
|
|
return new
|
|
|
|
{
|
|
|
|
Version = _environmentProvider.Version,
|
|
|
|
AppData = _environmentProvider.GetAppDataPath(),
|
|
|
|
IsAdmin = _environmentProvider.IsAdmin,
|
|
|
|
IsUserInteractive = _environmentProvider.IsUserInteractive,
|
|
|
|
BuildTime = _environmentProvider.BuildDateTime,
|
|
|
|
StartupPath = _environmentProvider.StartUpPath,
|
|
|
|
OsVersion = _environmentProvider.GetOsVersion(),
|
|
|
|
IsMono = EnvironmentProvider.IsMono,
|
|
|
|
IsProduction = EnvironmentProvider.IsProduction,
|
|
|
|
IsDebug = EnvironmentProvider.IsDebug,
|
2013-05-25 00:28:13 +03:00
|
|
|
IsLinux = EnvironmentProvider.IsLinux,
|
2013-05-20 23:22:27 +03:00
|
|
|
}.AsResponse();
|
|
|
|
|
|
|
|
}
|
2013-05-25 00:28:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
private Response GetRoutes()
|
|
|
|
{
|
|
|
|
return _routeCacheProvider.GetCache().Values.AsResponse();
|
|
|
|
}
|
2013-05-20 23:22:27 +03:00
|
|
|
}
|
|
|
|
}
|