]>
Commit | Line | Data |
---|---|---|
9c6327f8 | 1 | import { pick } from 'lodash' |
c0e8b12e | 2 | import { HttpStatusCode } from '@shared/models' |
9c6327f8 C |
3 | import { Job, JobState, JobType, ResultList } from '../../models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
5 | ||
6 | export class JobsCommand extends AbstractCommand { | |
7 | ||
8 | getJobsList (options: OverrideCommandOptions & { | |
9 | state?: JobState | |
10 | jobType?: JobType | |
11 | start?: number | |
12 | count?: number | |
13 | sort?: string | |
14 | } = {}) { | |
15 | const path = this.buildJobsUrl(options.state) | |
16 | ||
17 | const query = pick(options, [ 'start', 'count', 'sort', 'jobType' ]) | |
18 | ||
19 | return this.getRequestBody<ResultList<Job>>({ | |
20 | ...options, | |
21 | ||
22 | path, | |
23 | query, | |
a1637fa1 | 24 | implicitToken: true, |
9c6327f8 C |
25 | defaultExpectedStatus: HttpStatusCode.OK_200 |
26 | }) | |
27 | } | |
28 | ||
29 | private buildJobsUrl (state?: JobState) { | |
30 | let path = '/api/v1/jobs' | |
31 | ||
32 | if (state) path += '/' + state | |
33 | ||
34 | return path | |
35 | } | |
36 | } |