1 | type Jira = { |
2 | username: string; |
3 | password: string; |
4 | domain: string; |
5 | }; |
6 | |
7 | * Get issue security level members by issue security scheme |
8 | * Returns issue security level members. |
9 |
|
10 | Only issue security level members in context of classic projects are returned. |
11 |
|
12 | **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg). |
13 | */ |
14 | export async function main( |
15 | auth: Jira, |
16 | issueSecuritySchemeId: string, |
17 | startAt: string | undefined, |
18 | maxResults: string | undefined, |
19 | issueSecurityLevelId: string | undefined, |
20 | expand: string | undefined |
21 | ) { |
22 | const url = new URL( |
23 | `https://${auth.domain}.atlassian.net/rest/api/2/issuesecurityschemes/${issueSecuritySchemeId}/members` |
24 | ); |
25 | for (const [k, v] of [ |
26 | ["startAt", startAt], |
27 | ["maxResults", maxResults], |
28 | ["issueSecurityLevelId", issueSecurityLevelId], |
29 | ["expand", expand], |
30 | ]) { |
31 | if (v !== undefined && v !== "") { |
32 | url.searchParams.append(k, v); |
33 | } |
34 | } |
35 | const response = await fetch(url, { |
36 | method: "GET", |
37 | headers: { |
38 | Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`), |
39 | }, |
40 | body: undefined, |
41 | }); |
42 | if (!response.ok) { |
43 | const text = await response.text(); |
44 | throw new Error(`${response.status} ${text}`); |
45 | } |
46 | return await response.json(); |
47 | } |
48 |
|