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 (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) {
6 const path = '/api/v1/server/redundancy/' + host
8 return makePutBodyRequest({
12 fields: { redundancyAllowed },
13 statusCodeExpected: expectedStatus
17 function listVideoRedundancies (options: {
20 target: VideoRedundanciesTarget
24 statusCodeExpected?: HttpStatusCode
26 const path = '/api/v1/server/redundancy/videos'
28 const { url, accessToken, target, statusCodeExpected, start, count, sort } = options
30 return makeGetRequest({
40 statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200
44 function addVideoRedundancy (options: {
49 const path = '/api/v1/server/redundancy/videos'
50 const { url, accessToken, videoId } = options
52 return makePostBodyRequest({
57 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
61 function removeVideoRedundancy (options: {
66 const { url, accessToken, redundancyId } = options
67 const path = '/api/v1/server/redundancy/videos/' + redundancyId
69 return makeDeleteRequest({
73 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
79 listVideoRedundancies,