1 import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
2 import { VideoRedundanciesTarget } from '@shared/models'
3 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
5 function updateRedundancy (
9 redundancyAllowed: boolean,
10 expectedStatus = HttpStatusCode.NO_CONTENT_204
12 const path = '/api/v1/server/redundancy/' + host
14 return makePutBodyRequest({
18 fields: { redundancyAllowed },
19 statusCodeExpected: expectedStatus
23 function listVideoRedundancies (options: {
26 target: VideoRedundanciesTarget
30 statusCodeExpected?: HttpStatusCode
32 const path = '/api/v1/server/redundancy/videos'
34 const { url, accessToken, target, statusCodeExpected, start, count, sort } = options
36 return makeGetRequest({
46 statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200
50 function addVideoRedundancy (options: {
55 const path = '/api/v1/server/redundancy/videos'
56 const { url, accessToken, videoId } = options
58 return makePostBodyRequest({
63 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
67 function removeVideoRedundancy (options: {
72 const { url, accessToken, redundancyId } = options
73 const path = '/api/v1/server/redundancy/videos/' + redundancyId
75 return makeDeleteRequest({
79 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
85 listVideoRedundancies,