This commit is contained in:
@@ -74,6 +74,28 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get current job status for a job
|
||||
/// </summary>
|
||||
/// <param name="gid"></param>
|
||||
/// <returns>A single job's current status</returns>
|
||||
[HttpGet("status/{gid}")]
|
||||
public async Task<IActionResult> GetJobStatus([FromRoute] Guid gid)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
//This is called by the UI to monitor any operation that triggers a job so it really should be available to any logged in user
|
||||
// if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerJob))
|
||||
// {
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// }
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
return Ok(ApiOkResponse.Response(await JobsBiz.GetJobStatusAsync(gid)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +170,7 @@ namespace AyaNova.Api.Controllers
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = "TestJob";
|
||||
j.JobType = JobType.TestJob;
|
||||
await JobsBiz.AddJobAsync(j);
|
||||
await JobsBiz.AddJobAsync(j);
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.ServerJob, AyaEvent.Created, $"{j.JobType} {j.Name}"), ct);
|
||||
return Accepted(new { JobId = j.GId });//202 accepted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user