Edits history of script submission #13593 for ' Update a Global IP assignment (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Update a Global IP assignment
     * Update a Global IP assignment.
     */
    export async function main(
    	auth: Telnyx,
    	id: string,
    	body: {
    		id?: string
    		record_type?: string
    		created_at?: string
    		updated_at?: string
    	} & {
    		record_type?: string
    		global_ip_id?: string
    		wireguard_peer_id?: string
    		status?: 'created' | 'provisioning' | 'provisioned' | 'deleting'
    		is_connected?: false | true
    		is_in_maintenance?: false | true
    		is_announced?: false | true
    	} & { global_ip_id?: {}; wireguard_peer_id?: {} }
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/global_ip_assignments/${id}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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