import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const netdataDomain = "netdata";
export const netdataDefaultName = "Netdata";

export type TNetdataRawData = TSimpleLocalRawData;
export interface INetdataSnapshot extends ISimpleLocalSnapshot {}
export interface INetdataResourceConfig {
  data_group?: string;
  dataGroup?: string;
  element?: string;
  icon?: string;
  invert?: boolean;
  name?: string;
}
export interface INetdataConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  apiPath?: string;
  resources?: Record<string, string | INetdataResourceConfig>;
}
export interface IHomeAssistantNetdataConfig extends INetdataConfig {}

export const netdataProfile: ISimpleLocalIntegrationProfile = {
  domain: netdataDomain,
  displayName: "Netdata",
  manufacturer: "Netdata",
  model: "Netdata local integration",
  defaultName: netdataDefaultName,
  defaultPort: 19999,
  defaultProtocol: 'http',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "netdata",
    "Netdata",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/netdata",
    "upstreamDomain": "netdata",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "netdata==1.3.0",
    ],
    "codeowners": [
      "@fabaff",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/netdata",
    "loggers": [
      "netdata",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "implemented": [
        "live Netdata HTTP polling of /api/v1/allmetrics and /api/v1/alarms using the documented local REST API",
        "Home Assistant-style resource mapping from data_group plus element configuration into sensor snapshots",
        "manual local setup for Netdata endpoints, snapshots, rawData, snapshotProvider, and injected native clients remains supported",
        "runtime mapping for Netdata device snapshots and Home Assistant platform metadata",
      ],
      "explicitUnsupported": [
        "Netdata write/control APIs; Home Assistant's integration is read-only local polling",
        "Netdata Cloud APIs, streaming, alert silencing, or dynamic configuration endpoints",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
