1 | |
2 | |
3 | * Retrieve paginated list of test results for repository owner and organization |
4 | * Retrieves the list of test results for a given repository and owner. Also accepts a number of query parameters to filter the results. |
5 | */ |
6 | export async function main( |
7 | auth: RT.Sentry, |
8 | owner: string, |
9 | repository: string, |
10 | sortBy?: string | undefined, |
11 | filterBy?: string | undefined, |
12 | interval?: string | undefined, |
13 | branch?: string | undefined, |
14 | limit?: string | undefined, |
15 | navigation?: string | undefined, |
16 | cursor?: string | undefined, |
17 | term?: string | undefined |
18 | ) { |
19 | const url = new URL( |
20 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/prevent/owner/${owner}/repository/${repository}/test-results/` |
21 | ) |
22 | for (const [k, v] of [ |
23 | ['sortBy', sortBy], |
24 | ['filterBy', filterBy], |
25 | ['interval', interval], |
26 | ['branch', branch], |
27 | ['limit', limit], |
28 | ['navigation', navigation], |
29 | ['cursor', cursor], |
30 | ['term', term] |
31 | ]) { |
32 | if (v !== undefined && v !== '') { |
33 | url.searchParams.append(k, v) |
34 | } |
35 | } |
36 | const response = await fetch(url, { |
37 | method: 'GET', |
38 | headers: { |
39 | Authorization: 'Bearer ' + auth.token |
40 | }, |
41 | body: undefined |
42 | }) |
43 | if (!response.ok) { |
44 | const text = await response.text() |
45 | throw new Error(`${response.status} ${text}`) |
46 | } |
47 | return await response.json() |
48 | } |
49 |
|