1 | |
2 | type Vercel = { |
3 | token: string; |
4 | }; |
5 | |
6 | * List access groups for a team, project or member |
7 | * List access groups |
8 | */ |
9 | export async function main( |
10 | auth: Vercel, |
11 | projectId: string | undefined, |
12 | search: string | undefined, |
13 | membersLimit: string | undefined, |
14 | projectsLimit: string | undefined, |
15 | limit: string | undefined, |
16 | next: string | undefined, |
17 | teamId: string | undefined, |
18 | slug: string | undefined, |
19 | ) { |
20 | const url = new URL(`https://api.vercel.com/v1/access-groups`); |
21 | for (const [k, v] of [ |
22 | ["projectId", projectId], |
23 | ["search", search], |
24 | ["membersLimit", membersLimit], |
25 | ["projectsLimit", projectsLimit], |
26 | ["limit", limit], |
27 | ["next", next], |
28 | ["teamId", teamId], |
29 | ["slug", slug], |
30 | ]) { |
31 | if (v !== undefined && v !== "" && k !== undefined) { |
32 | url.searchParams.append(k, v); |
33 | } |
34 | } |
35 | const response = await fetch(url, { |
36 | method: "GET", |
37 | headers: { |
38 | Authorization: "Bearer " + auth.token, |
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 |
|