Edits history of script submission #18724 for ' Update Postgres instance (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Update Postgres instance
     * Update a Postgres instance by ID.
    
     */
    export async function main(
    	auth: Render,
    	postgresId: string,
    	body: {
    		name?: string
    		plan?:
    			| 'free'
    			| 'starter'
    			| 'standard'
    			| 'pro'
    			| 'pro_plus'
    			| 'custom'
    			| 'basic_256mb'
    			| 'basic_1gb'
    			| 'basic_4gb'
    			| 'pro_4gb'
    			| 'pro_8gb'
    			| 'pro_16gb'
    			| 'pro_32gb'
    			| 'pro_64gb'
    			| 'pro_128gb'
    			| 'pro_192gb'
    			| 'pro_256gb'
    			| 'pro_384gb'
    			| 'pro_512gb'
    			| 'accelerated_16gb'
    			| 'accelerated_32gb'
    			| 'accelerated_64gb'
    			| 'accelerated_128gb'
    			| 'accelerated_256gb'
    			| 'accelerated_384gb'
    			| 'accelerated_512gb'
    			| 'accelerated_768gb'
    			| 'accelerated_1024gb'
    		diskSizeGB?: number
    		enableHighAvailability?: false | true
    		datadogAPIKey?: string
    		datadogSite?: string
    		ipAllowList?: { cidrBlock: string; description: string }[]
    		readReplicas?: { name: string }[]
    	}
    ) {
    	const url = new URL(`https://api.render.com/v1/postgres/${postgresId}`)
    
    	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 235 days ago