//native
type Digitalocean = {
token: string;
};
/**
* Create a New VPC Peering
* To create a new VPC Peering, send a POST request to `/v2/vpc_peerings`
specifying a name and a list of two VPC IDs to peer. The response code, 202
Accepted, does not indicate the success or failure of the operation, just
that the request has been accepted for processing.
*/
export async function main(
auth: Digitalocean,
body: { name?: string } & { vpc_ids?: string[] },
) {
const url = new URL(`https://api.digitalocean.com/v2/vpc_peerings`);
const response = await fetch(url, {
method: "POST",
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