Edits history of script submission #24139 for ' List APNs (ericsson_ep5g)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List APNs
     * List the site's APNs (segments) with their IP pool CIDR, VRF, bandwidth limits, priority and DNS settings (v3 API, CPE version 25.50 or later). The API returns all APNs in one response; it has no paging parameters.
     */
    export async function main(auth: RT.EricssonEp5g) {
      const base = auth.base_url.replace(/\/+$/, "")
      const url = new URL(
        `${base}/v3/organization/${encodeURIComponent(auth.organization)}/site/${encodeURIComponent(auth.site)}/nc/apn`
      )
    
      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