1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Create a Virtual Cross Connect |
7 | * Create a new Virtual Cross Connect.For AWS and GCE, you have the option of creating the primary connection first and the secondary connection later. You also have the option of disabling the primary and/or secondary connections at any time and later re-enabling them. With Azure, you do not have this option. Azure requires both the primary and secondary connections to be created at the same time and they can not be independantly disabled. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | body: { |
12 | id?: string |
13 | record_type?: string |
14 | created_at?: string |
15 | updated_at?: string |
16 | } & { |
17 | network_id?: string |
18 | name?: string |
19 | status?: 'created' | 'provisioning' | 'provisioned' | 'deleting' |
20 | } & { |
21 | record_type?: string |
22 | cloud_provider?: 'aws' | 'azure' | 'gce' |
23 | cloud_provider_region?: string |
24 | bgp_asn?: number |
25 | bandwidth_mbps?: number |
26 | primary_enabled?: false | true |
27 | primary_cloud_account_id?: string |
28 | primary_telnyx_ip?: string |
29 | primary_cloud_ip?: string |
30 | primary_bgp_key?: string |
31 | secondary_enabled?: false | true |
32 | secondary_cloud_account_id?: string |
33 | secondary_telnyx_ip?: string |
34 | secondary_cloud_ip?: string |
35 | secondary_bgp_key?: string |
36 | } & { region_code?: string } & {} |
37 | ) { |
38 | const url = new URL(`https://api.telnyx.com/v2/virtual_cross_connects`) |
39 |
|
40 | const response = await fetch(url, { |
41 | method: 'POST', |
42 | headers: { |
43 | 'Content-Type': 'application/json', |
44 | Authorization: 'Bearer ' + auth.apiKey |
45 | }, |
46 | body: JSON.stringify(body) |
47 | }) |
48 | if (!response.ok) { |
49 | const text = await response.text() |
50 | throw new Error(`${response.status} ${text}`) |
51 | } |
52 | return await response.json() |
53 | } |
54 |
|