type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List Cloudflare Tunnels
* Lists and filters Cloudflare Tunnels in an account.
*/
export async function main(
auth: Cloudflare,
account_identifier: string,
name: string | undefined,
is_deleted: string | undefined,
existed_at: string | undefined,
uuid: string | undefined,
was_active_at: string | undefined,
was_inactive_at: string | undefined,
include_prefix: string | undefined,
exclude_prefix: string | undefined,
per_page: string | undefined,
page: string | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/cfd_tunnel`
);
for (const [k, v] of [
["name", name],
["is_deleted", is_deleted],
["existed_at", existed_at],
["uuid", uuid],
["was_active_at", was_active_at],
["was_inactive_at", was_inactive_at],
["include_prefix", include_prefix],
["exclude_prefix", exclude_prefix],
["per_page", per_page],
["page", page],
]) {
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 Cloudflare Tunnels
* Lists and filters Cloudflare Tunnels in an account.
*/
export async function main(
auth: Cloudflare,
account_identifier: string,
name: string | undefined,
is_deleted: string | undefined,
existed_at: string | undefined,
uuid: string | undefined,
was_active_at: string | undefined,
was_inactive_at: string | undefined,
include_prefix: string | undefined,
exclude_prefix: string | undefined,
per_page: string | undefined,
page: string | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/cfd_tunnel`
);
for (const [k, v] of [
["name", name],
["is_deleted", is_deleted],
["existed_at", existed_at],
["uuid", uuid],
["was_active_at", was_active_at],
["was_inactive_at", was_inactive_at],
["include_prefix", include_prefix],
["exclude_prefix", exclude_prefix],
["per_page", per_page],
["page", page],
]) {
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