import { z } from 'zod';

export const VmCheckLevelSchema = z.enum(['OK', 'WARN', 'CRIT']);
export type VmCheckLevel = z.infer<typeof VmCheckLevelSchema>;

export const VmCheckSchema = z.object({
  level: VmCheckLevelSchema,
  value: z.string(),
  message: z.string(),
});
export type VmCheck = z.infer<typeof VmCheckSchema>;

export const VmHealthResultSchema = z.object({
  timestamp: z.string(),
  hostname: z.string(),
  overall: VmCheckLevelSchema,
  checks: z.record(z.string(), VmCheckSchema),
  error: z.string().optional(),
});
export type VmHealthResult = z.infer<typeof VmHealthResultSchema>;

export const VmCleanupParamsSchema = z.object({
  mode: z.enum(['weekly', 'monthly', 'dry-run']),
});
export type VmCleanupParams = z.infer<typeof VmCleanupParamsSchema>;

export const VmCleanupResultSchema = z.object({
  success: z.boolean(),
  output: z.string(),
});
export type VmCleanupResult = z.infer<typeof VmCleanupResultSchema>;

// ── Container restart ─────────────────────────────────────────────────────────

export const VmContainerRestartParamsSchema = z.object({
  name: z.string().regex(/^[\w-]+$/, 'Invalid container name'),
});
export type VmContainerRestartParams = z.infer<typeof VmContainerRestartParamsSchema>;
