Edits history of script submission #22600 for ' List Applications (okta)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Applications
     * List applications in your org. Filter with `q` (matches name/label), a `filter` expression (e.g. status eq "ACTIVE"), or `expand` to inline related resources. Page with `limit` and the `after` cursor from the previous response's Link header.
     */
    export async function main(
      auth: RT.Okta,
      q: string | undefined,
      filter: string | undefined,
      expand: string | undefined,
      limit: number | undefined,
      after: string | undefined
    ) {
      const url = new URL(`${auth.org_url}/api/v1/apps`)
      if (q !== undefined && q !== "") url.searchParams.append("q", q)
      if (filter !== undefined && filter !== "")
        url.searchParams.append("filter", filter)
      if (expand !== undefined && expand !== "")
        url.searchParams.append("expand", expand)
      if (limit !== undefined) url.searchParams.append("limit", String(limit))
      if (after !== undefined && after !== "")
        url.searchParams.append("after", after)
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `SSWS ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 days ago