1 | |
2 | |
3 | * List Services By OrganizationId |
4 | * |
5 | */ |
6 | export async function main( |
7 | auth: RT.Qovery, |
8 | organizationId: string, |
9 | project_id?: string | undefined, |
10 | environment_id?: string | undefined, |
11 | cluster_id?: string | undefined |
12 | ) { |
13 | const url = new URL(`https://api.qovery.com/organization/${organizationId}/services`) |
14 | for (const [k, v] of [ |
15 | ['project_id', project_id], |
16 | ['environment_id', environment_id], |
17 | ['cluster_id', cluster_id] |
18 | ]) { |
19 | if (v !== undefined && v !== '') { |
20 | url.searchParams.append(k, v) |
21 | } |
22 | } |
23 | const response = await fetch(url, { |
24 | method: 'GET', |
25 | headers: { |
26 | Authorization: 'Token ' + auth.apiKey |
27 | }, |
28 | body: undefined |
29 | }) |
30 | if (!response.ok) { |
31 | const text = await response.text() |
32 | throw new Error(`${response.status} ${text}`) |
33 | } |
34 | return await response.json() |
35 | } |
36 |
|