0

Get device

by
Published today

Get one device (IMSI) of the site.

Script ericsson_ep5g Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 hours ago
1
//native
2

3
/**
4
 * Get device
5
 * Get one device (IMSI) of the site: name, status, online flag, segments (APNs), IMEI, ICCID, slices and location.
6
 */
7
export async function main(auth: RT.EricssonEp5g, imsi: string) {
8
  const base = auth.base_url.replace(/\/+$/, "")
9
  const url = new URL(
10
    `${base}/v2/organization/${encodeURIComponent(auth.organization)}/site/${encodeURIComponent(auth.site)}/nc/imsi/${encodeURIComponent(imsi)}`
11
  )
12

13
  const response = await fetch(url, {
14
    headers: {
15
      "X-Api-Key": auth.api_key,
16
      ...(auth.user_role ? { "X-User-Role": auth.user_role } : {}),
17
      Accept: "application/json",
18
    },
19
  })
20

21
  if (!response.ok) {
22
    throw new Error(`${response.status} ${await response.text()}`)
23
  }
24

25
  return await response.json()
26
}
27