2022-07-15 15:30:14 +02:00
|
|
|
import { ClientLogCreate, HttpStatusCode, ServerLogLevel } from '@shared/models'
|
2021-07-06 10:34:29 +02:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
|
|
|
export class LogsCommand extends AbstractCommand {
|
|
|
|
|
2022-07-15 15:30:14 +02:00
|
|
|
createLogClient (options: OverrideCommandOptions & { payload: ClientLogCreate }) {
|
|
|
|
const path = '/api/v1/server/logs/client'
|
|
|
|
|
|
|
|
return this.postBodyRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
fields: options.payload,
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-07-06 10:34:29 +02:00
|
|
|
getLogs (options: OverrideCommandOptions & {
|
|
|
|
startDate: Date
|
|
|
|
endDate?: Date
|
2022-07-15 15:30:14 +02:00
|
|
|
level?: ServerLogLevel
|
2021-10-20 14:23:32 +02:00
|
|
|
tagsOneOf?: string[]
|
2021-07-06 10:34:29 +02:00
|
|
|
}) {
|
2021-10-20 14:23:32 +02:00
|
|
|
const { startDate, endDate, tagsOneOf, level } = options
|
2021-07-06 10:34:29 +02:00
|
|
|
const path = '/api/v1/server/logs'
|
|
|
|
|
2021-10-20 14:23:32 +02:00
|
|
|
return this.getRequestBody<any[]>({
|
2021-07-06 10:34:29 +02:00
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
2021-10-20 14:23:32 +02:00
|
|
|
query: { startDate, endDate, level, tagsOneOf },
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-06 10:34:29 +02: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 },
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-06 10:34:29 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|