Edits history of script submission #5639 for ' Delete scheduled page test (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Delete scheduled page test
     * Deletes a scheduled test for a page.
     */
    export async function main(
      auth: Cloudflare,
      zone_identifier: string,
      url: string,
      region:
        | "asia-east1"
        | "asia-northeast1"
        | "asia-northeast2"
        | "asia-south1"
        | "asia-southeast1"
        | "australia-southeast1"
        | "europe-north1"
        | "europe-southwest1"
        | "europe-west1"
        | "europe-west2"
        | "europe-west3"
        | "europe-west4"
        | "europe-west8"
        | "europe-west9"
        | "me-west1"
        | "southamerica-east1"
        | "us-central1"
        | "us-east1"
        | "us-east4"
        | "us-south1"
        | "us-west1"
        | undefined
    ) {
      const url_ = new URL(
        `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/speed_api/schedule/${url}`
      );
      for (const [k, v] of [["region", region]]) {
        if (v !== undefined && v !== "") {
          url_.searchParams.append(k, v);
        }
      }
      const response = await fetch(url_, {
        method: "DELETE",
        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;
    };
    /**
     * Delete scheduled page test
     * Deletes a scheduled test for a page.
     */
    export async function main(
      auth: Cloudflare,
      zone_identifier: string,
      url: string,
      region:
        | "asia-east1"
        | "asia-northeast1"
        | "asia-northeast2"
        | "asia-south1"
        | "asia-southeast1"
        | "australia-southeast1"
        | "europe-north1"
        | "europe-southwest1"
        | "europe-west1"
        | "europe-west2"
        | "europe-west3"
        | "europe-west4"
        | "europe-west8"
        | "europe-west9"
        | "me-west1"
        | "southamerica-east1"
        | "us-central1"
        | "us-east1"
        | "us-east4"
        | "us-south1"
        | "us-west1"
        | undefined
    ) {
      const url_ = new URL(
        `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/speed_api/schedule/${url}`
      );
      for (const [k, v] of [["region", region]]) {
        if (v !== undefined && v !== "") {
          url_.searchParams.append(k, v);
        }
      }
      const response = await fetch(url_, {
        method: "DELETE",
        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