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 },
20 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
24 listVideos (options: OverrideCommandOptions & {
25 target: VideoRedundanciesTarget
30 const path = '/api/v1/server/redundancy/videos'
32 const { target, start, count, sort } = options
34 return this.getRequestBody<ResultList<VideoRedundancy>>({
47 defaultExpectedStatus: HttpStatusCode.OK_200
51 addVideo (options: OverrideCommandOptions & {
54 const path = '/api/v1/server/redundancy/videos'
55 const { videoId } = options
57 return this.postBodyRequest({
63 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
67 removeVideo (options: OverrideCommandOptions & {
70 const { redundancyId } = options
71 const path = '/api/v1/server/redundancy/videos/' + redundancyId
73 return this.deleteRequest({
78 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204