//native
type Digitalocean = {
token: string;
};
/**
* Patch the Default Project
* To update only specific attributes of your default project, send a PATCH request to `/v2/projects/default`. At least one of the following attributes needs to be sent.
*/
export async function main(
auth: Digitalocean,
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/default`);
const response = await fetch(url, {
method: "PATCH",
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