blob: e6f0fb41e9246e3ec84796e3f483a60994aaace6 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Api.Constants;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Model.Dlna;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Jellyfin.Api.Controllers
{
/// <summary>
/// Dlna Controller.
/// </summary>
[Authorize(Policy = Policies.RequiresElevation)]
public class DlnaController : BaseJellyfinApiController
{
private readonly IDlnaManager _dlnaManager;
/// <summary>
/// Initializes a new instance of the <see cref="DlnaController"/> class.
/// </summary>
/// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
public DlnaController(IDlnaManager dlnaManager)
{
_dlnaManager = dlnaManager;
}
/// <summary>
/// Get profile infos.
/// </summary>
/// <response code="200">Device profile infos returned.</response>
/// <returns>An <see cref="OkResult"/> containing the device profile infos.</returns>
[HttpGet("ProfileInfos")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<IEnumerable<DeviceProfileInfo>> GetProfileInfos()
{
return Ok(_dlnaManager.GetProfileInfos());
}
/// <summary>
/// Gets the default profile.
/// </summary>
/// <response code="200">Default device profile returned.</response>
/// <returns>An <see cref="OkResult"/> containing the default profile.</returns>
[HttpGet("Profiles/Default")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<DeviceProfile> GetDefaultProfile()
{
return _dlnaManager.GetDefaultProfile();
}
/// <summary>
/// Gets a single profile.
/// </summary>
/// <param name="profileId">Profile Id.</param>
/// <response code="200">Device profile returned.</response>
/// <response code="404">Device profile not found.</response>
/// <returns>An <see cref="OkResult"/> containing the profile on success, or a <see cref="NotFoundResult"/> if device profile not found.</returns>
[HttpGet("Profiles/{profileId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<DeviceProfile> GetProfile([FromRoute][Required] string profileId)
{
var profile = _dlnaManager.GetProfile(profileId);
if (profile == null)
{
return NotFound();
}
return profile;
}
/// <summary>
/// Deletes a profile.
/// </summary>
/// <param name="profileId">Profile id.</param>
/// <response code="204">Device profile deleted.</response>
/// <response code="404">Device profile not found.</response>
/// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if profile not found.</returns>
[HttpDelete("Profiles/{profileId}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult DeleteProfile([FromRoute][Required] string profileId)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
if (existingDeviceProfile == null)
{
return NotFound();
}
_dlnaManager.DeleteProfile(profileId);
return NoContent();
}
/// <summary>
/// Creates a profile.
/// </summary>
/// <param name="deviceProfile">Device profile.</param>
/// <response code="204">Device profile created.</response>
/// <returns>A <see cref="NoContentResult"/>.</returns>
[HttpPost("Profiles")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult CreateProfile([FromBody] DeviceProfile deviceProfile)
{
_dlnaManager.CreateProfile(deviceProfile);
return NoContent();
}
/// <summary>
/// Updates a profile.
/// </summary>
/// <param name="profileId">Profile id.</param>
/// <param name="deviceProfile">Device profile.</param>
/// <response code="204">Device profile updated.</response>
/// <response code="404">Device profile not found.</response>
/// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if profile not found.</returns>
[HttpPost("Profiles/{profileId}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult UpdateProfile([FromRoute][Required] string profileId, [FromBody] DeviceProfile deviceProfile)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
if (existingDeviceProfile == null)
{
return NotFound();
}
_dlnaManager.UpdateProfile(deviceProfile);
return NoContent();
}
}
}
|