Edits history of script submission #18595 for ' Create Postgres instance (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Create Postgres instance
     * Create a new Postgres instance.
    
     */
    export async function main(
    	auth: Render,
    	body: {
    		databaseName?: string
    		databaseUser?: string
    		datadogAPIKey?: string
    		datadogSite?: string
    		name: string
    		enableHighAvailability?: false | true
    		environmentId?: string
    		ownerId: 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
    		region?: string
    		ipAllowList?: { cidrBlock: string; description: string }[]
    		readReplicas?: { name: string }[]
    		version: '11' | '12' | '13' | '14' | '15' | '16' | '17'
    	}
    ) {
    	const url = new URL(`https://api.render.com/v1/postgres`)
    
    	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 235 days ago