1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * List Virtual Cross Connect Cloud Coverage |
7 | * List Virtual Cross Connects Cloud Coverage.This endpoint shows which cloud regions are available for the `location_code` your Virtual Cross Connect will be provisioned in. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | page_number_: string | undefined, |
12 | page_size_: string | undefined, |
13 | filters_available_bandwidth__contains_: string | undefined, |
14 | filter_cloud_provider_: 'aws' | 'azure' | 'gce' | undefined, |
15 | filter_cloud_provider_region_: string | undefined, |
16 | filter_location_region_: string | undefined, |
17 | filter_location_site_: string | undefined, |
18 | filter_location_pop_: string | undefined, |
19 | filter_location_code_: string | undefined |
20 | ) { |
21 | const url = new URL(`https://api.telnyx.com/v2/virtual_cross_connects_coverage`) |
22 | for (const [k, v] of [ |
23 | ['page[number]', page_number_], |
24 | ['page[size]', page_size_], |
25 | ['filters[available_bandwidth][contains]', filters_available_bandwidth__contains_], |
26 | ['filter[cloud_provider]', filter_cloud_provider_], |
27 | ['filter[cloud_provider_region]', filter_cloud_provider_region_], |
28 | ['filter[location.region]', filter_location_region_], |
29 | ['filter[location.site]', filter_location_site_], |
30 | ['filter[location.pop]', filter_location_pop_], |
31 | ['filter[location.code]', filter_location_code_] |
32 | ]) { |
33 | if (v !== undefined && v !== '' && k !== undefined) { |
34 | url.searchParams.append(k, v) |
35 | } |
36 | } |
37 | const response = await fetch(url, { |
38 | method: 'GET', |
39 | headers: { |
40 | Authorization: 'Bearer ' + auth.apiKey |
41 | }, |
42 | body: undefined |
43 | }) |
44 | if (!response.ok) { |
45 | const text = await response.text() |
46 | throw new Error(`${response.status} ${text}`) |
47 | } |
48 | return await response.json() |
49 | } |
50 |
|