mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
Fix response codes, documentation, and auth
This commit is contained in:
parent
f516cf9c4c
commit
6051df0c47
@ -1,9 +1,8 @@
|
|||||||
#nullable enable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Jellyfin.Api.Constants;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.Net;
|
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dlna Controller.
|
/// Dlna Controller.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authenticated(Roles = "Admin")]
|
[Authorize(Policy = Policies.RequiresElevation)]
|
||||||
public class DlnaController : BaseJellyfinApiController
|
public class DlnaController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
private readonly IDlnaManager _dlnaManager;
|
private readonly IDlnaManager _dlnaManager;
|
||||||
@ -29,34 +28,38 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get profile infos.
|
/// Get profile infos.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Profile infos.</returns>
|
/// <response code="200">Device profile infos returned.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> containing the device profile infos.</returns>
|
||||||
[HttpGet("ProfileInfos")]
|
[HttpGet("ProfileInfos")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public IEnumerable<DeviceProfileInfo> GetProfileInfos()
|
public ActionResult<IEnumerable<DeviceProfileInfo>> GetProfileInfos()
|
||||||
{
|
{
|
||||||
return _dlnaManager.GetProfileInfos();
|
return Ok(_dlnaManager.GetProfileInfos());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default profile.
|
/// Gets the default profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Default profile.</returns>
|
/// <response code="200">Default device profile returned.</response>
|
||||||
|
/// <returns>An <see cref="OkResult"/> containing the default profile.</returns>
|
||||||
[HttpGet("Profiles/Default")]
|
[HttpGet("Profiles/Default")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult<DeviceProfileInfo> GetDefaultProfile()
|
public ActionResult<DeviceProfile> GetDefaultProfile()
|
||||||
{
|
{
|
||||||
return Ok(_dlnaManager.GetDefaultProfile());
|
return _dlnaManager.GetDefaultProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a single profile.
|
/// Gets a single profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Profile Id.</param>
|
/// <param name="id">Profile Id.</param>
|
||||||
/// <returns>Profile.</returns>
|
/// <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/{Id}")]
|
[HttpGet("Profiles/{Id}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult<DeviceProfileInfo> GetProfile([FromRoute] string id)
|
public ActionResult<DeviceProfile> GetProfile([FromRoute] string id)
|
||||||
{
|
{
|
||||||
var profile = _dlnaManager.GetProfile(id);
|
var profile = _dlnaManager.GetProfile(id);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
@ -64,16 +67,18 @@ namespace Jellyfin.Api.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(profile);
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a profile.
|
/// Deletes a profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Profile id.</param>
|
/// <param name="id">Profile id.</param>
|
||||||
/// <returns>Status.</returns>
|
/// <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/{Id}")]
|
[HttpDelete("Profiles/{Id}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult DeleteProfile([FromRoute] string id)
|
public ActionResult DeleteProfile([FromRoute] string id)
|
||||||
{
|
{
|
||||||
@ -84,20 +89,21 @@ namespace Jellyfin.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
_dlnaManager.DeleteProfile(id);
|
_dlnaManager.DeleteProfile(id);
|
||||||
return Ok();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a profile.
|
/// Creates a profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceProfile">Device profile.</param>
|
/// <param name="deviceProfile">Device profile.</param>
|
||||||
/// <returns>Status.</returns>
|
/// <response code="204">Device profile created.</response>
|
||||||
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
||||||
[HttpPost("Profiles")]
|
[HttpPost("Profiles")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public ActionResult CreateProfile([FromBody] DeviceProfile deviceProfile)
|
public ActionResult CreateProfile([FromBody] DeviceProfile deviceProfile)
|
||||||
{
|
{
|
||||||
_dlnaManager.CreateProfile(deviceProfile);
|
_dlnaManager.CreateProfile(deviceProfile);
|
||||||
return Ok();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -105,9 +111,11 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Profile id.</param>
|
/// <param name="id">Profile id.</param>
|
||||||
/// <param name="deviceProfile">Device profile.</param>
|
/// <param name="deviceProfile">Device profile.</param>
|
||||||
/// <returns>Status.</returns>
|
/// <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/{Id}")]
|
[HttpPost("Profiles/{Id}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult UpdateProfile([FromRoute] string id, [FromBody] DeviceProfile deviceProfile)
|
public ActionResult UpdateProfile([FromRoute] string id, [FromBody] DeviceProfile deviceProfile)
|
||||||
{
|
{
|
||||||
@ -118,7 +126,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
_dlnaManager.UpdateProfile(deviceProfile);
|
_dlnaManager.UpdateProfile(deviceProfile);
|
||||||
return Ok();
|
return NoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user