DlnaService.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma warning disable CS1591
  2. using System.Diagnostics.CodeAnalysis;
  3. using System.Linq;
  4. using MediaBrowser.Controller.Dlna;
  5. using MediaBrowser.Controller.Net;
  6. using MediaBrowser.Model.Dlna;
  7. using MediaBrowser.Model.Services;
  8. namespace Emby.Dlna.Api
  9. {
  10. [Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")]
  11. public class GetProfileInfos : IReturn<DeviceProfileInfo[]>
  12. {
  13. }
  14. [Route("/Dlna/Profiles/{Id}", "DELETE", Summary = "Deletes a profile")]
  15. public class DeleteProfile : IReturnVoid
  16. {
  17. [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
  18. public string Id { get; set; }
  19. }
  20. [Route("/Dlna/Profiles/Default", "GET", Summary = "Gets the default profile")]
  21. public class GetDefaultProfile : IReturn<DeviceProfile>
  22. {
  23. }
  24. [Route("/Dlna/Profiles/{Id}", "GET", Summary = "Gets a single profile")]
  25. public class GetProfile : IReturn<DeviceProfile>
  26. {
  27. [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  28. public string Id { get; set; }
  29. }
  30. [Route("/Dlna/Profiles/{Id}", "POST", Summary = "Updates a profile")]
  31. public class UpdateProfile : DeviceProfile, IReturnVoid
  32. {
  33. }
  34. [Route("/Dlna/Profiles", "POST", Summary = "Creates a profile")]
  35. public class CreateProfile : DeviceProfile, IReturnVoid
  36. {
  37. }
  38. [Authenticated(Roles = "Admin")]
  39. public class DlnaService : IService
  40. {
  41. private readonly IDlnaManager _dlnaManager;
  42. public DlnaService(IDlnaManager dlnaManager)
  43. {
  44. _dlnaManager = dlnaManager;
  45. }
  46. [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
  47. public object Get(GetProfileInfos request)
  48. {
  49. return _dlnaManager.GetProfileInfos().ToArray();
  50. }
  51. public object Get(GetProfile request)
  52. {
  53. return _dlnaManager.GetProfile(request.Id);
  54. }
  55. [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
  56. public object Get(GetDefaultProfile request)
  57. {
  58. return _dlnaManager.GetDefaultProfile();
  59. }
  60. public void Delete(DeleteProfile request)
  61. {
  62. _dlnaManager.DeleteProfile(request.Id);
  63. }
  64. public void Post(UpdateProfile request)
  65. {
  66. _dlnaManager.UpdateProfile(request);
  67. }
  68. public void Post(CreateProfile request)
  69. {
  70. _dlnaManager.CreateProfile(request);
  71. }
  72. }
  73. }