1 | |
2 |
|
3 | |
4 | * List Applications |
5 | * 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. |
6 | */ |
7 | export async function main( |
8 | auth: RT.Okta, |
9 | q: string | undefined, |
10 | filter: string | undefined, |
11 | expand: string | undefined, |
12 | limit: number | undefined, |
13 | after: string | undefined |
14 | ) { |
15 | const url = new URL(`${auth.org_url}/api/v1/apps`) |
16 | if (q !== undefined && q !== "") url.searchParams.append("q", q) |
17 | if (filter !== undefined && filter !== "") |
18 | url.searchParams.append("filter", filter) |
19 | if (expand !== undefined && expand !== "") |
20 | url.searchParams.append("expand", expand) |
21 | if (limit !== undefined) url.searchParams.append("limit", String(limit)) |
22 | if (after !== undefined && after !== "") |
23 | url.searchParams.append("after", after) |
24 |
|
25 | const response = await fetch(url, { |
26 | method: "GET", |
27 | headers: { |
28 | Authorization: `SSWS ${auth.token}`, |
29 | Accept: "application/json", |
30 | }, |
31 | }) |
32 |
|
33 | if (!response.ok) { |
34 | throw new Error(`${response.status} ${await response.text()}`) |
35 | } |
36 |
|
37 | return await response.json() |
38 | } |
39 |
|