/**
 * 云服务器管理路由
 * 提供云服务器购买、续费、管理的API接口
 */

import { Router } from 'express';
import {
  getProviders,
  getRegions,
  getInstanceTypes,
  getImages,
  createInstance,
  getInstances,
  getInstance,
  startInstance,
  stopInstance,
  rebootInstance,
  renewInstance,
  deleteInstance,
  createRemoteSession,
  executeRemoteCommand,
  getActiveSessions,
  closeSession,
  getInstanceMetrics
} from '../controllers/cloud-controller';

const router = Router();

// 云服务商相关接口
router.get('/providers', getProviders);
router.get('/providers/:provider/regions', getRegions);
router.get('/providers/:provider/regions/:region/instance-types', getInstanceTypes);
router.get('/providers/:provider/regions/:region/images', getImages);

// 实例管理接口
router.post('/instances', createInstance);
router.get('/instances', getInstances);
router.get('/instances/:instanceId', getInstance);
router.post('/instances/:instanceId/start', startInstance);
router.post('/instances/:instanceId/stop', stopInstance);
router.post('/instances/:instanceId/reboot', rebootInstance);
router.post('/instances/:instanceId/renew', renewInstance);
router.delete('/instances/:instanceId', deleteInstance);

// 监控接口
router.get('/instances/:instanceId/metrics', getInstanceMetrics);

// 远程管理接口
router.post('/remote/sessions', createRemoteSession);
router.get('/remote/sessions', getActiveSessions);
router.post('/remote/sessions/:sessionId/command', executeRemoteCommand);
router.delete('/remote/sessions/:sessionId', closeSession);

export default router;