Edits history of script submission #24119 for ' Get named list (infoblox_csp)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get named list
     * Get a Threat Defense named list by ID, including its items (items and items_described) and the security policies it is assigned to.
     */
    export async function main(auth: RT.InfobloxCsp, id: number) {
      const url = new URL(
        `${(auth.base_url || "https://csp.infoblox.com").replace(/\/+$/, "")}/api/atcfw/v1/named_lists/${id}`
      )
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Token ${auth.api_key}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago