Edits history of script submission #5514 for ' List All Tunnels (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * List All Tunnels
     * Lists and filters all types of 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,
      tun_types: string | undefined,
      per_page: string | undefined,
      page: string | undefined
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${account_identifier}/tunnels`
      );
      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],
        ["tun_types", tun_types],
        ["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

  • nativets
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * List All Tunnels
     * Lists and filters all types of 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,
      tun_types: string | undefined,
      per_page: string | undefined,
      page: string | undefined
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${account_identifier}/tunnels`
      );
      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],
        ["tun_types", tun_types],
        ["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