1 import { pick } from '@shared/core-utils'
2 import { HttpStatusCode, ResultList, RunnerRegistrationToken } from '@shared/models'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 export class RunnerRegistrationTokensCommand extends AbstractCommand {
7 list (options: OverrideCommandOptions & {
12 const path = '/api/v1/runners/registration-tokens'
14 return this.getRequestBody<ResultList<RunnerRegistrationToken>>({
18 query: pick(options, [ 'start', 'count', 'sort' ]),
20 defaultExpectedStatus: HttpStatusCode.OK_200
24 generate (options: OverrideCommandOptions = {}) {
25 const path = '/api/v1/runners/registration-tokens/generate'
27 return this.postBodyRequest({
32 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
36 delete (options: OverrideCommandOptions & {
39 const path = '/api/v1/runners/registration-tokens/' + options.id
41 return this.deleteRequest({
46 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
50 async getFirstRegistrationToken (options: OverrideCommandOptions = {}) {
51 const { data } = await this.list(options)
53 return data[0].registrationToken