aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna/Api/DlnaService.cs
blob: fec610d230e2dbeb368a12340b05d022b2d743ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System.Linq;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Services;

namespace Emby.Dlna.Api
{
    [Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")]
    public class GetProfileInfos : IReturn<DeviceProfileInfo[]>
    {
    }

    [Route("/Dlna/Profiles/{Id}", "DELETE", Summary = "Deletes a profile")]
    public class DeleteProfile : IReturnVoid
    {
        [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
        public string Id { get; set; }
    }

    [Route("/Dlna/Profiles/Default", "GET", Summary = "Gets the default profile")]
    public class GetDefaultProfile : IReturn<DeviceProfile>
    {
    }

    [Route("/Dlna/Profiles/{Id}", "GET", Summary = "Gets a single profile")]
    public class GetProfile : IReturn<DeviceProfile>
    {
        [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
        public string Id { get; set; }
    }

    [Route("/Dlna/Profiles/{Id}", "POST", Summary = "Updates a profile")]
    public class UpdateProfile : DeviceProfile, IReturnVoid
    {
    }

    [Route("/Dlna/Profiles", "POST", Summary = "Creates a profile")]
    public class CreateProfile : DeviceProfile, IReturnVoid
    {
    }

    [Authenticated(Roles = "Admin")]
    public class DlnaService : IService
    {
        private readonly IDlnaManager _dlnaManager;

        public DlnaService(IDlnaManager dlnaManager)
        {
            _dlnaManager = dlnaManager;
        }

        public object Get(GetProfileInfos request)
        {
            return _dlnaManager.GetProfileInfos().ToArray();
        }

        public object Get(GetProfile request)
        {
            return _dlnaManager.GetProfile(request.Id);
        }

        public object Get(GetDefaultProfile request)
        {
            return _dlnaManager.GetDefaultProfile();
        }

        public void Delete(DeleteProfile request)
        {
            _dlnaManager.DeleteProfile(request.Id);
        }

        public void Post(UpdateProfile request)
        {
            _dlnaManager.UpdateProfile(request);
        }

        public void Post(CreateProfile request)
        {
            _dlnaManager.CreateProfile(request);
        }
    }
}