Files
Automata/packages/cli/src/controllers/orchestration.controller.ts
Iván Ovejero f667b384c9 refactor(core): Standardize filenames in cli (no-changelog) (#10484)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-08-22 11:10:37 +02:00

39 lines
1.2 KiB
TypeScript

import { Post, RestController, GlobalScope } from '@/decorators';
import { OrchestrationRequest } from '@/requests';
import { OrchestrationService } from '@/services/orchestration.service';
import { License } from '@/license';
@RestController('/orchestration')
export class OrchestrationController {
constructor(
private readonly orchestrationService: OrchestrationService,
private readonly licenseService: License,
) {}
/**
* These endpoints do not return anything, they just trigger the message to
* the workers to respond on Redis with their status.
*/
@GlobalScope('orchestration:read')
@Post('/worker/status/:id')
async getWorkersStatus(req: OrchestrationRequest.Get) {
if (!this.licenseService.isWorkerViewLicensed()) return;
const id = req.params.id;
return await this.orchestrationService.getWorkerStatus(id);
}
@GlobalScope('orchestration:read')
@Post('/worker/status')
async getWorkersStatusAll() {
if (!this.licenseService.isWorkerViewLicensed()) return;
return await this.orchestrationService.getWorkerStatus();
}
@GlobalScope('orchestration:list')
@Post('/worker/ids')
async getWorkerIdsAll() {
if (!this.licenseService.isWorkerViewLicensed()) return;
return await this.orchestrationService.getWorkerIds();
}
}