diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
commit | bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (patch) | |
tree | 54b40aaf01bae210632473285c3c7571d51e4f89 /shared/server-commands/logs/logs-command.ts | |
parent | 6b5f72beda96d8b7e4d6329c4001827334de27dd (diff) | |
download | PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.gz PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.zst PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.zip |
shared/ typescript types dir server-commands
Diffstat (limited to 'shared/server-commands/logs/logs-command.ts')
-rw-r--r-- | shared/server-commands/logs/logs-command.ts | 44 |
1 files changed, 44 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..7b5c66c0c --- /dev/null +++ b/shared/server-commands/logs/logs-command.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { LogLevel } from '../../models/server/log-level.type' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
4 | |||
5 | export class LogsCommand extends AbstractCommand { | ||
6 | |||
7 | getLogs (options: OverrideCommandOptions & { | ||
8 | startDate: Date | ||
9 | endDate?: Date | ||
10 | level?: LogLevel | ||
11 | tagsOneOf?: string[] | ||
12 | }) { | ||
13 | const { startDate, endDate, tagsOneOf, level } = options | ||
14 | const path = '/api/v1/server/logs' | ||
15 | |||
16 | return this.getRequestBody<any[]>({ | ||
17 | ...options, | ||
18 | |||
19 | path, | ||
20 | query: { startDate, endDate, level, tagsOneOf }, | ||
21 | implicitToken: true, | ||
22 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
23 | }) | ||
24 | } | ||
25 | |||
26 | getAuditLogs (options: OverrideCommandOptions & { | ||
27 | startDate: Date | ||
28 | endDate?: Date | ||
29 | }) { | ||
30 | const { startDate, endDate } = options | ||
31 | |||
32 | const path = '/api/v1/server/audit-logs' | ||
33 | |||
34 | return this.getRequestBody({ | ||
35 | ...options, | ||
36 | |||
37 | path, | ||
38 | query: { startDate, endDate }, | ||
39 | implicitToken: true, | ||
40 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
41 | }) | ||
42 | } | ||
43 | |||
44 | } | ||