import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ListLauncherSshKeysQuery, CreateDeviceAuthorizationDto, ListDeviceAuthorizationUsersQuery, ListProvisionedDevicesQuery, UpdateProvisionedDeviceDto, } from './dto'; import { AgentsService } from './agents.service'; @Controller('agents') export class AgentsController { constructor(private readonly agentsService: AgentsService) {} @Get('devices') listDevices(@Query() query: ListProvisionedDevicesQuery) { return this.agentsService.listDevices(query); } @Get('devices/:id') getDevice(@Param('id') id: string) { return this.agentsService.getDevice(id); } @Patch('devices/:id') updateDevice( @Param('id') id: string, @Body() body: UpdateProvisionedDeviceDto, ) { return this.agentsService.updateDevice(id, body); } @Get('ssh-keys') listSshKeys(@Query() query: ListLauncherSshKeysQuery) { return this.agentsService.listSshKeys(query); } @Delete('ssh-keys/:id') removeSshKey(@Param('id') id: string) { return this.agentsService.removeSshKey(id); } @Get('registration-users') listRegistrationUsers(@Query() query: ListDeviceAuthorizationUsersQuery) { return this.agentsService.listRegistrationUsers(query); } @Get('device-authorizations') listDeviceAuthorizations() { return this.agentsService.listDeviceAuthorizations(); } @Post('device-authorizations') createDeviceAuthorization(@Body() body: CreateDeviceAuthorizationDto) { return this.agentsService.createDeviceAuthorization(body.userId); } @Post('device-authorizations/:id/cancel') cancelDeviceAuthorization(@Param('id') id: string) { return this.agentsService.cancelDeviceAuthorization(id); } }