Edits history of script submission #18741 for ' Update registry credential (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Update registry credential
     * Update the registry credential with the provided ID. Services that use this credential must be redeployed to use updated values.
     */
    export async function main(
    	auth: Render,
    	registryCredentialId: string,
    	body: {
    		registry: 'GITHUB' | 'GITLAB' | 'DOCKER' | 'GOOGLE_ARTIFACT' | 'AWS_ECR'
    		name: string
    		username: string
    		authToken: string
    	}
    ) {
    	const url = new URL(`https://api.render.com/v1/registrycredentials/${registryCredentialId}`)
    
    	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