aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/extra-utils/logs/logs-command.ts
blob: 7b5c66c0ccb6fb989a1688a5900f769808d60ad8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                               








                                                                   
                        
      
                                                            

                                      
                                       


                 
                                                      
                          
















                                                   
                          




                                                  
import { HttpStatusCode } from '@shared/models'
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
    tagsOneOf?: string[]
  }) {
    const { startDate, endDate, tagsOneOf, level } = options
    const path = '/api/v1/server/logs'

    return this.getRequestBody<any[]>({
      ...options,

      path,
      query: { startDate, endDate, level, tagsOneOf },
      implicitToken: true,
      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,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

}