71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
|
|
|
import {
|
|
CreateAdminSshKeyDto,
|
|
CreateAdminDto,
|
|
ListAdminsQuery,
|
|
ResetAdminPasswordDto,
|
|
UpdateAdminAppPermissionsDto,
|
|
UpdateAdminRoleDto,
|
|
UpdateAdminStatusDto,
|
|
} from './dto';
|
|
import { AdminRoles } from '../admin-auth/decorators/admin-auth.decorators';
|
|
import { AdminRole } from './admin-role';
|
|
import { AdminsService } from './admins.service';
|
|
|
|
@AdminRoles(AdminRole.OWNER)
|
|
@Controller('admins')
|
|
export class AdminsController {
|
|
constructor(private readonly adminsService: AdminsService) {}
|
|
|
|
@Get('roles')
|
|
listRoles() {
|
|
return this.adminsService.listRoles();
|
|
}
|
|
|
|
@Get()
|
|
list(@Query() query: ListAdminsQuery) {
|
|
return this.adminsService.list(query);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() body: CreateAdminDto) {
|
|
return this.adminsService.create(body);
|
|
}
|
|
|
|
@Patch(':id/status')
|
|
updateStatus(@Param('id') id: string, @Body() body: UpdateAdminStatusDto) {
|
|
return this.adminsService.updateStatus(id, body);
|
|
}
|
|
|
|
@Patch(':id/role')
|
|
updateRole(@Param('id') id: string, @Body() body: UpdateAdminRoleDto) {
|
|
return this.adminsService.updateRole(id, body);
|
|
}
|
|
|
|
@Patch(':id/password')
|
|
resetPassword(@Param('id') id: string, @Body() body: ResetAdminPasswordDto) {
|
|
return this.adminsService.resetPassword(id, body);
|
|
}
|
|
|
|
@Get(':id/app-permissions')
|
|
listAppPermissions(@Param('id') id: string) {
|
|
return this.adminsService.listAppPermissions(id);
|
|
}
|
|
|
|
@Put(':id/app-permissions')
|
|
updateAppPermissions(@Param('id') id: string, @Body() body: UpdateAdminAppPermissionsDto) {
|
|
return this.adminsService.updateAppPermissions(id, body);
|
|
}
|
|
|
|
@Post(':id/ssh-keys')
|
|
createSshKey(@Param('id') id: string, @Body() body: CreateAdminSshKeyDto) {
|
|
return this.adminsService.createSshKey(id, body);
|
|
}
|
|
|
|
@Delete(':id/ssh-keys/:keyId')
|
|
deleteSshKey(@Param('id') id: string, @Param('keyId') keyId: string) {
|
|
return this.adminsService.deleteSshKey(id, keyId);
|
|
}
|
|
}
|