//native
type Digitalocean = {
token: string;
};
/**
* Update a Check
* To update the settings of an Uptime check, send a PUT request to `/v2/uptime/checks/$CHECK_ID`.
*/
export async function main(
auth: Digitalocean,
check_id: string,
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/${check_id}`,
);
const response = await fetch(url, {
method: "PUT",
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