type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List fleet status devices
* List details for devices using WARP
*/
export async function main(
auth: Cloudflare,
account_identifier: string,
time_end: string | undefined,
time_start: string | undefined,
page: string | undefined,
per_page: string | undefined,
sort_by:
| "colo"
| "device_id"
| "mode"
| "platform"
| "status"
| "timestamp"
| "version"
| undefined,
colo: string | undefined,
device_id: string | undefined,
mode: string | undefined,
status: string | undefined,
platform: string | undefined,
version: string | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/dex/fleet-status/devices`
);
for (const [k, v] of [
["time_end", time_end],
["time_start", time_start],
["page", page],
["per_page", per_page],
["sort_by", sort_by],
["colo", colo],
["device_id", device_id],
["mode", mode],
["status", status],
["platform", platform],
["version", version],
]) {
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 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List fleet status devices
* List details for devices using WARP
*/
export async function main(
auth: Cloudflare,
account_identifier: string,
time_end: string | undefined,
time_start: string | undefined,
page: string | undefined,
per_page: string | undefined,
sort_by:
| "colo"
| "device_id"
| "mode"
| "platform"
| "status"
| "timestamp"
| "version"
| undefined,
colo: string | undefined,
device_id: string | undefined,
mode: string | undefined,
status: string | undefined,
platform: string | undefined,
version: string | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/dex/fleet-status/devices`
);
for (const [k, v] of [
["time_end", time_end],
["time_start", time_start],
["page", page],
["per_page", per_page],
["sort_by", sort_by],
["colo", colo],
["device_id", device_id],
["mode", mode],
["status", status],
["platform", platform],
["version", version],
]) {
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 920 days ago