0

Update the Virtual Cross Connect

by
Published Apr 8, 2025

Update the Virtual Cross Connect.Cloud IPs can only be patched during the `created` state, as GCE will only inform you of your generated IP once the pending connection requested has been accepted. Once the Virtual Cross Connect has moved to `provisioning`, the IPs can no longer be patched.Once the Virtual Cross Connect has moved to `provisioned` and you are ready to enable routing, you can toggle the routing announcements to `true`.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Update the Virtual Cross Connect
7
 * Update the Virtual Cross Connect.Cloud IPs can only be patched during the `created` state, as GCE will only inform you of your generated IP once the pending connection requested has been accepted. Once the Virtual Cross Connect has moved to `provisioning`, the IPs can no longer be patched.Once the Virtual Cross Connect has moved to `provisioned` and you are ready to enable routing, you can toggle the routing announcements to `true`.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		primary_enabled?: false | true
14
		primary_routing_announcement?: false | true
15
		primary_cloud_ip?: string
16
		secondary_enabled?: false | true
17
		secondary_routing_announcement?: false | true
18
		secondary_cloud_ip?: string
19
	}
20
) {
21
	const url = new URL(`https://api.telnyx.com/v2/virtual_cross_connects/${id}`)
22

23
	const response = await fetch(url, {
24
		method: 'PATCH',
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