mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
API: Cleaning up the configuration's documentation
This commit is contained in:
parent
cd5b953e0f
commit
a7a994ab41
@ -29,6 +29,7 @@ using IdentityServer4.Services;
|
|||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
using Kyoo.Abstractions.Models.Exceptions;
|
using Kyoo.Abstractions.Models.Exceptions;
|
||||||
|
using Kyoo.Abstractions.Models.Utils;
|
||||||
using Kyoo.Authentication.Models;
|
using Kyoo.Authentication.Models;
|
||||||
using Kyoo.Authentication.Models.DTO;
|
using Kyoo.Authentication.Models.DTO;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
@ -36,14 +37,15 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using static Kyoo.Abstractions.Models.Utils.Constants;
|
||||||
|
|
||||||
namespace Kyoo.Authentication.Views
|
namespace Kyoo.Authentication.Views
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The class responsible for login, logout, permissions and claims of a user.
|
/// The endpoint responsible for login, logout, permissions and claims of a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/account")]
|
|
||||||
[Route("api/accounts")]
|
[Route("api/accounts")]
|
||||||
|
[Route("api/account", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class AccountApi : Controller, IProfileService
|
public class AccountApi : Controller, IProfileService
|
||||||
{
|
{
|
||||||
@ -78,11 +80,16 @@ namespace Kyoo.Authentication.Views
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register a new user and return a OTAC to connect to it.
|
/// Register
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Register a new user and return a OTAC to connect to it.
|
||||||
|
/// </remarks>
|
||||||
/// <param name="request">The DTO register request</param>
|
/// <param name="request">The DTO register request</param>
|
||||||
/// <returns>A OTAC to connect to this new account</returns>
|
/// <returns>A OTAC to connect to this new account</returns>
|
||||||
[HttpPost("register")]
|
[HttpPost("register")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict, Type = typeof(RequestError))]
|
||||||
public async Task<IActionResult> Register([FromBody] RegisterRequest request)
|
public async Task<IActionResult> Register([FromBody] RegisterRequest request)
|
||||||
{
|
{
|
||||||
User user = request.ToUser();
|
User user = request.ToUser();
|
||||||
@ -96,7 +103,7 @@ namespace Kyoo.Authentication.Views
|
|||||||
}
|
}
|
||||||
catch (DuplicatedItemException)
|
catch (DuplicatedItemException)
|
||||||
{
|
{
|
||||||
return Conflict(new { Errors = new { Duplicate = new[] { "A user with this name already exists" } } });
|
return Conflict(new RequestError("A user with this name already exists"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(new { Otac = user.ExtraData["otac"] });
|
return Ok(new { Otac = user.ExtraData["otac"] });
|
||||||
|
@ -19,18 +19,23 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
using Kyoo.Abstractions.Models.Exceptions;
|
using Kyoo.Abstractions.Models.Exceptions;
|
||||||
using Kyoo.Abstractions.Models.Permissions;
|
using Kyoo.Abstractions.Models.Permissions;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using static Kyoo.Abstractions.Models.Utils.Constants;
|
||||||
|
|
||||||
namespace Kyoo.Core.Api
|
namespace Kyoo.Core.Api
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An API to retrieve or edit configuration settings
|
/// An API to retrieve or edit configuration settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/config")]
|
|
||||||
[Route("api/configuration")]
|
[Route("api/configuration")]
|
||||||
|
[Route("api/config", Order = AlternativeRoute)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
|
[PartialPermission("Configuration", Group = Group.Admin)]
|
||||||
|
[ApiDefinition("Configuration", Group = AdminGroup)]
|
||||||
public class ConfigurationApi : Controller
|
public class ConfigurationApi : Controller
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -48,14 +53,19 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a permission from it's slug.
|
/// Get config value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Retrieve a configuration's value from it's slug.
|
||||||
|
/// </remarks>
|
||||||
/// <param name="slug">The permission to retrieve. You can use ':' or "__" to get a child value.</param>
|
/// <param name="slug">The permission to retrieve. You can use ':' or "__" to get a child value.</param>
|
||||||
/// <returns>The associate value or list of values.</returns>
|
/// <returns>The associate value or list of values.</returns>
|
||||||
/// <response code="200">Return the configuration value or the list of configurations</response>
|
/// <response code="200">Return the configuration value or the list of configurations</response>
|
||||||
/// <response code="404">No configuration exists for the given slug</response>
|
/// <response code="404">No configuration exists for the given slug</response>
|
||||||
[HttpGet("{slug}")]
|
[HttpGet("{slug}")]
|
||||||
[Permission(nameof(ConfigurationApi), Kind.Read, Group.Admin)]
|
[PartialPermission(Kind.Read)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult<object> GetConfiguration(string slug)
|
public ActionResult<object> GetConfiguration(string slug)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -69,15 +79,20 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Edit a permission from it's slug.
|
/// Edit config
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Edit a configuration's value from it's slug.
|
||||||
|
/// </remarks>
|
||||||
/// <param name="slug">The permission to edit. You can use ':' or "__" to get a child value.</param>
|
/// <param name="slug">The permission to edit. You can use ':' or "__" to get a child value.</param>
|
||||||
/// <param name="newValue">The new value of the configuration</param>
|
/// <param name="newValue">The new value of the configuration</param>
|
||||||
/// <returns>The edited value.</returns>
|
/// <returns>The edited value.</returns>
|
||||||
/// <response code="200">Return the edited value</response>
|
/// <response code="200">Return the edited value</response>
|
||||||
/// <response code="404">No configuration exists for the given slug</response>
|
/// <response code="404">No configuration exists for the given slug</response>
|
||||||
[HttpPut("{slug}")]
|
[HttpPut("{slug}")]
|
||||||
[Permission(nameof(ConfigurationApi), Kind.Write, Group.Admin)]
|
[PartialPermission(Kind.Write)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult<object>> EditConfiguration(string slug, [FromBody] object newValue)
|
public async Task<ActionResult<object>> EditConfiguration(string slug, [FromBody] object newValue)
|
||||||
{
|
{
|
||||||
try
|
try
|
Loading…
x
Reference in New Issue
Block a user