//native
type Digitalocean = {
token: string;
};
/**
* Assign Resources to Default Project
* To assign resources to your default project, send a POST request to `/v2/projects/default/resources`.
*/
export async function main(auth: Digitalocean, body: { resources?: string[] }) {
const url = new URL(
`https://api.digitalocean.com/v2/projects/default/resources`,
);
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 537 days ago