-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathcontrol-template.controller.ts
More file actions
112 lines (100 loc) · 2.82 KB
/
control-template.controller.ts
File metadata and controls
112 lines (100 loc) · 2.82 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import {
Controller,
Get,
Post,
Patch,
Delete,
Body,
Param,
Query,
UseGuards,
UsePipes,
ValidationPipe,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PlatformAdminGuard } from '../../auth/platform-admin.guard';
import { CreateControlTemplateDto } from './dto/create-control-template.dto';
import { UpdateControlTemplateDto } from './dto/update-control-template.dto';
import { ControlTemplateService } from './control-template.service';
@ApiTags('Framework Editor Control Templates')
@Controller({ path: 'framework-editor/control-template', version: '1' })
@UseGuards(PlatformAdminGuard)
export class ControlTemplateController {
constructor(private readonly service: ControlTemplateService) {}
@Get()
async findAll(
@Query('take') take?: string,
@Query('skip') skip?: string,
@Query('frameworkId') frameworkId?: string,
) {
const limit = Math.min(Number(take) || 500, 500);
const offset = Number(skip) || 0;
return this.service.findAll(limit, offset, frameworkId);
}
@Get(':id')
async findOne(@Param('id') id: string) {
return this.service.findById(id);
}
@Post()
@UsePipes(new ValidationPipe({ whitelist: true, transform: true }))
async create(
@Body() dto: CreateControlTemplateDto,
@Query('frameworkId') frameworkId?: string,
) {
return this.service.create(dto, frameworkId);
}
@Patch(':id')
@UsePipes(new ValidationPipe({ whitelist: true, transform: true }))
async update(
@Param('id') id: string,
@Body() dto: UpdateControlTemplateDto,
) {
return this.service.update(id, dto);
}
@Delete(':id')
async delete(@Param('id') id: string) {
return this.service.delete(id);
}
@Post(':id/requirements/:reqId')
async linkRequirement(
@Param('id') id: string,
@Param('reqId') reqId: string,
) {
return this.service.linkRequirement(id, reqId);
}
@Delete(':id/requirements/:reqId')
async unlinkRequirement(
@Param('id') id: string,
@Param('reqId') reqId: string,
) {
return this.service.unlinkRequirement(id, reqId);
}
@Post(':id/policy-templates/:ptId')
async linkPolicyTemplate(
@Param('id') id: string,
@Param('ptId') ptId: string,
) {
return this.service.linkPolicyTemplate(id, ptId);
}
@Delete(':id/policy-templates/:ptId')
async unlinkPolicyTemplate(
@Param('id') id: string,
@Param('ptId') ptId: string,
) {
return this.service.unlinkPolicyTemplate(id, ptId);
}
@Post(':id/task-templates/:ttId')
async linkTaskTemplate(
@Param('id') id: string,
@Param('ttId') ttId: string,
) {
return this.service.linkTaskTemplate(id, ttId);
}
@Delete(':id/task-templates/:ttId')
async unlinkTaskTemplate(
@Param('id') id: string,
@Param('ttId') ttId: string,
) {
return this.service.unlinkTaskTemplate(id, ttId);
}
}