1 import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
2 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 export class RedundancyCommand extends AbstractCommand {
7 updateRedundancy (options: OverrideCommandOptions & {
9 redundancyAllowed: boolean
11 const { host, redundancyAllowed } = options
12 const path = '/api/v1/server/redundancy/' + host
14 return this.putBodyRequest({
18 fields: { redundancyAllowed },
19 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
23 listVideos (options: OverrideCommandOptions & {
24 target: VideoRedundanciesTarget
29 const path = '/api/v1/server/redundancy/videos'
31 const { target, start, count, sort } = options
33 return this.getRequestBody<ResultList<VideoRedundancy>>({
45 defaultExpectedStatus: HttpStatusCode.OK_200
49 addVideo (options: OverrideCommandOptions & {
52 const path = '/api/v1/server/redundancy/videos'
53 const { videoId } = options
55 return this.postBodyRequest({
60 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
64 removeVideo (options: OverrideCommandOptions & {
67 const { redundancyId } = options
68 const path = '/api/v1/server/redundancy/videos/' + redundancyId
70 return this.deleteRequest({
74 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204