1 | |
2 | |
3 | * List an organizations issues |
4 | * Return a list of issues for an organization. All parameters are supplied as query string parameters. A default query of `is:unresolved issue.priority:[high,medium]` is applied. To return all results, use an empty query value (i.e. ``?query=`). |
5 | */ |
6 | export async function main( |
7 | auth: RT.Sentry, |
8 | environment?: string | undefined, |
9 | project?: string | undefined, |
10 | statsPeriod?: string | undefined, |
11 | start?: string | undefined, |
12 | end?: string | undefined, |
13 | groupStatsPeriod?: '' | '14d' | '24h' | 'auto' | undefined, |
14 | shortIdLookup?: '0' | '1' | undefined, |
15 | query?: string | undefined, |
16 | viewId?: string | undefined, |
17 | sort?: 'date' | 'freq' | 'inbox' | 'new' | 'trends' | 'user' | undefined, |
18 | limit?: string | undefined, |
19 | expand?: string | undefined, |
20 | collapse?: string | undefined, |
21 | cursor?: string | undefined |
22 | ) { |
23 | const url = new URL( |
24 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/issues/` |
25 | ) |
26 | for (const [k, v] of [ |
27 | ['environment', environment], |
28 | ['project', project], |
29 | ['statsPeriod', statsPeriod], |
30 | ['start', start], |
31 | ['end', end], |
32 | ['groupStatsPeriod', groupStatsPeriod], |
33 | ['shortIdLookup', shortIdLookup], |
34 | ['query', query], |
35 | ['viewId', viewId], |
36 | ['sort', sort], |
37 | ['limit', limit], |
38 | ['expand', expand], |
39 | ['collapse', collapse], |
40 | ['cursor', cursor] |
41 | ]) { |
42 | if (v !== undefined && v !== '') { |
43 | url.searchParams.append(k, v) |
44 | } |
45 | } |
46 | const response = await fetch(url, { |
47 | method: 'GET', |
48 | headers: { |
49 | Authorization: 'Bearer ' + auth.token |
50 | }, |
51 | body: undefined |
52 | }) |
53 | if (!response.ok) { |
54 | const text = await response.text() |
55 | throw new Error(`${response.status} ${text}`) |
56 | } |
57 | return await response.json() |
58 | } |
59 |
|