//native
type Render = {
apiKey: string
}
/**
* Add disk
* Attach a persistent disk to a web service, private service, or background worker.
The service must be redeployed for the disk to be attached.
*/
export async function main(
auth: Render,
body: { name: string; sizeGB: number; mountPath: string; serviceId: string }
) {
const url = new URL(`https://api.render.com/v1/disks`)
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