//native
type Digitalocean = {
token: string;
};
/**
* Partially Update a VPC
* To update a subset of information about a VPC, send a PATCH request to
`/v2/vpcs/$VPC_ID`.
*/
export async function main(
auth: Digitalocean,
vpc_id: string,
body: { name?: string; description?: string } & { default?: false | true },
) {
const url = new URL(`https://api.digitalocean.com/v2/vpcs/${vpc_id}`);
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