Edits history of script submission #4975 for ' Update DNS Firewall Cluster (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Update DNS Firewall Cluster
     * Modify a DNS Firewall Cluster configuration.
     */
    export async function main(
      auth: Cloudflare,
      identifier: string,
      account_identifier: string,
      body: {
        attack_mitigation?: {
          enabled?: boolean;
          only_when_origin_unhealthy?: { [k: string]: unknown };
          only_when_upstream_unhealthy?: boolean;
          [k: string]: unknown;
        };
        deprecate_any_requests: boolean;
        dns_firewall_ips: (string | string)[];
        ecs_fallback: boolean;
        id: string;
        maximum_cache_ttl: number;
        minimum_cache_ttl: number;
        modified_on: string;
        name: string;
        negative_cache_ttl?: number;
        origin_ips?: { [k: string]: unknown };
        ratelimit?: number;
        retries?: number;
        upstream_ips: (string | string)[];
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${account_identifier}/dns_firewall/${identifier}`
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      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;
    };
    /**
     * Update DNS Firewall Cluster
     * Modify a DNS Firewall Cluster configuration.
     */
    export async function main(
      auth: Cloudflare,
      identifier: string,
      account_identifier: string,
      body: {
        attack_mitigation?: {
          enabled?: boolean;
          only_when_origin_unhealthy?: { [k: string]: unknown };
          only_when_upstream_unhealthy?: boolean;
          [k: string]: unknown;
        };
        deprecate_any_requests: boolean;
        dns_firewall_ips: (string | string)[];
        ecs_fallback: boolean;
        id: string;
        maximum_cache_ttl: number;
        minimum_cache_ttl: number;
        modified_on: string;
        name: string;
        negative_cache_ttl?: number;
        origin_ips?: { [k: string]: unknown };
        ratelimit?: number;
        retries?: number;
        upstream_ips: (string | string)[];
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${account_identifier}/dns_firewall/${identifier}`
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 920 days ago