2017-02-11 06:46:39 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-08-04 01:55:31 +00:00
|
|
|
|
using NzbDrone.Common.Extensions;
|
2017-02-11 06:46:39 +00:00
|
|
|
|
using NzbDrone.Core.RootFolders;
|
|
|
|
|
using Sonarr.Http.REST;
|
|
|
|
|
|
|
|
|
|
namespace Sonarr.Api.V3.RootFolders
|
|
|
|
|
{
|
|
|
|
|
public class RootFolderResource : RestResource
|
|
|
|
|
{
|
|
|
|
|
public string Path { get; set; }
|
2019-08-27 21:48:34 +00:00
|
|
|
|
public bool Accessible { get; set; }
|
2017-02-11 06:46:39 +00:00
|
|
|
|
public long? FreeSpace { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<UnmappedFolder> UnmappedFolders { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class RootFolderResourceMapper
|
|
|
|
|
{
|
|
|
|
|
public static RootFolderResource ToResource(this RootFolder model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null) return null;
|
|
|
|
|
|
|
|
|
|
return new RootFolderResource
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
|
2019-08-04 01:55:31 +00:00
|
|
|
|
Path = model.Path.GetCleanPath(),
|
2019-08-27 21:48:34 +00:00
|
|
|
|
Accessible = model.Accessible,
|
2017-02-11 06:46:39 +00:00
|
|
|
|
FreeSpace = model.FreeSpace,
|
|
|
|
|
UnmappedFolders = model.UnmappedFolders
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static RootFolder ToModel(this RootFolderResource resource)
|
|
|
|
|
{
|
|
|
|
|
if (resource == null) return null;
|
|
|
|
|
|
|
|
|
|
return new RootFolder
|
|
|
|
|
{
|
|
|
|
|
Id = resource.Id,
|
|
|
|
|
|
2019-08-04 01:55:31 +00:00
|
|
|
|
Path = resource.Path
|
2019-08-27 21:48:34 +00:00
|
|
|
|
//Accessible
|
2017-02-11 06:46:39 +00:00
|
|
|
|
//FreeSpace
|
|
|
|
|
//UnmappedFolders
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<RootFolderResource> ToResource(this IEnumerable<RootFolder> models)
|
|
|
|
|
{
|
|
|
|
|
return models.Select(ToResource).ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|