type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Get latest Internet traffic anomalies.
* Internet traffic anomalies are signals that might point to an outage,
These alerts are automatically detected by Radar and then manually verified by our team.
This endpoint returns the latest alerts.
*/
export async function main(
auth: Cloudflare,
limit: string | undefined,
offset: string | undefined,
dateRange:
| "1d"
| "2d"
| "7d"
| "14d"
| "28d"
| "12w"
| "24w"
| "52w"
| "1dControl"
| "2dControl"
| "7dControl"
| "14dControl"
| "28dControl"
| "12wControl"
| "24wControl"
| undefined,
dateStart: string | undefined,
dateEnd: string | undefined,
status: "VERIFIED" | "UNVERIFIED" | undefined,
asn: string | undefined,
location: string | undefined,
format: "JSON" | "CSV" | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/radar/traffic_anomalies`
);
for (const [k, v] of [
["limit", limit],
["offset", offset],
["dateRange", dateRange],
["dateStart", dateStart],
["dateEnd", dateEnd],
["status", status],
["asn", asn],
["location", location],
["format", format],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 403 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Get latest Internet traffic anomalies.
* Internet traffic anomalies are signals that might point to an outage,
These alerts are automatically detected by Radar and then manually verified by our team.
This endpoint returns the latest alerts.
*/
export async function main(
auth: Cloudflare,
limit: string | undefined,
offset: string | undefined,
dateRange:
| "1d"
| "2d"
| "7d"
| "14d"
| "28d"
| "12w"
| "24w"
| "52w"
| "1dControl"
| "2dControl"
| "7dControl"
| "14dControl"
| "28dControl"
| "12wControl"
| "24wControl"
| undefined,
dateStart: string | undefined,
dateEnd: string | undefined,
status: "VERIFIED" | "UNVERIFIED" | undefined,
asn: string | undefined,
location: string | undefined,
format: "JSON" | "CSV" | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/radar/traffic_anomalies`
);
for (const [k, v] of [
["limit", limit],
["offset", offset],
["dateRange", dateRange],
["dateStart", dateStart],
["dateEnd", dateEnd],
["status", status],
["asn", asn],
["location", location],
["format", format],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 941 days ago