import { Controller, Get, Delete, Param } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { FleetService } from './fleet.service';
import { CurrentTenant } from '../../common/decorators/current-tenant.decorator';
import { RequirePermission } from '../../common/decorators/require-permission.decorator';

@ApiTags('fleet')
@ApiBearerAuth()
@Controller('fleet')
export class FleetController {
  constructor(private readonly fleetService: FleetService) {}

  @Get()
  @RequirePermission('server.view')
  @ApiOperation({ summary: 'Get fleet overview — hosts and game instances for this license' })
  async getFleet(@CurrentTenant() licenseId: string) {
    return this.fleetService.getFleet(licenseId);
  }

  @Delete('hosts/:id')
  @RequirePermission('server.manage')
  @ApiOperation({ summary: 'Remove a host and its instances (host must be offline)' })
  async deleteHost(@CurrentTenant() licenseId: string, @Param('id') id: string) {
    return this.fleetService.deleteHost(licenseId, id);
  }
}
