Get issue security level members

Returns a [paginated](#pagination) list of issue security level members. Only issue security level members in the context of classic projects are returned. Filtering using parameters is inclusive: if you specify both security scheme IDs and level IDs, the result will include all issue security level members from the specified schemes and levels. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

Script jira Verified

by hugo697 ยท 11/2/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 396 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Get issue security level members
8
 * Returns a [paginated](#pagination) list of issue security level members.
9

10
Only issue security level members in the context of classic projects are returned.
11

12
Filtering using parameters is inclusive: if you specify both security scheme IDs and level IDs, the result will include all issue security level members from the specified schemes and levels.
13

14
**[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
15
 */
16
export async function main(
17
  auth: Jira,
18
  startAt: string | undefined,
19
  maxResults: string | undefined,
20
  id: string | undefined,
21
  schemeId: string | undefined,
22
  levelId: string | undefined,
23
  expand: string | undefined
24
) {
25
  const url = new URL(
26
    `https://${auth.domain}.atlassian.net/rest/api/2/issuesecurityschemes/level/member`
27
  );
28
  for (const [k, v] of [
29
    ["startAt", startAt],
30
    ["maxResults", maxResults],
31
    ["id", id],
32
    ["schemeId", schemeId],
33
    ["levelId", levelId],
34
    ["expand", expand],
35
  ]) {
36
    if (v !== undefined && v !== "") {
37
      url.searchParams.append(k, v);
38
    }
39
  }
40
  const response = await fetch(url, {
41
    method: "GET",
42
    headers: {
43
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
44
    },
45
    body: undefined,
46
  });
47
  if (!response.ok) {
48
    const text = await response.text();
49
    throw new Error(`${response.status} ${text}`);
50
  }
51
  return await response.json();
52
}
53