File

src/alerts/alerts.controller.ts

Prefix

alerts

Index

Methods

Methods

Async acknowledge
acknowledge(id: string)
Decorators :
@Post(':id/acknowledge')
@ApiOperation({summary: 'Acknowledge an alert'})
Parameters :
Name Type Optional
id string No
Returns : unknown
Async create
create(orgId: string, dto: CreateAlertDto)
Decorators :
@Post()
@ApiOperation({summary: 'Create a new alert'})
Parameters :
Name Type Optional
orgId string No
dto CreateAlertDto No
Returns : unknown
Async findAll
findAll(orgId: string, query: PaginationParams)
Decorators :
@Get()
@ApiPagination()
@ApiOperation({summary: 'List all alerts'})
Parameters :
Name Type Optional
orgId string No
query PaginationParams No
Returns : unknown
Async findOne
findOne(id: string)
Decorators :
@Get(':id')
@ApiOperation({summary: 'Get alert by ID'})
Parameters :
Name Type Optional
id string No
Returns : unknown
Async getStats
getStats(orgId: string)
Decorators :
@Get('stats')
@ApiOperation({summary: 'Get alert statistics'})
Parameters :
Name Type Optional
orgId string No
Returns : unknown
Async remove
remove(id: string)
Decorators :
@Delete(':id')
@ApiOperation({summary: 'Delete an alert'})
Parameters :
Name Type Optional
id string No
Returns : unknown
Async resolve
resolve(id: string)
Decorators :
@Post(':id/resolve')
@ApiOperation({summary: 'Resolve an alert'})
Parameters :
Name Type Optional
id string No
Returns : unknown
Async update
update(id: string, dto: UpdateAlertDto)
Decorators :
@Patch(':id')
@ApiOperation({summary: 'Update an alert'})
Parameters :
Name Type Optional
id string No
dto UpdateAlertDto No
Returns : unknown
import {
  Controller,
  Get,
  Post,
  Patch,
  Delete,
  Body,
  Param,
  Query,
  UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { AlertsService } from './alerts.service';
import { CreateAlertDto } from './dto/create-alert.dto';
import { UpdateAlertDto } from './dto/update-alert.dto';
import { CombinedAuthGuard } from '../auth/guards/combined-auth.guard';
import { RolesGuard } from '../auth/guards/roles.guard';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { ApiPagination } from '../common/decorators/api-pagination.decorator';
import { PaginationParams } from '../common/utils/pagination.util';

@ApiTags('Alerts')
@ApiBearerAuth()
@UseGuards(CombinedAuthGuard, RolesGuard)
@Controller('alerts')
export class AlertsController {
  constructor(private readonly alertsService: AlertsService) {}

  @Post()
  @ApiOperation({ summary: 'Create a new alert' })
  async create(
    @CurrentUser('organizationId') orgId: string,
    @Body() dto: CreateAlertDto,
  ) {
    return this.alertsService.create(orgId, dto);
  }

  @Get('stats')
  @ApiOperation({ summary: 'Get alert statistics' })
  async getStats(@CurrentUser('organizationId') orgId: string) {
    return this.alertsService.getStats(orgId);
  }

  @Get()
  @ApiPagination()
  @ApiOperation({ summary: 'List all alerts' })
  async findAll(
    @CurrentUser('organizationId') orgId: string,
    @Query() query: PaginationParams,
  ) {
    return this.alertsService.findAll(orgId, query);
  }

  @Get(':id')
  @ApiOperation({ summary: 'Get alert by ID' })
  async findOne(@Param('id') id: string) {
    return this.alertsService.findOne(id);
  }

  @Patch(':id')
  @ApiOperation({ summary: 'Update an alert' })
  async update(@Param('id') id: string, @Body() dto: UpdateAlertDto) {
    return this.alertsService.update(id, dto);
  }

  @Post(':id/acknowledge')
  @ApiOperation({ summary: 'Acknowledge an alert' })
  async acknowledge(@Param('id') id: string) {
    return this.alertsService.acknowledge(id);
  }

  @Post(':id/resolve')
  @ApiOperation({ summary: 'Resolve an alert' })
  async resolve(@Param('id') id: string) {
    return this.alertsService.resolve(id);
  }

  @Delete(':id')
  @ApiOperation({ summary: 'Delete an alert' })
  async remove(@Param('id') id: string) {
    return this.alertsService.remove(id);
  }
}

results matching ""

    No results matching ""