1
0
Fork 0
peertube/shared/extra-utils/logs/logs-command.ts

45 lines
1 KiB
TypeScript
Raw Normal View History

2021-07-16 04:42:24 -04:00
import { HttpStatusCode } from '@shared/models'
2021-07-06 04:34:29 -04:00
import { LogLevel } from '../../models/server/log-level.type'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class LogsCommand extends AbstractCommand {
getLogs (options: OverrideCommandOptions & {
startDate: Date
endDate?: Date
level?: LogLevel
2021-10-20 08:23:32 -04:00
tagsOneOf?: string[]
2021-07-06 04:34:29 -04:00
}) {
2021-10-20 08:23:32 -04:00
const { startDate, endDate, tagsOneOf, level } = options
2021-07-06 04:34:29 -04:00
const path = '/api/v1/server/logs'
2021-10-20 08:23:32 -04:00
return this.getRequestBody<any[]>({
2021-07-06 04:34:29 -04:00
...options,
path,
2021-10-20 08:23:32 -04:00
query: { startDate, endDate, level, tagsOneOf },
implicitToken: true,
2021-07-06 04:34:29 -04:00
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getAuditLogs (options: OverrideCommandOptions & {
startDate: Date
endDate?: Date
}) {
const { startDate, endDate } = options
const path = '/api/v1/server/audit-logs'
return this.getRequestBody({
...options,
path,
query: { startDate, endDate },
implicitToken: true,
2021-07-06 04:34:29 -04:00
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
}