Edits history of script submission #12712 for ' Update a compute endpoint (neondb)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Neondb = {
    	apiKey: string
    }
    /**
     * Update a compute endpoint
     * Updates the specified compute endpoint.
     */
    export async function main(
    	auth: Neondb,
    	project_id: string,
    	endpoint_id: string,
    	body: {
    		endpoint: {
    			branch_id?: string
    			autoscaling_limit_min_cu?: number
    			autoscaling_limit_max_cu?: number
    			provisioner?: string
    			settings?: { pg_settings?: {}; pgbouncer_settings?: {} }
    			pooler_enabled?: false | true
    			pooler_mode?: 'transaction'
    			disabled?: false | true
    			passwordless_access?: false | true
    			suspend_timeout_seconds?: number
    		}
    	}
    ) {
    	const url = new URL(
    		`https://console.neon.tech/api/v2/projects/${project_id}/endpoints/${endpoint_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