//native
type Digitalocean = {
token: string;
};
/**
* Update a Project
* To update a project, send a PUT request to `/v2/projects/$PROJECT_ID`. All of the following attributes must be sent.
*/
export async function main(
auth: Digitalocean,
project_id: string,
body: {
id?: string;
owner_uuid?: string;
owner_id?: number;
name?: string;
description?: string;
purpose?: string;
environment?: "Development" | "Staging" | "Production";
created_at?: string;
updated_at?: string;
} & { is_default?: false | true },
) {
const url = new URL(`https://api.digitalocean.com/v2/projects/${project_id}`);
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 536 days ago