Edits history of script submission #13042 for ' Create a Virtual Cross Connect (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Create a Virtual Cross Connect
     * 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.
     */
    export async function main(
    	auth: Telnyx,
    	body: {
    		id?: string
    		record_type?: string
    		created_at?: string
    		updated_at?: string
    	} & {
    		network_id?: string
    		name?: string
    		status?: 'created' | 'provisioning' | 'provisioned' | 'deleting'
    	} & {
    		record_type?: string
    		cloud_provider?: 'aws' | 'azure' | 'gce'
    		cloud_provider_region?: string
    		bgp_asn?: number
    		bandwidth_mbps?: number
    		primary_enabled?: false | true
    		primary_cloud_account_id?: string
    		primary_telnyx_ip?: string
    		primary_cloud_ip?: string
    		primary_bgp_key?: string
    		secondary_enabled?: false | true
    		secondary_cloud_account_id?: string
    		secondary_telnyx_ip?: string
    		secondary_cloud_ip?: string
    		secondary_bgp_key?: string
    	} & { region_code?: string } & {}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/virtual_cross_connects`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago