mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Introduce redundancy command
This commit is contained in:
parent
ae2abfd3ae
commit
dab047092b
7 changed files with 166 additions and 247 deletions
77
shared/extra-utils/server/redundancy-command.ts
Normal file
77
shared/extra-utils/server/redundancy-command.ts
Normal file
|
@ -0,0 +1,77 @@
|
|||
import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||
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 },
|
||||
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
|
||||
},
|
||||
|
||||
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 },
|
||||
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,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue