2021-07-16 14:27:30 +02:00
|
|
|
import { HttpStatusCode, ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
|
2021-07-07 10:56:45 +02:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
|
|
|
export class RedundancyCommand extends AbstractCommand {
|
|
|
|
|
|
|
|
updateRedundancy (options: OverrideCommandOptions & {
|
|
|
|
host: string
|
|
|
|
redundancyAllowed: boolean
|
|
|
|
}) {
|
|
|
|
const { host, redundancyAllowed } = options
|
|
|
|
const path = '/api/v1/server/redundancy/' + host
|
|
|
|
|
|
|
|
return this.putBodyRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
fields: { redundancyAllowed },
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-07 10:56:45 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
listVideos (options: OverrideCommandOptions & {
|
|
|
|
target: VideoRedundanciesTarget
|
|
|
|
start?: number
|
|
|
|
count?: number
|
|
|
|
sort?: string
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/server/redundancy/videos'
|
|
|
|
|
|
|
|
const { target, start, count, sort } = options
|
|
|
|
|
|
|
|
return this.getRequestBody<ResultList<VideoRedundancy>>({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
|
|
|
|
query: {
|
|
|
|
start: start ?? 0,
|
|
|
|
count: count ?? 5,
|
|
|
|
sort: sort ?? 'name',
|
|
|
|
target
|
|
|
|
},
|
|
|
|
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-07 10:56:45 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
addVideo (options: OverrideCommandOptions & {
|
|
|
|
videoId: number
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/server/redundancy/videos'
|
|
|
|
const { videoId } = options
|
|
|
|
|
|
|
|
return this.postBodyRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
fields: { videoId },
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-07 10:56:45 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
removeVideo (options: OverrideCommandOptions & {
|
|
|
|
redundancyId: number
|
|
|
|
}) {
|
|
|
|
const { redundancyId } = options
|
|
|
|
const path = '/api/v1/server/redundancy/videos/' + redundancyId
|
|
|
|
|
|
|
|
return this.deleteRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-07 10:56:45 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|