//native
type Digitalocean = {
token: string;
};
/**
* Retrieve Multiple Apps' Daily Bandwidth Metrics
* Retrieve daily bandwidth usage metrics for multiple apps.
*/
export async function main(
auth: Digitalocean,
body: { app_ids: string[]; date?: string },
) {
const url = new URL(
`https://api.digitalocean.com/v2/apps/metrics/bandwidth_daily`,
);
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