DlnaService.cs 2.4 KB

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