This commit is contained in:
2020-05-23 18:39:39 +00:00
parent 65479bd903
commit 60aa652b9d
6 changed files with 63 additions and 62 deletions

View File

@@ -134,7 +134,24 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Trigger a test job that simulates a (30 second) long running operation for testing and ops confirmation
/// </summary>
/// <returns>Job id</returns>
[HttpPost("test-job")]
public async Task<IActionResult> TestWidgetJob()
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.ServerJob))
return StatusCode(403, new ApiNotAuthorizedResponse());
OpsJob j = new OpsJob();
j.Name = "TestJob";
j.JobType = JobType.TestJob;
await JobsBiz.AddJobAsync(j, ct);
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
}
//------------