0

Delete a cluster

by
Published Oct 17, 2025
Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Delete a cluster
4
 *
5
 */
6
export async function main(
7
	auth: RT.Qovery,
8
	organizationId: string,
9
	clusterId: string,
10
	deleteMode?: 'DEFAULT' | 'DELETE_CLUSTER_AND_QOVERY_CONFIG' | 'DELETE_QOVERY_CONFIG' | undefined
11
) {
12
	const url = new URL(`https://api.qovery.com/organization/${organizationId}/cluster/${clusterId}`)
13
	for (const [k, v] of [['deleteMode', deleteMode]]) {
14
		if (v !== undefined && v !== '') {
15
			url.searchParams.append(k, v)
16
		}
17
	}
18
	const response = await fetch(url, {
19
		method: 'DELETE',
20
		headers: {
21
			Authorization: 'Token ' + auth.apiKey
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.text()
30
}
31