//native
type Digitalocean = {
token: string;
};
/**
* Create a New Check
* To create an Uptime check, send a POST request to `/v2/uptime/checks` specifying the attributes
in the table below in the JSON body.
*/
export async function main(
auth: Digitalocean,
body: {
name?: string;
type?: "ping" | "http" | "https";
target?: string;
regions?: "us_east" | "us_west" | "eu_west" | "se_asia"[];
enabled?: false | true;
},
) {
const url = new URL(`https://api.digitalocean.com/v2/uptime/checks`);
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