0

Assign or update a VPC endpoint

by
Published Apr 8, 2025

Assigns the specified VPC endpoint to the specified organization or updates the existing assignment. This endpoint is under active development and its semantics may change in the future.

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Assign or update a VPC endpoint
7
 * Assigns the specified VPC endpoint to the specified organization
8
or updates the existing assignment.
9
This endpoint is under active development and its semantics may change in the future.
10

11
 */
12
export async function main(
13
	auth: Neondb,
14
	org_id: string,
15
	region_id: string,
16
	vpc_endpoint_id: string,
17
	body: { label: string }
18
) {
19
	const url = new URL(
20
		`https://console.neon.tech/api/v2/organizations/${org_id}/vpc/region/${region_id}/vpc-endpoints/${vpc_endpoint_id}`
21
	)
22

23
	const response = await fetch(url, {
24
		method: 'POST',
25
		headers: {
26
			'Content-Type': 'application/json',
27
			Authorization: 'Bearer ' + auth.apiKey
28
		},
29
		body: JSON.stringify(body)
30
	})
31
	if (!response.ok) {
32
		const text = await response.text()
33
		throw new Error(`${response.status} ${text}`)
34
	}
35
	return await response.json()
36
}
37