0

List Cluster Kubernetes Events

by
Published Oct 17, 2025

List Cluster Kubernetes Events

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List Cluster Kubernetes Events
4
 * List Cluster Kubernetes Events
5
 */
6
export async function main(
7
	auth: RT.Qovery,
8
	clusterId: string,
9
	from_date_time: string | undefined,
10
	to_date_time: string | undefined,
11
	node_name?: string | undefined,
12
	pod_name?: string | undefined,
13
	reporting_component?: string | undefined
14
) {
15
	const url = new URL(`https://api.qovery.com/cluster/${clusterId}/events`)
16
	for (const [k, v] of [
17
		['from_date_time', from_date_time],
18
		['to_date_time', to_date_time],
19
		['node_name', node_name],
20
		['pod_name', pod_name],
21
		['reporting_component', reporting_component]
22
	]) {
23
		if (v !== undefined && v !== '') {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Token ' + auth.apiKey
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40