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/NzbDrone.Api/QualityProfiles/RootFolderModule.cs

39 lines
1.1 KiB

using Nancy;
using NzbDrone.Core.Providers;
using NzbDrone.Api.QualityType;
using NzbDrone.Core.Repository;
namespace NzbDrone.Api.QualityProfiles
{
public class RootDirModule : NzbDroneApiModule
{
private readonly RootDirProvider _rootDirProvider;
public RootDirModule(RootDirProvider rootDirProvider)
: base("//rootdir")
{
_rootDirProvider = rootDirProvider;
Get["/"] = x => GetRootFolders();
Post["/"] = x => AddRootFolder();
Delete["/{id}"] = x => DeleteRootFolder((int)x.id);
}
private Response AddRootFolder()
{
var dir = _rootDirProvider.Add(Request.Body.FromJson<RootDir>());
return dir.AsResponse(HttpStatusCode.Created);
}
private Response GetRootFolders()
{
return _rootDirProvider.AllWithFreeSpace().AsResponse();
}
private Response DeleteRootFolder(int folderId)
{
_rootDirProvider.Remove(folderId);
return new Response { StatusCode = HttpStatusCode.OK };
}
}
}