diff options
Diffstat (limited to 'shared/server-commands/logs/logs-command.ts')
-rw-r--r-- | shared/server-commands/logs/logs-command.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/shared/server-commands/logs/logs-command.ts b/shared/server-commands/logs/logs-command.ts new file mode 100644 index 000000000..8f63383ea --- /dev/null +++ b/shared/server-commands/logs/logs-command.ts | |||
@@ -0,0 +1,43 @@ | |||
1 | import { HttpStatusCode, LogLevel } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class LogsCommand extends AbstractCommand { | ||
5 | |||
6 | getLogs (options: OverrideCommandOptions & { | ||
7 | startDate: Date | ||
8 | endDate?: Date | ||
9 | level?: LogLevel | ||
10 | tagsOneOf?: string[] | ||
11 | }) { | ||
12 | const { startDate, endDate, tagsOneOf, level } = options | ||
13 | const path = '/api/v1/server/logs' | ||
14 | |||
15 | return this.getRequestBody<any[]>({ | ||
16 | ...options, | ||
17 | |||
18 | path, | ||
19 | query: { startDate, endDate, level, tagsOneOf }, | ||
20 | implicitToken: true, | ||
21 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | getAuditLogs (options: OverrideCommandOptions & { | ||
26 | startDate: Date | ||
27 | endDate?: Date | ||
28 | }) { | ||
29 | const { startDate, endDate } = options | ||
30 | |||
31 | const path = '/api/v1/server/audit-logs' | ||
32 | |||
33 | return this.getRequestBody({ | ||
34 | ...options, | ||
35 | |||
36 | path, | ||
37 | query: { startDate, endDate }, | ||
38 | implicitToken: true, | ||
39 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | } | ||