0

Get URL list

by
Published today

Get one URL list by ID: name, data.urls, data.type, and pending = 1 when it has changes not yet applied. field restricts the returned columns, e.g. id,name,data.

Script netskope Verified

The script

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

3
/**
4
 * Get URL list
5
 * Get one URL list by ID: name, data.urls, data.type and the pending flag.
6
 */
7
export async function main(
8
  auth: RT.Netskope,
9
  url_list_id: number,
10
  field: string | undefined
11
) {
12
  const url = new URL(
13
    `${auth.tenant_url.replace(/\/+$/, "")}/api/v2/policy/urllist/${url_list_id}`
14
  )
15
  if (field != null && field !== "") {
16
    url.searchParams.append("field", field)
17
  }
18

19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      "Netskope-Api-Token": auth.token,
23
      Accept: "application/json",
24
    },
25
  })
26

27
  if (!response.ok) {
28
    throw new Error(`${response.status} ${await response.text()}`)
29
  }
30

31
  return await response.json()
32
}
33