mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 14:57:53 +02:00
Add Endpoint GET /v2/Job returns list of jobs specified by jobid
This commit is contained in:
@ -37,6 +37,7 @@ public partial class Server : GlobalBase, IDisposable
|
||||
new ("GET", @"/v2/Jobs/Monitoring", GetV2JobsMonitoring),
|
||||
new ("Get", @"/v2/Job/Types", GetV2JobTypes),
|
||||
new ("POST", @"/v2/Job/Create/([a-zA-Z]+)", PostV2JobCreateType),
|
||||
new ("GET", @"/v2/Job", GetV2Job),
|
||||
new ("GET", @"/v2/Job/([a-zA-Z\.]+-[-A-Za-z0-9+/]*={0,3}(?:-[0-9]+)?)", GetV2JobJobId),
|
||||
new ("DELETE", @"/v2/Job/([a-zA-Z\.]+-[-A-Za-z0-9+/]*={0,3}(?:-[0-9]+)?)", DeleteV2JobJobId),
|
||||
new ("GET", @"/v2/Job/([a-zA-Z\.]+-[-A-Za-z0-9+/]*={0,3}(?:-[0-9]+)?)/Progress", GetV2JobJobIdProgress),
|
||||
|
@ -150,5 +150,20 @@ public partial class Server
|
||||
job.Cancel();
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, null);
|
||||
}
|
||||
|
||||
|
||||
private ValueTuple<HttpStatusCode, object?> GetV2Job(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||
{
|
||||
if(!requestParameters.TryGetValue("jobIds", out string? jobIdListStr))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, "Missing parameter 'jobIds'.");
|
||||
string[] jobIdList = jobIdListStr.Split(',');
|
||||
List<Job> ret = new();
|
||||
foreach (string jobId in jobIdList)
|
||||
{
|
||||
if(!_parent.jobBoss.TryGetJobById(jobId, out Job? job) || job is null)
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"Job with id '{jobId}' not found.");
|
||||
ret.Add(job);
|
||||
}
|
||||
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user