/**
 * GraphQL TypeScript types
 * These types should match the GraphQL schema
 */

export type ResourceType =
  | 'REGION'
  | 'SITE'
  | 'CLUSTER'
  | 'NODE'
  | 'VM'
  | 'POD'
  | 'SERVICE'
  | 'NETWORK'
  | 'STORAGE'
  | 'TUNNEL'
  | 'POLICY'

export type PillarCode =
  | 'SECURITY'
  | 'RELIABILITY'
  | 'COST_OPTIMIZATION'
  | 'PERFORMANCE_EFFICIENCY'
  | 'OPERATIONAL_EXCELLENCE'
  | 'SUSTAINABILITY'

export type HealthStatus = 'HEALTHY' | 'DEGRADED' | 'UNHEALTHY' | 'UNKNOWN'

export type FindingStatus = 'PASS' | 'FAIL' | 'WARNING' | 'INFO' | 'NOT_APPLICABLE'

export type Severity = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW' | 'INFO'

export type MetricType =
  | 'CPU_USAGE'
  | 'MEMORY_USAGE'
  | 'NETWORK_THROUGHPUT'
  | 'NETWORK_LATENCY'
  | 'STORAGE_IOPS'
  | 'REQUEST_RATE'
  | 'ERROR_RATE'
  | 'COST'
  | 'HEALTH_SCORE'

export interface Region {
  id: string
  name: string
  code: string
  country?: string
  coordinates?: {
    latitude: number
    longitude: number
  }
  sites?: Site[]
  clusters?: Cluster[]
}

export interface Site {
  id: string
  name: string
  region: Region
  clusters?: Cluster[]
}

export interface Cluster {
  id: string
  name: string
  region?: Region
  site?: Site
  nodes?: Node[]
  services?: Service[]
  health: HealthStatus
}

export interface Node {
  id: string
  name: string
  cluster: Cluster
  health: HealthStatus
}

export interface Service {
  id: string
  name: string
  cluster?: Cluster
  dependencies?: Service[]
  health: HealthStatus
}

export interface Resource {
  id: string
  name: string
  type: ResourceType
  region?: Region
  health?: HealthStatus
  metadata?: Record<string, unknown>
}

export interface Pillar {
  id: string
  code: PillarCode
  name: string
  description?: string
  controls?: Control[]
}

export interface Control {
  id: string
  code: string
  name: string
  pillar: Pillar
  description?: string
  findings?: Finding[]
}

export interface Finding {
  id: string
  control: Control
  resource: Resource
  status: FindingStatus
  severity: Severity
  title: string
  description?: string
  recommendation?: string
}

export interface Risk {
  id: string
  resource: Resource
  pillar?: Pillar
  severity: Severity
  title: string
  description?: string
  mitigation?: string
}

export interface Metrics {
  resource: Resource
  metricType: MetricType
  values: MetricValue[]
  timeRange: TimeRange
}

export interface MetricValue {
  timestamp: string
  value: number
  labels?: Record<string, string>
}

export interface TimeRange {
  start: string
  end: string
}

