Edits history of script submission #13315 for ' List Virtual Cross Connect Cloud Coverage (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * List Virtual Cross Connect Cloud Coverage
     * 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.
     */
    export async function main(
    	auth: Telnyx,
    	page_number_: string | undefined,
    	page_size_: string | undefined,
    	filters_available_bandwidth__contains_: string | undefined,
    	filter_cloud_provider_: 'aws' | 'azure' | 'gce' | undefined,
    	filter_cloud_provider_region_: string | undefined,
    	filter_location_region_: string | undefined,
    	filter_location_site_: string | undefined,
    	filter_location_pop_: string | undefined,
    	filter_location_code_: string | undefined
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/virtual_cross_connects_coverage`)
    	for (const [k, v] of [
    		['page[number]', page_number_],
    		['page[size]', page_size_],
    		['filters[available_bandwidth][contains]', filters_available_bandwidth__contains_],
    		['filter[cloud_provider]', filter_cloud_provider_],
    		['filter[cloud_provider_region]', filter_cloud_provider_region_],
    		['filter[location.region]', filter_location_region_],
    		['filter[location.site]', filter_location_site_],
    		['filter[location.pop]', filter_location_pop_],
    		['filter[location.code]', filter_location_code_]
    	]) {
    		if (v !== undefined && v !== '' && k !== undefined) {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago