aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server/debug-command.ts
blob: 36704836da388a714fd298d11efb3e3a02593842 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Debug, SendDebugCommand } from '@shared/models'
import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'

export class DebugCommand extends AbstractCommand {

  getDebug (options: OverrideCommandOptions = {}) {
    const path = '/api/v1/server/debug'

    return this.getRequestBody<Debug>({
      ...options,

      path,
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

  sendCommand (options: OverrideCommandOptions & {
    body: SendDebugCommand
  }) {
    const { body } = options
    const path = '/api/v1/server/debug/run-command'

    return this.postBodyRequest({
      ...options,

      path,
      fields: body,
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
    })
  }
}