//native
type Render = {
apiKey: string
}
/**
* Restore snapshot
* Restore a persistent disk to an available snapshot.
**This operation is irreversible.** It will overwrite the current disk data. It might also trigger a service deploy.
Snapshot keys returned from the [List snapshots](https://api-docs.render.com/reference/list-snapshots) endpoint expire after 24 hours. If a snapshot key has expired, query the endpoint again for a new key.
*/
export async function main(
auth: Render,
diskId: string,
body: { snapshotKey: string; instanceId?: string }
) {
const url = new URL(`https://api.render.com/v1/disks/${diskId}/snapshots/restore`)
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