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