//native
type Digitalocean = {
token: string;
};
/**
* Resize a Database Cluster
* To resize a database cluster, send a PUT request to `/v2/databases/$DATABASE_ID/resize`. The body of the request must specify both the size and num_nodes attributes.
A successful request will receive a 202 Accepted status code with no body in response. Querying the database cluster will show that its status attribute will now be set to resizing. This will transition back to online when the resize operation has completed.
*/
export async function main(
auth: Digitalocean,
database_cluster_uuid: string,
body: { size: string; num_nodes: number; storage_size_mib?: number },
) {
const url = new URL(
`https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/resize`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
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 537 days ago