//native
type Linode = {
token: string;
};
/**
* Create an IPv6 range
* Creates an IPv6 Range and assigns it based on the provided Linode or route target IPv6 SLAAC address.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
body: { linode_id?: number; prefix_length: 56 | 64; route_target?: string },
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/networking/ipv6/ranges`,
);
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 235 days ago