1 | |
2 |
|
3 | |
4 | * List Boards |
5 | * List Jira Software boards, optionally filtered by type, name or project. Paginated with `start_at` / `max_results`; the response carries `isLast`. |
6 | */ |
7 | export async function main( |
8 | auth: RT.Jira, |
9 | type: "scrum" | "kanban" | "simple" | undefined, |
10 | name: string | undefined, |
11 | project_key_or_id: string | undefined, |
12 | start_at: number | undefined, |
13 | max_results: number | undefined |
14 | ) { |
15 | const url = new URL( |
16 | `https://${auth.domain}.atlassian.net/rest/agile/1.0/board` |
17 | ) |
18 | if (type != null && type !== "") { |
19 | url.searchParams.append("type", type) |
20 | } |
21 | if (name != null && name !== "") { |
22 | url.searchParams.append("name", name) |
23 | } |
24 | if (project_key_or_id != null && project_key_or_id !== "") { |
25 | url.searchParams.append("projectKeyOrId", project_key_or_id) |
26 | } |
27 | if (start_at != null) { |
28 | url.searchParams.append("startAt", String(start_at)) |
29 | } |
30 | if (max_results != null) { |
31 | url.searchParams.append("maxResults", String(max_results)) |
32 | } |
33 |
|
34 | const response = await fetch(url, { |
35 | method: "GET", |
36 | headers: { |
37 | Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`, |
38 | Accept: "application/json", |
39 | }, |
40 | }) |
41 |
|
42 | if (!response.ok) { |
43 | throw new Error(`${response.status} ${await response.text()}`) |
44 | } |
45 |
|
46 | return await response.json() |
47 | } |
48 |
|