// Zabbix API Types

export interface ZabbixConfig {
  apiUrl: string;
  apiToken: string;
}

export interface ZabbixHost {
  hostid: string;
  host: string;
  name: string;
  status: string;
  description?: string;
  interfaces?: ZabbixHostInterface[];
  groups?: ZabbixHostGroup[];
  templates?: ZabbixTemplate[];
  parentTemplates?: ZabbixTemplate[];
  macros?: ZabbixHostMacro[];
  tags?: ZabbixHostTag[];
}

export interface ZabbixHostInterface {
  type: number;    // 1 = agent, 2 = SNMP, 3 = IPMI, 4 = JMX
  main: number;    // 1 = default
  useip: number;   // 1 = use IP, 0 = use DNS
  ip: string;
  dns: string;
  port: string;
}

export interface ZabbixHostGroup {
  groupid: string;
  name: string;
}

export interface ZabbixTemplate {
  templateid: string;
  host: string;
  name?: string;
}

export interface ZabbixHostMacro {
  macro: string;   // e.g. "{$AUTOTASK_COMPANY_ID}"
  value: string;
  description?: string;
}

export interface ZabbixHostTag {
  tag: string;     // e.g. "client"
  value: string;   // e.g. "TK Plastics"
}

export interface ZabbixHostCreateParams {
  host: string;
  name?: string;
  description?: string;
  interfaces: ZabbixHostInterface[];
  groups: Array<{ groupid: string }>;
  templates?: Array<{ templateid: string }>;
  macros?: ZabbixHostMacro[];
  tags?: ZabbixHostTag[];
}

export interface ZabbixHostUpdateParams {
  hostid: string;
  name?: string;
  description?: string;
  interfaces?: ZabbixHostInterface[];
  groups?: Array<{ groupid: string }>;
  templates?: Array<{ templateid: string }>;
  macros?: ZabbixHostMacro[];
  tags?: ZabbixHostTag[];
}

export interface ZabbixProblem {
  eventid: string;
  objectid: string;
  name: string;
  severity: string;
  clock: string;
  acknowledged: string;
  acknowledges?: Array<{ acknowledgeid: string; userid: string; clock: string; message: string }>;
  suppressed?: string;
  r_eventid?: string;
  hosts?: Array<{ hostid: string; name: string; status: string }>;
}

export interface ZabbixEvent {
  eventid: string;
  objectid: string;
  name: string;
  severity: string;
  clock: string;
  r_eventid?: string;
  r_clock?: string;
  hosts?: Array<{ hostid: string; name: string; status: string }>;
}

export interface ZabbixRpcResponse<T> {
  jsonrpc: string;
  result?: T;
  error?: {
    code: number;
    message: string;
    data?: string;
  };
  id: number;
}
