Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
Query,
HttpCode,
HttpStatus,
} from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiParam,
ApiQuery,
} from '@nestjs/swagger';
import { SubAgentsService } from './sub-agents.service';
import { CreateSubAgentDto } from './dto/create-sub-agent.dto';
import { UpdateSubAgentDto } from './dto/update-sub-agent.dto';
@ApiTags('sub-agents')
@Controller('sub-agents')
export class SubAgentsController {
constructor(private readonly subAgentsService: SubAgentsService) {}
@Post()
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'Create a sub-agent' })
@ApiResponse({ status: 201, description: 'Sub-agent created' })
create(@Body() createSubAgentDto: CreateSubAgentDto) {
return this.subAgentsService.create(createSubAgentDto);
}
@Get()
@ApiOperation({ summary: 'List sub-agents (optional filter by active)' })
@ApiQuery({
name: 'activeOnly',
required: false,
description: 'Filter to only active sub-agents',
type: Boolean,
})
@ApiResponse({ status: 200, description: 'List of sub-agents' })
findAll(@Query('activeOnly') activeOnly?: boolean) {
return this.subAgentsService.findAll(activeOnly);
}
@Get(':id')
@ApiOperation({ summary: 'Get a sub-agent by ID' })
@ApiParam({ name: 'id', description: 'Sub-agent UUID', format: 'uuid' })
@ApiResponse({ status: 200, description: 'Sub-agent found' })
@ApiResponse({ status: 404, description: 'Sub-agent not found' })
findOne(@Param('id') id: string) {
return this.subAgentsService.findOne(id);
}
@Patch(':id')
@ApiOperation({ summary: 'Update a sub-agent' })
@ApiParam({ name: 'id', description: 'Sub-agent UUID', format: 'uuid' })
@ApiResponse({ status: 200, description: 'Sub-agent updated' })
@ApiResponse({ status: 403, description: 'Cannot modify built-in sub-agent' })
@ApiResponse({ status: 404, description: 'Sub-agent not found' })
update(
@Param('id') id: string,
@Body() updateSubAgentDto: UpdateSubAgentDto,
) {
return this.subAgentsService.update(id, updateSubAgentDto);
}
@Delete(':id')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Delete a sub-agent' })
@ApiParam({ name: 'id', description: 'Sub-agent UUID', format: 'uuid' })
@ApiResponse({ status: 204, description: 'Sub-agent deleted' })
@ApiResponse({ status: 403, description: 'Cannot delete built-in sub-agent' })
@ApiResponse({ status: 404, description: 'Sub-agent not found' })
remove(@Param('id') id: string) {
return this.subAgentsService.remove(id);
}
@Post(':id/duplicate')
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'Duplicate a sub-agent' })
@ApiParam({
name: 'id',
description: 'Sub-agent UUID to duplicate',
format: 'uuid',
})
@ApiResponse({ status: 201, description: 'Sub-agent duplicated' })
@ApiResponse({ status: 404, description: 'Sub-agent not found' })
async duplicate(@Param('id') id: string) {
return this.subAgentsService.duplicate(id);
}
}
|