]>
Commit | Line | Data |
---|---|---|
dab04709 C |
1 | import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
4 | ||
5 | export class RedundancyCommand extends AbstractCommand { | |
6 | ||
7 | updateRedundancy (options: OverrideCommandOptions & { | |
8 | host: string | |
9 | redundancyAllowed: boolean | |
10 | }) { | |
11 | const { host, redundancyAllowed } = options | |
12 | const path = '/api/v1/server/redundancy/' + host | |
13 | ||
14 | return this.putBodyRequest({ | |
15 | ...options, | |
16 | ||
17 | path, | |
18 | fields: { redundancyAllowed }, | |
19 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | |
20 | }) | |
21 | } | |
22 | ||
23 | listVideos (options: OverrideCommandOptions & { | |
24 | target: VideoRedundanciesTarget | |
25 | start?: number | |
26 | count?: number | |
27 | sort?: string | |
28 | }) { | |
29 | const path = '/api/v1/server/redundancy/videos' | |
30 | ||
31 | const { target, start, count, sort } = options | |
32 | ||
33 | return this.getRequestBody<ResultList<VideoRedundancy>>({ | |
34 | ...options, | |
35 | ||
36 | path, | |
37 | ||
38 | query: { | |
39 | start: start ?? 0, | |
40 | count: count ?? 5, | |
41 | sort: sort ?? 'name', | |
42 | target | |
43 | }, | |
44 | ||
45 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
46 | }) | |
47 | } | |
48 | ||
49 | addVideo (options: OverrideCommandOptions & { | |
50 | videoId: number | |
51 | }) { | |
52 | const path = '/api/v1/server/redundancy/videos' | |
53 | const { videoId } = options | |
54 | ||
55 | return this.postBodyRequest({ | |
56 | ...options, | |
57 | ||
58 | path, | |
59 | fields: { videoId }, | |
60 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | |
61 | }) | |
62 | } | |
63 | ||
64 | removeVideo (options: OverrideCommandOptions & { | |
65 | redundancyId: number | |
66 | }) { | |
67 | const { redundancyId } = options | |
68 | const path = '/api/v1/server/redundancy/videos/' + redundancyId | |
69 | ||
70 | return this.deleteRequest({ | |
71 | ...options, | |
72 | ||
73 | path, | |
74 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | |
75 | }) | |
76 | } | |
77 | } |