From bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Dec 2021 09:29:23 +0100 Subject: shared/ typescript types dir server-commands --- shared/server-commands/logs/index.ts | 1 + shared/server-commands/logs/logs-command.ts | 44 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 shared/server-commands/logs/index.ts create mode 100644 shared/server-commands/logs/logs-command.ts (limited to 'shared/server-commands/logs') diff --git a/shared/server-commands/logs/index.ts b/shared/server-commands/logs/index.ts new file mode 100644 index 000000000..69452d7f0 --- /dev/null +++ b/shared/server-commands/logs/index.ts @@ -0,0 +1 @@ +export * from './logs-command' diff --git a/shared/server-commands/logs/logs-command.ts b/shared/server-commands/logs/logs-command.ts new file mode 100644 index 000000000..7b5c66c0c --- /dev/null +++ b/shared/server-commands/logs/logs-command.ts @@ -0,0 +1,44 @@ +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({ + ...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 + }) + } + +} -- cgit v1.2.3