//native
type Digitalocean = {
token: string;
};
/**
* Update a VPC peering
* To update the name of a VPC peering, send a PATCH request to `/v2/vpc_peerings/$VPC_PEERING_ID` with the new `name` in the request body.
*/
export async function main(
auth: Digitalocean,
vpc_peering_id: string,
body: { name?: string },
) {
const url = new URL(
`https://api.digitalocean.com/v2/vpc_peerings/${vpc_peering_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