#nullable enable
using System.Collections.Generic;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dlna;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Jellyfin.Api.Controllers
{
///
/// Dlna Controller.
///
[Authenticated(Roles = "Admin")]
public class DlnaController : BaseJellyfinApiController
{
private readonly IDlnaManager _dlnaManager;
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
public DlnaController(IDlnaManager dlnaManager)
{
_dlnaManager = dlnaManager;
}
///
/// Get profile infos.
///
/// Profile infos.
[HttpGet("ProfileInfos")]
[ProducesResponseType(StatusCodes.Status200OK)]
public IEnumerable GetProfileInfos()
{
return _dlnaManager.GetProfileInfos();
}
///
/// Gets the default profile.
///
/// Default profile.
[HttpGet("Profiles/Default")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult GetDefaultProfile()
{
return Ok(_dlnaManager.GetDefaultProfile());
}
///
/// Gets a single profile.
///
/// Profile Id.
/// Profile.
[HttpGet("Profiles/{Id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GetProfile([FromRoute] string id)
{
var profile = _dlnaManager.GetProfile(id);
if (profile == null)
{
return NotFound();
}
return Ok(profile);
}
///
/// Deletes a profile.
///
/// Profile id.
/// Status.
[HttpDelete("Profiles/{Id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult DeleteProfile([FromRoute] string id)
{
var existingDeviceProfile = _dlnaManager.GetProfile(id);
if (existingDeviceProfile == null)
{
return NotFound();
}
_dlnaManager.DeleteProfile(id);
return Ok();
}
///
/// Creates a profile.
///
/// Device profile.
/// Status.
[HttpPost("Profiles")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult CreateProfile([FromBody] DeviceProfile deviceProfile)
{
_dlnaManager.CreateProfile(deviceProfile);
return Ok();
}
///
/// Updates a profile.
///
/// Profile id.
/// Device profile.
/// Status.
[HttpPost("Profiles/{Id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult UpdateProfile([FromRoute] string id, [FromBody] DeviceProfile deviceProfile)
{
var existingDeviceProfile = _dlnaManager.GetProfile(id);
if (existingDeviceProfile == null)
{
return NotFound();
}
_dlnaManager.UpdateProfile(deviceProfile);
return Ok();
}
}
}