Edits history of script submission #18742 for ' Update secret files (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Update secret files
     * Replace all secret files for a service with the provided list of secret files.
    
    **Any of the service's existing secret files not included in this request will be deleted.**
    
    This only applies to secret files set directly on the service, not to secret files in a linked environment group.
    
     */
    export async function main(
    	auth: Render,
    	serviceId: string,
    	body: { name: string; content: string }[]
    ) {
    	const url = new URL(`https://api.render.com/v1/services/${serviceId}/secret-files`)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		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