This commit is contained in:
2020-05-22 21:09:29 +00:00
parent 6060d5a6d1
commit 8c546b3779
4 changed files with 52 additions and 4 deletions

View File

@@ -80,11 +80,11 @@ namespace AyaNova.Api.Controllers
/// Get Operations log for a job
/// </summary>
/// <param name="gid"></param>
/// <returns>A tag</returns>
/// <returns>A single job's log</returns>
[HttpGet("logs/{gid}")]
public async Task<IActionResult> GetLogs([FromRoute] Guid gid)
{
if (serverState.IsClosed)
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
@@ -105,6 +105,34 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Get Operations log for all jobs
/// </summary>
/// <returns>Log for all jobs in system</returns>
[HttpGet("logs/all-jobs")]
public async Task<IActionResult> GetAllLogs()
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
if (!ModelState.IsValid)
{
return BadRequest(new ApiErrorResponse(ModelState));
}
//Instantiate the business object handler
JobOperationsBiz biz = new JobOperationsBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
List<JobOperationsLogInfoItem> l = await biz.GetAllJobsLogsListAsync();
return Ok(ApiOkResponse.Response(l));
}