//native
/**
* Get KPIs
* Get a site KPI: latency (per-watchdog latency data points, optionally for one watchdog IMSI), throughput (average uplink and downlink in Mbit) or topdevices (top data-consuming devices). The watchdog IMSI only applies to latency.
*/
export async function main(
auth: RT.EricssonEp5g,
kpi: "latency" | "throughput" | "topdevices",
watchdog_imsi: string | undefined
) {
const base = auth.base_url.replace(/\/+$/, "")
const url = new URL(
`${base}/v2/organization/${encodeURIComponent(auth.organization)}/site/${encodeURIComponent(auth.site)}/kpi/${kpi}`
)
if (kpi === "latency" && watchdog_imsi != null && watchdog_imsi !== "") {
url.searchParams.append("imsi", watchdog_imsi)
}
const response = await fetch(url, {
headers: {
"X-Api-Key": auth.api_key,
...(auth.user_role ? { "X-User-Role": auth.user_role } : {}),
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 hours ago