mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-14 04:13:18 +02:00
XML-Documentation
This commit is contained in:
parent
3305519307
commit
3ecbc1a805
@ -214,7 +214,7 @@ public class JobController(PgsqlContext context) : Controller
|
||||
/// <response code="202">Job modified</response>
|
||||
/// <response code="400">Malformed request</response>
|
||||
/// <response code="404">Job with ID not found</response>
|
||||
/// <response code="500">Internal Error</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPatch("{id}/")]
|
||||
[ProducesResponseType<Job>(Status202Accepted)]
|
||||
[ProducesResponseType(Status400BadRequest)]
|
||||
@ -247,7 +247,7 @@ public class JobController(PgsqlContext context) : Controller
|
||||
/// <response code="202">Job started</response>
|
||||
/// <response code="404">Job with ID not found</response>
|
||||
/// <response code="409">Job was already running</response>
|
||||
/// <response code="500">Internal Error</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPost("{id}/Start")]
|
||||
[ProducesResponseType(Status202Accepted)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
@ -276,19 +276,10 @@ public class JobController(PgsqlContext context) : Controller
|
||||
/// Stops the Job with the requested ID
|
||||
/// </summary>
|
||||
/// <param name="id">Job-ID</param>
|
||||
/// <response code="202">Job started</response>
|
||||
/// <response code="404">Job with ID not found</response>
|
||||
/// <response code="409">Job was not running</response>
|
||||
/// <response code="500">Internal Error</response>
|
||||
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||
[ProducesResponseType(Status202Accepted)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
[ProducesResponseType(Status409Conflict)]
|
||||
[ProducesResponseType(Status500InternalServerError)]
|
||||
[HttpPost("{id}/Stop")]
|
||||
public IActionResult StopJob(string id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return NotFound(new ProblemResponse("Not implemented"));
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Gets all configured Library-Connectors
|
||||
/// </summary>
|
||||
/// <returns>Array of configured Library-Connectors</returns>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet]
|
||||
[ProducesResponseType<LibraryConnector[]>(Status200OK)]
|
||||
public IActionResult GetAllConnectors()
|
||||
@ -28,7 +28,8 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
||||
/// Returns Library-Connector with requested ID
|
||||
/// </summary>
|
||||
/// <param name="id">Library-Connector-ID</param>
|
||||
/// <returns>Library-Connector</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Connector with ID not found.</response>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType<LibraryConnector>(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
@ -46,7 +47,8 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
||||
/// Creates a new Library-Connector
|
||||
/// </summary>
|
||||
/// <param name="libraryConnector">Library-Connector</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPut]
|
||||
[ProducesResponseType(Status200OK)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
@ -68,7 +70,9 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
||||
/// Deletes the Library-Connector with the requested ID
|
||||
/// </summary>
|
||||
/// <param name="id">Library-Connector-ID</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Connector with ID not found.</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
|
@ -15,7 +15,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Get all available Connectors (Scanlation-Sites)
|
||||
/// </summary>
|
||||
/// <response code="200">List of all Connectors</response>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet("GetConnectors")]
|
||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||
public IActionResult GetConnectors()
|
||||
@ -27,7 +27,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Get all enabled Connectors (Scanlation-Sites)
|
||||
/// </summary>
|
||||
/// <response code="200">List of all enabled Connectors</response>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet("GetConnectors/enabled")]
|
||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||
public IActionResult GetEnabledConnectors()
|
||||
@ -39,7 +39,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Get all disabled Connectors (Scanlation-Sites)
|
||||
/// </summary>
|
||||
/// <response code="200">List of all enabled Connectors</response>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet("GetConnectors/disabled")]
|
||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||
public IActionResult GetDisabledConnectors()
|
||||
|
@ -14,7 +14,7 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Returns all cached Manga
|
||||
/// </summary>
|
||||
/// <returns>Array of Manga</returns>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet]
|
||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||
public IActionResult GetAllManga()
|
||||
@ -27,7 +27,7 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// Returns all cached Manga with IDs
|
||||
/// </summary>
|
||||
/// <param name="ids">Array of Manga-IDs</param>
|
||||
/// <returns>Array of Manga</returns>
|
||||
/// <response code="200"></response>
|
||||
[HttpPost("WithIDs")]
|
||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||
public IActionResult GetManga([FromBody]string[] ids)
|
||||
@ -40,42 +40,41 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// Return Manga with ID
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>Manga</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Manga with ID not found</response>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType<Manga>(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
public IActionResult GetManga(string id)
|
||||
{
|
||||
Manga? ret = context.Manga.Find(id);
|
||||
return (ret is not null) switch
|
||||
{
|
||||
true => Ok(ret),
|
||||
false => NotFound()
|
||||
};
|
||||
if (ret is null)
|
||||
return NotFound();
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Manga with ID
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Manga with ID not found</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
[ProducesResponseType(Status500InternalServerError)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult DeleteManga(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Manga? ret = context.Manga.Find(id);
|
||||
switch (ret is not null)
|
||||
{
|
||||
case true:
|
||||
context.Remove(ret);
|
||||
context.SaveChanges();
|
||||
return Ok();
|
||||
case false: return NotFound();
|
||||
}
|
||||
if (ret is null)
|
||||
return NotFound();
|
||||
|
||||
context.Remove(ret);
|
||||
context.SaveChanges();
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -87,28 +86,29 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// Returns URL of Cover of Manga
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>URL of Cover</returns>
|
||||
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||
[HttpGet("{id}/Cover")]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult GetCover(string id)
|
||||
{
|
||||
return StatusCode(500, "Not implemented"); //TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all Chapters of Manga
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>Array of Chapters</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Manga with ID not found</response>
|
||||
[HttpGet("{id}/Chapters")]
|
||||
[ProducesResponseType<Chapter[]>(Status200OK)]
|
||||
[ProducesResponseType<string>(Status404NotFound)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
public IActionResult GetChapters(string id)
|
||||
{
|
||||
Manga? m = context.Manga.Find(id);
|
||||
if (m is null)
|
||||
return NotFound("Manga could not be found");
|
||||
Chapter[] ret = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToArray();
|
||||
return NotFound();
|
||||
|
||||
Chapter[] ret = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToArray();
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
@ -116,35 +116,46 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// Returns the latest Chapter of requested Manga
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>Latest Chapter</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="204">No available chapters</response>
|
||||
/// <response code="404">Manga with ID not found.</response>
|
||||
/// <response code="500">Could not retrieve the maximum chapter-number</response>
|
||||
[HttpGet("{id}/Chapter/Latest")]
|
||||
[ProducesResponseType<Chapter>(Status200OK)]
|
||||
[ProducesResponseType<string>(Status404NotFound)]
|
||||
[ProducesResponseType(Status204NoContent)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult GetLatestChapter(string id)
|
||||
{
|
||||
Manga? m = context.Manga.Find(id);
|
||||
if (m is null)
|
||||
return NotFound("Manga could not be found");
|
||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToList();
|
||||
return NotFound();
|
||||
|
||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToList();
|
||||
if (chapters.Count == 0)
|
||||
return NoContent();
|
||||
|
||||
Chapter? max = chapters.Max();
|
||||
if (max is null)
|
||||
return NotFound("Chapter could not be found");
|
||||
return StatusCode(500, "Max chapter could not be found");
|
||||
|
||||
return Ok(max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configure the cut-off for Manga
|
||||
/// </summary>
|
||||
/// <remarks>This is important for the DownloadNewChapters-Job</remarks>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">Manga with ID not found.</response>
|
||||
[HttpPatch("{id}/IgnoreChaptersBefore")]
|
||||
[ProducesResponseType<float>(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
public IActionResult IgnoreChaptersBefore(string id)
|
||||
{
|
||||
Manga? m = context.Manga.Find(id);
|
||||
if (m is null)
|
||||
return NotFound("Manga could not be found");
|
||||
return NotFound();
|
||||
return Ok(m.IgnoreChapterBefore);
|
||||
}
|
||||
|
||||
@ -153,11 +164,10 @@ public class MangaController(PgsqlContext context) : Controller
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-ID</param>
|
||||
/// <param name="folder">New Directory-Path</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||
[HttpPost("{id}/MoveFolder")]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult MoveFolder(string id, [FromBody]string folder)
|
||||
{
|
||||
return StatusCode(500, "Not implemented"); //TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
||||
/// <summary>
|
||||
/// Gets all configured Notification-Connectors
|
||||
/// </summary>
|
||||
/// <returns>Array of configured Notification-Connectors</returns>
|
||||
/// <response code="200"></response>
|
||||
[HttpGet]
|
||||
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
||||
public IActionResult GetAllConnectors()
|
||||
@ -28,7 +28,8 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
||||
/// Returns Notification-Connector with requested ID
|
||||
/// </summary>
|
||||
/// <param name="id">Notification-Connector-ID</param>
|
||||
/// <returns>Notification-Connector</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">NotificationConnector with ID not found</response>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType<NotificationConnector>(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
@ -46,7 +47,8 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
||||
/// Creates a new Notification-Connector
|
||||
/// </summary>
|
||||
/// <param name="notificationConnector">Notification-Connector</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="201"></response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPut]
|
||||
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
@ -68,7 +70,9 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
||||
/// Deletes the Notification-Connector with the requested ID
|
||||
/// </summary>
|
||||
/// <param name="id">Notification-Connector-ID</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">NotificationConnector with ID not found</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
@ -78,14 +82,12 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
||||
try
|
||||
{
|
||||
NotificationConnector? ret = context.NotificationConnectors.Find(id);
|
||||
switch (ret is not null)
|
||||
{
|
||||
case true:
|
||||
context.Remove(ret);
|
||||
context.SaveChanges();
|
||||
return Ok();
|
||||
case false: return NotFound();
|
||||
}
|
||||
if(ret is null)
|
||||
return NotFound();
|
||||
|
||||
context.Remove(ret);
|
||||
context.SaveChanges();
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -18,14 +18,17 @@ public class SearchController(PgsqlContext context) : Controller
|
||||
/// Initiate a search for a Manga on all Connectors
|
||||
/// </summary>
|
||||
/// <param name="name">Name/Title of the Manga</param>
|
||||
/// <returns>Array of Manga</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPost("{name}")]
|
||||
[ProducesResponseType<Manga[]>(Status500InternalServerError)]
|
||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult SearchMangaGlobal(string name)
|
||||
{
|
||||
List<(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)> allManga = new();
|
||||
foreach (MangaConnector contextMangaConnector in context.MangaConnectors)
|
||||
allManga.AddRange(contextMangaConnector.GetManga(name));
|
||||
|
||||
List<Manga> retMangas = new();
|
||||
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in allManga)
|
||||
{
|
||||
@ -35,9 +38,9 @@ public class SearchController(PgsqlContext context) : Controller
|
||||
if(add is not null)
|
||||
retMangas.Add(add);
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
catch (Exception e)
|
||||
{
|
||||
return StatusCode(500, new ProblemResponse("An error occurred while processing your request."));
|
||||
return StatusCode(500, e);
|
||||
}
|
||||
}
|
||||
return Ok(retMangas.ToArray());
|
||||
@ -48,16 +51,23 @@ public class SearchController(PgsqlContext context) : Controller
|
||||
/// </summary>
|
||||
/// <param name="id">Manga-Connector-ID</param>
|
||||
/// <param name="name">Name/Title of the Manga</param>
|
||||
/// <returns>Manga</returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="404">MangaConnector with ID not found</response>
|
||||
/// <response code="406">MangaConnector with ID is disabled</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPost("{id}/{name}")]
|
||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||
[ProducesResponseType<ProblemResponse>(Status404NotFound)]
|
||||
[ProducesResponseType<ProblemResponse>(Status500InternalServerError)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
[ProducesResponseType(Status406NotAcceptable)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||
public IActionResult SearchManga(string id, string name)
|
||||
{
|
||||
MangaConnector? connector = context.MangaConnectors.Find(id);
|
||||
if (connector is null)
|
||||
return NotFound(new ProblemResponse("Connector not found."));
|
||||
return NotFound();
|
||||
else if (connector.Enabled is false)
|
||||
return StatusCode(406);
|
||||
|
||||
(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)[] mangas = connector.GetManga(name);
|
||||
List<Manga> retMangas = new();
|
||||
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in mangas)
|
||||
@ -68,15 +78,15 @@ public class SearchController(PgsqlContext context) : Controller
|
||||
if(add is not null)
|
||||
retMangas.Add(add);
|
||||
}
|
||||
catch (DbUpdateException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return StatusCode(500, new ProblemResponse("An error occurred while processing your request.", e.Message));
|
||||
return StatusCode(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(retMangas.ToArray());
|
||||
}
|
||||
|
||||
|
||||
private Manga? AddMangaToContext(Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links,
|
||||
List<MangaAltTitle>? altTitles)
|
||||
{
|
||||
@ -144,7 +154,7 @@ public class SearchController(PgsqlContext context) : Controller
|
||||
context.Manga.Update(existing);
|
||||
else
|
||||
context.Manga.Add(manga);
|
||||
|
||||
|
||||
context.SaveChanges();
|
||||
return existing ?? manga;
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
namespace API;
|
||||
|
||||
public record ProblemResponse(string title, string? message = null);
|
@ -118,7 +118,7 @@ public static class TrangaSettings
|
||||
ExportSettings();
|
||||
}
|
||||
|
||||
public static void ResetRateLimits()
|
||||
public static void ResetRequestLimits()
|
||||
{
|
||||
requestLimits = DefaultRequestLimits;
|
||||
ExportSettings();
|
||||
|
Loading…
x
Reference in New Issue
Block a user