JobController XML-Documentation

This commit is contained in:
Glax 2025-03-07 12:31:10 +01:00
parent 9fca2d81ab
commit 3305519307

View File

@ -15,7 +15,7 @@ public class JobController(PgsqlContext context) : Controller
/// <summary> /// <summary>
/// Returns all Jobs /// Returns all Jobs
/// </summary> /// </summary>
/// <returns>Array of Jobs</returns> /// <response code="200"></response>
[HttpGet] [HttpGet]
[ProducesResponseType<Job[]>(Status200OK)] [ProducesResponseType<Job[]>(Status200OK)]
public IActionResult GetAllJobs() public IActionResult GetAllJobs()
@ -28,7 +28,7 @@ public class JobController(PgsqlContext context) : Controller
/// Returns Jobs with requested Job-IDs /// Returns Jobs with requested Job-IDs
/// </summary> /// </summary>
/// <param name="ids">Array of Job-IDs</param> /// <param name="ids">Array of Job-IDs</param>
/// <returns>Array of Jobs</returns> /// <response code="200"></response>
[HttpPost("WithIDs")] [HttpPost("WithIDs")]
[ProducesResponseType<Job[]>(Status200OK)] [ProducesResponseType<Job[]>(Status200OK)]
public IActionResult GetJobs([FromBody]string[] ids) public IActionResult GetJobs([FromBody]string[] ids)
@ -41,7 +41,7 @@ public class JobController(PgsqlContext context) : Controller
/// Get all Jobs in requested State /// Get all Jobs in requested State
/// </summary> /// </summary>
/// <param name="state">Requested Job-State</param> /// <param name="state">Requested Job-State</param>
/// <returns>Array of Jobs</returns> /// <response code="200"></response>
[HttpGet("State/{state}")] [HttpGet("State/{state}")]
[ProducesResponseType<Job[]>(Status200OK)] [ProducesResponseType<Job[]>(Status200OK)]
public IActionResult GetJobsInState(JobState state) public IActionResult GetJobsInState(JobState state)
@ -54,7 +54,7 @@ public class JobController(PgsqlContext context) : Controller
/// Returns all Jobs of requested Type /// Returns all Jobs of requested Type
/// </summary> /// </summary>
/// <param name="type">Requested Job-Type</param> /// <param name="type">Requested Job-Type</param>
/// <returns>Array of Jobs</returns> /// <response code="200"></response>
[HttpGet("Type/{type}")] [HttpGet("Type/{type}")]
[ProducesResponseType<Job[]>(Status200OK)] [ProducesResponseType<Job[]>(Status200OK)]
public IActionResult GetJobsOfType(JobType type) public IActionResult GetJobsOfType(JobType type)
@ -67,7 +67,8 @@ public class JobController(PgsqlContext context) : Controller
/// Return Job with ID /// Return Job with ID
/// </summary> /// </summary>
/// <param name="id">Job-ID</param> /// <param name="id">Job-ID</param>
/// <returns>Job</returns> /// <response code="200"></response>
/// <response code="404">Job with ID could not be found</response>
[HttpGet("{id}")] [HttpGet("{id}")]
[ProducesResponseType<Job>(Status200OK)] [ProducesResponseType<Job>(Status200OK)]
[ProducesResponseType(Status404NotFound)] [ProducesResponseType(Status404NotFound)]
@ -84,8 +85,10 @@ public class JobController(PgsqlContext context) : Controller
/// <summary> /// <summary>
/// Create a new CreateNewDownloadChapterJob /// Create a new CreateNewDownloadChapterJob
/// </summary> /// </summary>
/// <param name="request">ID of the Manga, and how often we check again</param> /// <param name="mangaId">ID of Manga</param>
/// <returns>Nothing</returns> /// <param name="recurrenceTime">How often should we check for new chapters</param>
/// <response code="201">Created new Job</response>
/// <response code="500">Error during Database Operation</response>
[HttpPut("NewDownloadChapterJob/{mangaId}")] [HttpPut("NewDownloadChapterJob/{mangaId}")]
[ProducesResponseType(Status201Created)] [ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)] [ProducesResponseType<string>(Status500InternalServerError)]
@ -99,7 +102,8 @@ public class JobController(PgsqlContext context) : Controller
/// Create a new DownloadSingleChapterJob /// Create a new DownloadSingleChapterJob
/// </summary> /// </summary>
/// <param name="chapterId">ID of the Chapter</param> /// <param name="chapterId">ID of the Chapter</param>
/// <returns>Nothing</returns> /// <response code="201">Created new Job</response>
/// <response code="500">Error during Database Operation</response>
[HttpPut("DownloadSingleChapterJob/{chapterId}")] [HttpPut("DownloadSingleChapterJob/{chapterId}")]
[ProducesResponseType(Status201Created)] [ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)] [ProducesResponseType<string>(Status500InternalServerError)]
@ -113,7 +117,8 @@ public class JobController(PgsqlContext context) : Controller
/// Create a new UpdateMetadataJob /// Create a new UpdateMetadataJob
/// </summary> /// </summary>
/// <param name="mangaId">ID of the Manga</param> /// <param name="mangaId">ID of the Manga</param>
/// <returns>Nothing</returns> /// <response code="201">Created new Job</response>
/// <response code="500">Error during Database Operation</response>
[HttpPut("UpdateMetadataJob/{mangaId}")] [HttpPut("UpdateMetadataJob/{mangaId}")]
[ProducesResponseType(Status201Created)] [ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)] [ProducesResponseType<string>(Status500InternalServerError)]
@ -126,7 +131,8 @@ public class JobController(PgsqlContext context) : Controller
/// <summary> /// <summary>
/// Create a new UpdateMetadataJob for all Manga /// Create a new UpdateMetadataJob for all Manga
/// </summary> /// </summary>
/// <returns>Nothing</returns> /// <response code="201">Created new Job</response>
/// <response code="500">Error during Database Operation</response>
[HttpPut("UpdateMetadataJob")] [HttpPut("UpdateMetadataJob")]
[ProducesResponseType(Status201Created)] [ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)] [ProducesResponseType<string>(Status500InternalServerError)]
@ -161,12 +167,14 @@ public class JobController(PgsqlContext context) : Controller
} }
/// <summary> /// <summary>
/// Delete Job with ID /// Delete Job with ID and all children
/// </summary> /// </summary>
/// <param name="id">Job-ID</param> /// <param name="id">Job-ID</param>
/// <returns>Nothing</returns> /// <response code="200">Job(s) deleted</response>
/// <response code="404">Job could not be found</response>
/// <response code="500">Error during Database Operation</response>
[HttpDelete("{id}")] [HttpDelete("{id}")]
[ProducesResponseType(Status200OK)] [ProducesResponseType<string[]>(Status200OK)]
[ProducesResponseType(Status404NotFound)] [ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status500InternalServerError)] [ProducesResponseType(Status500InternalServerError)]
public IActionResult DeleteJob(string id) public IActionResult DeleteJob(string id)
@ -181,7 +189,7 @@ public class JobController(PgsqlContext context) : Controller
context.RemoveRange(children); context.RemoveRange(children);
context.Remove(ret); context.Remove(ret);
context.SaveChanges(); context.SaveChanges();
return Ok(); return new OkObjectResult(children.Select(x => x.JobId).Append(ret.JobId).ToArray());
} }
catch (Exception e) catch (Exception e)
{ {
@ -265,7 +273,7 @@ public class JobController(PgsqlContext context) : Controller
} }
/// <summary> /// <summary>
/// NOT IMPLEMENTED. Stops the Job with the requested ID /// Stops the Job with the requested ID
/// </summary> /// </summary>
/// <param name="id">Job-ID</param> /// <param name="id">Job-ID</param>
/// <response code="202">Job started</response> /// <response code="202">Job started</response>