Add Endpoint GET /v2/Job returns list of jobs specified by jobid
This commit is contained in:
parent
2e1f633f40
commit
5b22246c41
@ -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);
|
||||
}
|
||||
}
|
@ -333,6 +333,35 @@ Creates a Job.
|
||||
| 500 | Error parsing interval |
|
||||
</details>
|
||||
|
||||
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Job/`
|
||||
|
||||
Returns the list of Jobs requested.
|
||||
|
||||
<details>
|
||||
<summary>Request</summary>
|
||||
|
||||
| Parameter | Value |
|
||||
|------------|--------------------------------|
|
||||
| jobIds | Comma-Seperated list of jobIds |
|
||||
|
||||
`jobId` is returned in the response of
|
||||
* [GET /v2/Jobs](#-v2jobs)
|
||||
* [GET /v2/Jobs/Running](#-v2jobsrunning)
|
||||
* [GET /v2/Jobs/Waiting](#-v2jobswaiting)
|
||||
* [GET /v2/Jobs/Monitoring](#-v2jobsmonitoring)
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Returns</summary>
|
||||
|
||||
List of [Jobs](Types.md#job)
|
||||
|
||||
| StatusCode | Meaning |
|
||||
|------------|---------------------------------------|
|
||||
| 400 | Missing Parameter |
|
||||
| 404 | Manga with `jobId` could not be found |
|
||||
</details>
|
||||
|
||||
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Job/<jobId>`
|
||||
|
||||
Returns the specified Job.
|
||||
|
Loading…
Reference in New Issue
Block a user